create-discord-bot
Version:
A simple way to create a startup Discord bot.
21 lines (16 loc) • 584 B
text/typescript
import { Events } from 'npm:discord.js@^14.20.0';
import type { Event } from './index.ts';
import { loadCommands } from '../util/loaders.ts';
const commands = await loadCommands(new URL('../commands/', import.meta.url));
export default {
name: Events.InteractionCreate,
async execute(interaction) {
if (interaction.isCommand()) {
const command = commands.get(interaction.commandName);
if (!command) {
throw new Error(`Command '${interaction.commandName}' not found.`);
}
await command.execute(interaction);
}
},
} satisfies Event<Events.InteractionCreate>;