diff options
Diffstat (limited to 'index.ts')
| -rw-r--r-- | index.ts | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -1,5 +1,4 @@ import { - ChannelType, Client, CommandInteraction, Events, @@ -18,20 +17,14 @@ function requireEnv(key: string): string { return value; } -let token = requireEnv("DISCORD_TOKEN"); let clientId = requireEnv("DISCORD_CLIENT_ID"); -let guildId = requireEnv("DISCORD_GUILD_ID"); +let token = requireEnv("DISCORD_TOKEN"); +export let celebrationMessage = requireEnv("CELEBRATION_MESSAGE"); let client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] }); let rest = new REST({ version: "10" }).setToken(token); -async function registerSlashCommands() { - await rest.put(Routes.applicationGuildCommands(clientId, guildId), { - body: slashCommands.map(command => command.slashCommand.toJSON()), - }); -} - client.once(Events.ClientReady, (readyClient) => { console.log(`Logged in as ${readyClient.user.tag}`); }); @@ -92,7 +85,10 @@ client.on(Events.ThreadCreate, async (thread) => { }); try { - await registerSlashCommands(); + await rest.put(Routes.applicationCommands(clientId), { + body: slashCommands.map(command => command.slashCommand.toJSON()), + }); + await client.login(token); } catch (error) { console.error("Discord bot failed to start", error); |
