bot: clearer hint when Activities aren't enabled; keep the Activity entry-point command on global registration
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
f3c88cff19
commit
819a5b2b86
3 files changed
+14
-4
No files matched your search
@@ -20,7 +20,11 @@ async function main() {
|
||||
console.log(`guild ${g}: ${res.length} commands`);
|
||||
}
|
||||
} else {
|
||||
const res = await rest.put(Routes.applicationCommands(cfg.applicationId), { body });
|
||||
// keep Discord's Activity entry-point command (type 4): a bulk overwrite without it fails
|
||||
const existing = await rest.get(Routes.applicationCommands(cfg.applicationId));
|
||||
const res = await rest.put(Routes.applicationCommands(cfg.applicationId), {
|
||||
body: [...body, ...existing.filter((c) => c.type === 4)],
|
||||
});
|
||||
console.log(`global: ${res.length} commands (may take up to an hour to appear)`);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
-1
@@ -63,7 +63,10 @@ async function launch(interaction) {
|
||||
} catch (e) {
|
||||
console.warn(`[bot] launch activity: ${e.message}`);
|
||||
if (!interaction.replied && !interaction.deferred) {
|
||||
await interaction.reply(ephemeral(`Couldn't start the activity (${e.message}). Open it from the voice channel's Activities menu.`)).catch(() => {});
|
||||
const hint = /EMBEDDED flag/i.test(e.message)
|
||||
? 'Activities are not enabled for this app yet: Developer Portal → your app → Activities → Settings → Enable Activities.'
|
||||
: `Couldn't start the activity (${e.message}). Open it from the voice channel's Activities menu.`;
|
||||
await interaction.reply(ephemeral(hint)).catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -1,6 +1,6 @@
|
||||
// Discord bot: gateway client, slash commands, control-message components, voice presence.
|
||||
|
||||
const { Client, GatewayIntentBits, Events, MessageFlags } = require('discord.js');
|
||||
const { Client, GatewayIntentBits, Events, MessageFlags, Routes } = require('discord.js');
|
||||
const { commandDefs, handleCommand } = require('./commands');
|
||||
const { handleComponent } = require('./controls');
|
||||
const { handleAutocomplete } = require('./autocomplete');
|
||||
@@ -14,7 +14,10 @@ async function registerCommands(client, cfg) {
|
||||
}
|
||||
console.log(`[bot] registered ${commandDefs.length} commands in ${cfg.guildIds.length} guild(s)`);
|
||||
} else {
|
||||
await app.commands.set(commandDefs);
|
||||
// keep Discord's Activity entry-point command (type 4): a bulk overwrite without it fails
|
||||
const route = Routes.applicationCommands(app.id);
|
||||
const existing = await client.rest.get(route).catch(() => []);
|
||||
await client.rest.put(route, { body: [...commandDefs, ...existing.filter((c) => c.type === 4)] });
|
||||
console.log(`[bot] registered ${commandDefs.length} global commands`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user