From 2e04d9efb4403949baf56b6a72f776742c8611ce Mon Sep 17 00:00:00 2001 From: 4DBug Date: Tue, 27 Oct 2026 09:14:38 -0500 Subject: [PATCH] bot: explain when the bot user hasn't joined the server, with an invite link --- src/bot/commands.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bot/commands.js b/src/bot/commands.js index 40b3e54..c9b7530 100644 --- a/src/bot/commands.js +++ b/src/bot/commands.js @@ -70,7 +70,17 @@ async function adoptReply(ctx, room, interaction, deferred) { ctx.updater.schedule(room, false); // catch anything that changed while we were posting } +// commands can be installed without the bot user joining the server; then Discord never +// sends it voice states and nothing here can work +function notInGuild(interaction, ctx) { + if (interaction.guild) return false; + const invite = `https://discord.com/oauth2/authorize?client_id=${ctx.cfg.applicationId}&scope=bot%20applications.commands&permissions=84992`; + interaction.reply(ephemeral(`The bot user isn't in this server yet, so it can't see voice channels. Add it with this link: ${invite}`)).catch(() => {}); + return true; +} + async function watch(interaction, ctx) { + if (notInGuild(interaction, ctx)) return; const vc = await userVoiceChannel(interaction); if (!vc) return interaction.reply(ephemeral('Join a voice channel first, then use `/watch` there.')); const raw = interaction.options.getString('query', true); @@ -99,6 +109,7 @@ async function roomFor(interaction, ctx) { } async function np(interaction, ctx) { + if (notInGuild(interaction, ctx)) return; const room = await roomFor(interaction, ctx); if (!room || !room.state.media) return interaction.reply(ephemeral('Nothing is playing. Use `/watch` in a voice channel.')); await interaction.deferReply(); @@ -106,6 +117,7 @@ async function np(interaction, ctx) { } async function stop(interaction, ctx) { + if (notInGuild(interaction, ctx)) return; const room = await roomFor(interaction, ctx); if (!room) return interaction.reply(ephemeral('Nothing is playing.')); if (!ctx.isInVoice(room.id, interaction.user.id)) return interaction.reply(ephemeral(`Join <#${room.id}> to control playback.`));