From db0b737210c1dd057a46b08ebfb050bcb80b35cd Mon Sep 17 00:00:00 2001 From: Mathias Magnusson Date: Tue, 20 Jan 2026 10:43:30 +0100 Subject: parameterize solve message; clean up index.ts --- commands.ts | 4 +++- index.ts | 16 ++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/commands.ts b/commands.ts index 2f5598f..7005165 100644 --- a/commands.ts +++ b/commands.ts @@ -15,6 +15,8 @@ import { type GuildBasedChannel, } from "discord.js"; +import { celebrationMessage } from "./index.ts"; + export let slashCommands = [ { slashCommand: new SlashCommandBuilder() @@ -309,7 +311,7 @@ async function solveThread(interaction: ChatInputCommandInteraction) { await channel.setAppliedTags(channel.appliedTags.filter(tag => tag !== unsolvedTag.id)); } - await interaction.reply("<:club_mate:889629353934213210> 🎉"); + await interaction.reply(celebrationMessage); } async function handleJoinCtfButton(interaction: ButtonInteraction, forumId: string) { diff --git a/index.ts b/index.ts index acc61fa..98ddb0c 100644 --- a/index.ts +++ b/index.ts @@ -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); -- cgit v1.2.3