summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.ts4
-rw-r--r--index.ts16
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);