diff options
| author | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-22 15:32:57 +0100 |
|---|---|---|
| committer | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-22 15:32:57 +0100 |
| commit | 72487019b3f255cece40a8073bbad8bc9968a3b7 (patch) | |
| tree | b6590e63039cdc8b1820bd345cdfe83f28ff839b /174bg/discord-bot/main.js | |
| parent | da0509c91376f56f133872eddd2e4282d76f215e (diff) | |
| download | unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.gz unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.bz2 unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.xz unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.zip | |
major code refactor, add uex lookup
Diffstat (limited to '174bg/discord-bot/main.js')
| -rw-r--r-- | 174bg/discord-bot/main.js | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/174bg/discord-bot/main.js b/174bg/discord-bot/main.js deleted file mode 100644 index b0de475..0000000 --- a/174bg/discord-bot/main.js +++ /dev/null @@ -1,78 +0,0 @@ -import { - Client, - Events, - GatewayIntentBits, - REST, - Routes, - ChannelType, - PermissionFlagsBits, - SlashCommandBuilder, - ActionRowBuilder, - ButtonBuilder, - ButtonStyle, -} from "discord.js"; -import commands from "./commands/_index.js"; - -const client = new Client({ - intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers], -}); - -client.on(Events.ClientReady, async (readyClient) => { - console.log(`Logged in as ${readyClient.user.tag}!`); - - await registerCommands(); -}); - -client.on(Events.InteractionCreate, async (interaction) => { - // only respond to interactions in the specified guild - if (interaction.guild.id !== process.env.DISCORD_GUILD_ID) return; - - if (interaction.isChatInputCommand()) { - if ( - commands.some((command) => command.data.name === interaction.commandName) - ) { - const command = commands.find( - (command) => command.data.name === interaction.commandName, - ); - await command.execute(interaction); - } - } -}); - -client.login(process.env.DISCORD_BOT_TOKEN); - -async function registerCommands() { - try { - const rest = new REST({ version: "10" }).setToken( - process.env.DISCORD_BOT_TOKEN, - ); - - // clear global commands - await rest.put(Routes.applicationCommands(process.env.DISCORD_CLIENT_ID), { - body: [], - }); - - console.log("Cleared global application commands."); - - // register guild-scoped commands - await rest.put( - Routes.applicationGuildCommands( - process.env.DISCORD_CLIENT_ID, - process.env.DISCORD_GUILD_ID, - ), - { - body: commands.map((command) => command.data.toJSON()), - }, - ); - - const guild = await client.guilds.fetch(process.env.DISCORD_GUILD_ID); - - await guild.members.fetch(); - - console.log( - `Successfully registered application commands for guild ${process.env.DISCORD_GUILD_ID} (${guild ? guild.name : "Unknown"}).`, - ); - } catch (error) { - console.error(error); - } -}
\ No newline at end of file |
