Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions apps/test-bot/commandkit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { defineConfig } from 'commandkit';

export default defineConfig({
main: 'index.js',
src: 'src',
});
export default defineConfig();
7 changes: 7 additions & 0 deletions apps/test-bot/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Client } from 'discord.js';

const client = new Client({
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],
});

export default client;
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SlashCommandProps, CommandData, dmOnly } from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'dm-only',
description: 'This is a dm only command',
};

export async function run({ interaction }: SlashCommandProps) {
export async function chatInput({ interaction }: SlashCommandProps) {
dmOnly();

await interaction.reply('This command can only be used in a dm.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
AutocompleteProps,
} from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'ping',
description: 'Pong!',
options: [
Expand Down Expand Up @@ -42,7 +42,7 @@ export async function autocomplete({ interaction }: AutocompleteProps) {
interaction.respond(filtered);
}

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

const button = new ButtonKit()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SlashCommandProps, CommandData, guildOnly } from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'guild-only',
description: 'This is a guild only command.',
};

export async function run({ interaction }: SlashCommandProps) {
export async function chatInput({ interaction }: SlashCommandProps) {
guildOnly();

await interaction.reply('This command can only be used in a guild.');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SlashCommandProps, CommandOptions, CommandData } from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'reload',
description: 'Reload commands, events, and validations.',
};

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

// await handler.reloadCommands();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SlashCommandProps, CommandData, afterCommand } from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'run-after',
description: 'This is a run-after command',
};

export async function run({ interaction }: SlashCommandProps) {
export async function chatInput({ interaction }: SlashCommandProps) {
afterCommand((env) => {
console.log(
`The command ${interaction.commandName} was executed successfully in ${env
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SlashCommandProps, CommandData } from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'help',
description: 'This is a help command.',
};
Expand All @@ -12,7 +12,7 @@ function $botVersion(): string {
return require(path).version;
}

export async function run({ interaction, handler }: SlashCommandProps) {
export async function chatInput({ interaction, handler }: SlashCommandProps) {
await interaction.deferReply();

const botVersion = $botVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
AutocompleteProps,
} from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'ping',
description: 'Pong!',
options: [
Expand Down Expand Up @@ -42,7 +42,7 @@ export async function autocomplete({ interaction }: AutocompleteProps) {
interaction.respond(filtered);
}

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

const button = new ButtonKit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CommandKit, {
} from 'commandkit';
import { MessageFlags } from 'discord.js';

export const data: CommandData = {
export const command: CommandData = {
name: 'commandkit',
description: 'This is a commandkit command.',
};
Expand Down Expand Up @@ -40,7 +40,7 @@ function ButtonGrid() {
);
}

export async function run({ interaction }: SlashCommandProps) {
export async function chatInput({ interaction }: SlashCommandProps) {
await interaction.deferReply();

await interaction.editReply({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CommandKit, {
} from 'commandkit';
import { ButtonStyle, MessageFlags } from 'discord.js';

export const data: CommandData = {
export const command: CommandData = {
name: 'confirm',
description: 'This is a confirm command.',
};
Expand All @@ -30,7 +30,7 @@ const handleCancel: OnButtonKitClick = async (interaction, context) => {
context.dispose();
};

export async function run({ interaction }: SlashCommandProps) {
export async function chatInput({ interaction }: SlashCommandProps) {
const buttons = (
<ActionRow>
<Button onClick={handleCancel} style={ButtonStyle.Primary}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SlashCommandProps, CommandData, cacheTag } from 'commandkit';
import { database } from '../../database/store';
import { database } from '../../../database/store.ts';

export const data: CommandData = {
export const command: CommandData = {
name: 'xp',
description: 'This is an xp command.',
};
Expand All @@ -17,7 +17,7 @@ async function getUserXP(guildId: string, userId: string) {
return xp;
}

export async function run({ interaction }: SlashCommandProps) {
export async function chatInput({ interaction }: SlashCommandProps) {
await interaction.deferReply();

const dataRetrievalStart = Date.now();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SlashCommandProps, CommandData, cache } from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'random',
description: 'This is a random command.',
};
Expand All @@ -12,7 +12,7 @@ const random = cache(
{ name: 'random', ttl: 60_000 },
);

export async function run({ interaction }: SlashCommandProps) {
export async function chatInput({ interaction }: SlashCommandProps) {
await interaction.deferReply();

const xp = await random();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SlashCommandProps, CommandData, invalidate } from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'invalidate-random',
description: 'This is a random command invalidation.',
};

export async function run({ interaction }: SlashCommandProps) {
export async function chatInput({ interaction }: SlashCommandProps) {
await interaction.deferReply();

await invalidate('random');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SlashCommandProps, CommandData, revalidate } from 'commandkit';

export const data: CommandData = {
export const command: CommandData = {
name: 'revalidate-random',
description: 'This is a random command invalidation.',
};

export async function run({ interaction }: SlashCommandProps) {
export async function chatInput({ interaction }: SlashCommandProps) {
await interaction.deferReply();

const revalidated = await revalidate<number>('random');
Expand Down
3 changes: 0 additions & 3 deletions apps/test-bot/src/app/events/messageCreate/event.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Message } from 'discord.js';
import { invalidate } from 'commandkit';
import { database } from '../../database/store';
import { database } from '../../../database/store.ts';

export default async function (message: Message) {
if (message.author.bot || !message.inGuild()) return;
Expand Down
6 changes: 0 additions & 6 deletions apps/test-bot/src/events/ready/console-log.ts

This file was deleted.

23 changes: 0 additions & 23 deletions apps/test-bot/src/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions apps/test-bot/src/validations/devOnly.ts

This file was deleted.

2 changes: 2 additions & 0 deletions apps/test-bot/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"target": "ESNext",
"module": "Preserve",
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"noEmit": true,
"lib": ["ESNext", "DOM"],
"jsx": "react",
"jsxFactory": "CommandKit.createElement",
Expand Down
2 changes: 1 addition & 1 deletion packages/commandkit/bin/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node

import { bootstrapCommandkitCLI } from '../dist/index.mjs';
import { bootstrapCommandkitCLI } from '../dist/index.js';

await bootstrapCommandkitCLI(process.argv);
5 changes: 3 additions & 2 deletions packages/commandkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"scripts": {
"lint": "tsc --noEmit",
"dev": "tsup --watch",
"dev": "pnpm run --filter=test-bot dev",
"build": "tsup",
"publish-package": "npm publish",
"test": "vitest"
Expand All @@ -34,14 +34,15 @@
"@babel/parser": "^7.26.5",
"@babel/traverse": "^7.26.5",
"@babel/types": "^7.26.5",
"chokidar": "^4.0.3",
"commander": "^12.1.0",
"dotenv": "^16.4.7",
"ms": "^2.1.3",
"ora": "^8.0.1",
"picocolors": "^1.1.1",
"rfdc": "^1.3.1",
"rimraf": "^5.0.5",
"tsup": "^8.3.5",
"tsup": "^8.4.0",
"use-macro": "^1.1.0"
},
"devDependencies": {
Expand Down
Loading