From 819a5b2b86b30a3212f699cb58384c7bdb38dc23 Mon Sep 17 00:00:00 2001 From: 4DBug Date: Tue, 27 Oct 2026 09:18:21 -0500 Subject: [PATCH] bot: clearer hint when Activities aren't enabled; keep the Activity entry-point command on global registration Co-Authored-By: Claude Opus 5.5 --- scripts/register-commands.js | 6 +++++- src/bot/controls.js | 5 ++++- src/bot/index.js | 7 +++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/register-commands.js b/scripts/register-commands.js index 983a8dd..7059e76 100644 --- a/scripts/register-commands.js +++ b/scripts/register-commands.js @@ -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)`); } } diff --git a/src/bot/controls.js b/src/bot/controls.js index f3a49b6..9b4fcfa 100644 --- a/src/bot/controls.js +++ b/src/bot/controls.js @@ -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(() => {}); } } } diff --git a/src/bot/index.js b/src/bot/index.js index 75006e3..0d766da 100644 --- a/src/bot/index.js +++ b/src/bot/index.js @@ -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`); } }