Stop the listener rule from locking people out on stale presence
The panel said "you are not in a voice channel" while the client showed the user sitting in the call, which also disabled the only button that could summon the bot. The SDK learns voice participants from gateway events alone — no endpoint to ask — so a bot that restarted, or missed a VoiceChannelJoin, sees every channel as empty forever, and that looks exactly like nobody listening. The rule now refuses only on proven absence: when the bot can see people in voice somewhere in the server and the requester is not among them. With no presence data at all it accepts an explicitly chosen channel and logs that it is trusting the request, and the panel falls back to the channel picker instead of a dead button. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0b17b880d6
commit
224d5679a3
@@ -37,6 +37,18 @@ export class BotStoatContext implements StoatContext {
|
||||
.map((channel) => ({ id: channel.id, name: channel.name }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we have any idea who is sitting in voice right now. The SDK learns
|
||||
* participants from gateway events only, so a bot that restarted (or missed an
|
||||
* event) sees every channel as empty — which is indistinguishable from an
|
||||
* actually empty server unless we ask this question separately.
|
||||
*/
|
||||
hasVoicePresence(serverId: string): boolean {
|
||||
const server = this.client.servers.get(serverId);
|
||||
if (!server) return false;
|
||||
return server.channels.some((channel) => channel.isVoice && channel.voiceParticipants.size > 0);
|
||||
}
|
||||
|
||||
findUserVoiceChannel(serverId: string, userId: string): VoiceChannelRef | null {
|
||||
const server = this.client.servers.get(serverId);
|
||||
if (!server) return null;
|
||||
|
||||
Reference in New Issue
Block a user