Convert to Typescript

This commit is contained in:
2024-09-16 09:56:40 +00:00
parent a89150fc2f
commit 6a59118f4a
42 changed files with 2916 additions and 785 deletions

35
src/index.ts Normal file
View File

@@ -0,0 +1,35 @@
import 'dotenv/config';
import {
Client,
Collection,
Events,
GatewayIntentBits,
Interaction,
} from 'discord.js';
import { commands } from './commands';
// Define an extended version of the Client interface to include commands
interface ExtendedClient extends Client {
commands: Collection<string, any>;
}
const client: ExtendedClient = new Client({
intents: [GatewayIntentBits.Guilds],
}) as ExtendedClient;
// Register the event listener for command interactions.
client.on(Events.InteractionCreate, async (interaction: Interaction) => {
if (!interaction.isChatInputCommand()) return;
const { commandName } = interaction;
if (commands[commandName as keyof typeof commands]) {
commands[commandName as keyof typeof commands].execute(interaction);
}
});
client.once(Events.ClientReady, (readyClient) => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});
client.login(process.env.DISCORD_API_KEY);