Skip to content

Commit b01fc76

Browse files
authored
Merge pull request #86 from underctrl-io/rewrite
feat!: rewrite commandkit
2 parents 662fba2 + 2107673 commit b01fc76

File tree

92 files changed

+2582
-2667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2582
-2667
lines changed

apps/test-bot/commandkit.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
import { defineConfig } from 'commandkit';
22

3-
export default defineConfig({
4-
main: 'index.js',
5-
src: 'src',
6-
});
3+
export default defineConfig();

apps/test-bot/src/app.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Client } from 'discord.js';
2+
3+
const client = new Client({
4+
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],
5+
});
6+
7+
export default client;

apps/test-bot/src/commands/misc/dm-only.ts apps/test-bot/src/app/commands/(actions)/dm-only.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { SlashCommandProps, CommandData, dmOnly } from 'commandkit';
22

3-
export const data: CommandData = {
3+
export const command: CommandData = {
44
name: 'dm-only',
55
description: 'This is a dm only command',
66
};
77

8-
export async function run({ interaction }: SlashCommandProps) {
8+
export async function chatInput({ interaction }: SlashCommandProps) {
99
dmOnly();
1010

1111
await interaction.reply('This command can only be used in a dm.');

apps/test-bot/src/commands/misc/giveaway.ts apps/test-bot/src/app/commands/(actions)/giveaway.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
AutocompleteProps,
1212
} from 'commandkit';
1313

14-
export const data: CommandData = {
14+
export const command: CommandData = {
1515
name: 'ping',
1616
description: 'Pong!',
1717
options: [
@@ -42,7 +42,7 @@ export async function autocomplete({ interaction }: AutocompleteProps) {
4242
interaction.respond(filtered);
4343
}
4444

45-
export async function run({ interaction, client }: SlashCommandProps) {
45+
export async function chatInput({ interaction, client }: SlashCommandProps) {
4646
if (!interaction.channel) return;
4747

4848
const button = new ButtonKit()

apps/test-bot/src/commands/misc/guild-only.ts apps/test-bot/src/app/commands/(actions)/guild-only.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { SlashCommandProps, CommandData, guildOnly } from 'commandkit';
22

3-
export const data: CommandData = {
3+
export const command: CommandData = {
44
name: 'guild-only',
55
description: 'This is a guild only command.',
66
};
77

8-
export async function run({ interaction }: SlashCommandProps) {
8+
export async function chatInput({ interaction }: SlashCommandProps) {
99
guildOnly();
1010

1111
await interaction.reply('This command can only be used in a guild.');

apps/test-bot/src/commands/misc/reload.ts apps/test-bot/src/app/commands/(developer)/reload.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { SlashCommandProps, CommandOptions, CommandData } from 'commandkit';
22

3-
export const data: CommandData = {
3+
export const command: CommandData = {
44
name: 'reload',
55
description: 'Reload commands, events, and validations.',
66
};
77

8-
export async function run({ interaction, handler }: SlashCommandProps) {
8+
export async function chatInput({ interaction, handler }: SlashCommandProps) {
99
await interaction.deferReply({ ephemeral: true });
1010

1111
// await handler.reloadCommands();

apps/test-bot/src/commands/misc/run-after.ts apps/test-bot/src/app/commands/(developer)/run-after.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { SlashCommandProps, CommandData, afterCommand } from 'commandkit';
22

3-
export const data: CommandData = {
3+
export const command: CommandData = {
44
name: 'run-after',
55
description: 'This is a run-after command',
66
};
77

8-
export async function run({ interaction }: SlashCommandProps) {
8+
export async function chatInput({ interaction }: SlashCommandProps) {
99
afterCommand((env) => {
1010
console.log(
1111
`The command ${interaction.commandName} was executed successfully in ${env

apps/test-bot/src/commands/misc/help.ts apps/test-bot/src/app/commands/(general)/help.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SlashCommandProps, CommandData } from 'commandkit';
22

3-
export const data: CommandData = {
3+
export const command: CommandData = {
44
name: 'help',
55
description: 'This is a help command.',
66
};
@@ -12,7 +12,7 @@ function $botVersion(): string {
1212
return require(path).version;
1313
}
1414

15-
export async function run({ interaction, handler }: SlashCommandProps) {
15+
export async function chatInput({ interaction, handler }: SlashCommandProps) {
1616
await interaction.deferReply();
1717

1818
const botVersion = $botVersion();

apps/test-bot/src/commands/misc/ping.ts apps/test-bot/src/app/commands/(general)/ping.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
AutocompleteProps,
1212
} from 'commandkit';
1313

14-
export const data: CommandData = {
14+
export const command: CommandData = {
1515
name: 'ping',
1616
description: 'Pong!',
1717
options: [
@@ -42,7 +42,7 @@ export async function autocomplete({ interaction }: AutocompleteProps) {
4242
interaction.respond(filtered);
4343
}
4444

45-
export async function run({ interaction, client }: SlashCommandProps) {
45+
export async function chatInput({ interaction, client }: SlashCommandProps) {
4646
if (!interaction.channel) return;
4747

4848
const button = new ButtonKit()

apps/test-bot/src/commands/misc/commandkit.tsx apps/test-bot/src/app/commands/(interactions)/commandkit.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CommandKit, {
77
} from 'commandkit';
88
import { MessageFlags } from 'discord.js';
99

10-
export const data: CommandData = {
10+
export const command: CommandData = {
1111
name: 'commandkit',
1212
description: 'This is a commandkit command.',
1313
};
@@ -40,7 +40,7 @@ function ButtonGrid() {
4040
);
4141
}
4242

43-
export async function run({ interaction }: SlashCommandProps) {
43+
export async function chatInput({ interaction }: SlashCommandProps) {
4444
await interaction.deferReply();
4545

4646
await interaction.editReply({

apps/test-bot/src/commands/misc/confirmation.tsx apps/test-bot/src/app/commands/(interactions)/confirmation.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CommandKit, {
77
} from 'commandkit';
88
import { ButtonStyle, MessageFlags } from 'discord.js';
99

10-
export const data: CommandData = {
10+
export const command: CommandData = {
1111
name: 'confirm',
1212
description: 'This is a confirm command.',
1313
};
@@ -30,7 +30,7 @@ const handleCancel: OnButtonKitClick = async (interaction, context) => {
3030
context.dispose();
3131
};
3232

33-
export async function run({ interaction }: SlashCommandProps) {
33+
export async function chatInput({ interaction }: SlashCommandProps) {
3434
const buttons = (
3535
<ActionRow>
3636
<Button onClick={handleCancel} style={ButtonStyle.Primary}>

apps/test-bot/src/commands/misc/xp.ts apps/test-bot/src/app/commands/(leveling)/xp.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { SlashCommandProps, CommandData, cacheTag } from 'commandkit';
2-
import { database } from '../../database/store';
2+
import { database } from '../../../database/store.ts';
33

4-
export const data: CommandData = {
4+
export const command: CommandData = {
55
name: 'xp',
66
description: 'This is an xp command.',
77
};
@@ -17,7 +17,7 @@ async function getUserXP(guildId: string, userId: string) {
1717
return xp;
1818
}
1919

20-
export async function run({ interaction }: SlashCommandProps) {
20+
export async function chatInput({ interaction }: SlashCommandProps) {
2121
await interaction.deferReply();
2222

2323
const dataRetrievalStart = Date.now();

apps/test-bot/src/commands/misc/random.ts apps/test-bot/src/app/commands/random/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SlashCommandProps, CommandData, cache } from 'commandkit';
22

3-
export const data: CommandData = {
3+
export const command: CommandData = {
44
name: 'random',
55
description: 'This is a random command.',
66
};
@@ -12,7 +12,7 @@ const random = cache(
1212
{ name: 'random', ttl: 60_000 },
1313
);
1414

15-
export async function run({ interaction }: SlashCommandProps) {
15+
export async function chatInput({ interaction }: SlashCommandProps) {
1616
await interaction.deferReply();
1717

1818
const xp = await random();

apps/test-bot/src/commands/misc/invalidate-random.ts apps/test-bot/src/app/commands/random/invalidate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { SlashCommandProps, CommandData, invalidate } from 'commandkit';
22

3-
export const data: CommandData = {
3+
export const command: CommandData = {
44
name: 'invalidate-random',
55
description: 'This is a random command invalidation.',
66
};
77

8-
export async function run({ interaction }: SlashCommandProps) {
8+
export async function chatInput({ interaction }: SlashCommandProps) {
99
await interaction.deferReply();
1010

1111
await invalidate('random');

apps/test-bot/src/commands/misc/revalidate-random.ts apps/test-bot/src/app/commands/random/revalidate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { SlashCommandProps, CommandData, revalidate } from 'commandkit';
22

3-
export const data: CommandData = {
3+
export const command: CommandData = {
44
name: 'revalidate-random',
55
description: 'This is a random command invalidation.',
66
};
77

8-
export async function run({ interaction }: SlashCommandProps) {
8+
export async function chatInput({ interaction }: SlashCommandProps) {
99
await interaction.deferReply();
1010

1111
const revalidated = await revalidate<number>('random');

apps/test-bot/src/app/events/messageCreate/event.ts

-3
This file was deleted.

apps/test-bot/src/events/messageCreate/give-xp.ts apps/test-bot/src/app/events/messageCreate/give-xp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Message } from 'discord.js';
22
import { invalidate } from 'commandkit';
3-
import { database } from '../../database/store';
3+
import { database } from '../../../database/store.ts';
44

55
export default async function (message: Message) {
66
if (message.author.bot || !message.inGuild()) return;

apps/test-bot/src/events/ready/console-log.ts

-6
This file was deleted.

apps/test-bot/src/index.ts

-23
This file was deleted.

apps/test-bot/src/validations/devOnly.ts

-13
This file was deleted.

apps/test-bot/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"target": "ESNext",
44
"module": "Preserve",
55
"moduleResolution": "Bundler",
6+
"allowImportingTsExtensions": true,
7+
"noEmit": true,
68
"lib": ["ESNext", "DOM"],
79
"jsx": "react",
810
"jsxFactory": "CommandKit.createElement",

packages/commandkit/bin/index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
22

3-
import { bootstrapCommandkitCLI } from '../dist/index.mjs';
3+
import { bootstrapCommandkitCLI } from '../dist/index.js';
44

55
await bootstrapCommandkitCLI(process.argv);

packages/commandkit/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"scripts": {
1515
"lint": "tsc --noEmit",
16-
"dev": "tsup --watch",
16+
"dev": "pnpm run --filter=test-bot dev",
1717
"build": "tsup",
1818
"publish-package": "npm publish",
1919
"test": "vitest"
@@ -34,14 +34,15 @@
3434
"@babel/parser": "^7.26.5",
3535
"@babel/traverse": "^7.26.5",
3636
"@babel/types": "^7.26.5",
37+
"chokidar": "^4.0.3",
3738
"commander": "^12.1.0",
3839
"dotenv": "^16.4.7",
3940
"ms": "^2.1.3",
4041
"ora": "^8.0.1",
4142
"picocolors": "^1.1.1",
4243
"rfdc": "^1.3.1",
4344
"rimraf": "^5.0.5",
44-
"tsup": "^8.3.5",
45+
"tsup": "^8.4.0",
4546
"use-macro": "^1.1.0"
4647
},
4748
"devDependencies": {

0 commit comments

Comments
 (0)