feat: harden intelligence runtime and llm providers
This commit is contained in:
@@ -59,9 +59,6 @@ export class DiscordAlerter {
|
||||
intents: [GatewayIntentBits.Guilds],
|
||||
});
|
||||
|
||||
// Register slash commands
|
||||
await this._registerCommands(REST, Routes, SlashCommandBuilder);
|
||||
|
||||
// Handle slash command interactions
|
||||
this._client.on('interactionCreate', async (interaction) => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
@@ -71,9 +68,10 @@ export class DiscordAlerter {
|
||||
// Connect
|
||||
await this._client.login(this.botToken);
|
||||
|
||||
this._client.once('ready', () => {
|
||||
this._client.once('clientReady', async () => {
|
||||
this._ready = true;
|
||||
console.log(`[Discord] Bot online as ${this._client.user.tag}`);
|
||||
await this._registerCommands(REST, Routes, SlashCommandBuilder);
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
@@ -123,11 +121,13 @@ export class DiscordAlerter {
|
||||
try {
|
||||
if (this.guildId) {
|
||||
// Guild commands (instant, for development)
|
||||
await rest.put(Routes.applicationGuildCommands(this._client?.user?.id || 'me', this.guildId), { body: commands });
|
||||
const appId = this._client?.application?.id || this._client?.user?.id;
|
||||
if (!appId) throw new Error('Discord application id unavailable after login');
|
||||
await rest.put(Routes.applicationGuildCommands(appId, this.guildId), { body: commands });
|
||||
console.log(`[Discord] Registered ${commands.length} guild slash commands`);
|
||||
} else {
|
||||
// Global commands (can take up to 1h to propagate)
|
||||
const appId = this._client?.application?.id;
|
||||
const appId = this._client?.application?.id || this._client?.user?.id;
|
||||
if (appId) {
|
||||
await rest.put(Routes.applicationCommands(appId), { body: commands });
|
||||
console.log(`[Discord] Registered ${commands.length} global slash commands`);
|
||||
|
||||
Reference in New Issue
Block a user