Your personal intelligence agent. Watches the world from multiple data sources and pings you when something changes.
fix(discord): register slash commands after client is ready
exe.dev userbea8fc655dcd
diff --git a/lib/alerts/discord.mjs b/lib/alerts/discord.mjsindex ba0ce3f..673a4a5 100644--- a/lib/alerts/discord.mjs+++ b/lib/alerts/discord.mjs@@ -59,23 +59,23 @@ export class DiscordAlerter {intents: [GatewayIntentBits.Guilds],});- // Register slash commands- await this._registerCommands(REST, Routes, SlashCommandBuilder);-// Handle slash command interactionsthis._client.on('interactionCreate', async (interaction) => {if (!interaction.isChatInputCommand()) return;await this._handleCommand(interaction);});- // Connect- await this._client.login(this.botToken);-- this._client.once('ready', () => {+ // Register ready handler before login so we don't miss the event+ this._client.once('ready', async () => {this._ready = true;console.log(`[Discord] Bot online as ${this._client.user.tag}`);+ // Register slash commands after login so client.user.id is available+ await this._registerCommands(REST, Routes, SlashCommandBuilder);});+ // Connect+ await this._client.login(this.botToken);+} catch (err) {if (err.code === 'MODULE_NOT_FOUND' || err.message?.includes('Cannot find')) {console.warn('[Discord] discord.js not installed. Run: npm install discord.js');