From e512c61f3623b248843099163a8f24ca868e0918 Mon Sep 17 00:00:00 2001 From: ponderingdemocritus Date: Wed, 20 Nov 2024 21:23:09 +1100 Subject: [PATCH] fix voice perms --- packages/client-discord/src/voice.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/client-discord/src/voice.ts b/packages/client-discord/src/voice.ts index d18acdd673..61d8224ae0 100644 --- a/packages/client-discord/src/voice.ts +++ b/packages/client-discord/src/voice.ts @@ -8,7 +8,13 @@ import { ModelClass, ServiceType, State, - UUID, composeContext, elizaLogger, embeddingZeroVector, generateMessageResponse, messageCompletionFooter, stringToUuid + UUID, + composeContext, + elizaLogger, + embeddingZeroVector, + generateMessageResponse, + messageCompletionFooter, + stringToUuid, } from "@ai16z/eliza"; import { AudioReceiveStream, @@ -232,11 +238,12 @@ export class VoiceManager extends EventEmitter { selfMute: false, }); - // Explicitly undeafen and unmute the bot const me = channel.guild.members.me; - if (me?.voice) { + if (me?.voice && me.permissions.has("DeafenMembers")) { await me.voice.setDeaf(false); await me.voice.setMute(false); + } else { + elizaLogger.log("Bot lacks permission to modify voice state"); } for (const [, member] of channel.members) { @@ -245,8 +252,8 @@ export class VoiceManager extends EventEmitter { } } - connection.on('error', (error) => { - console.error('Voice connection error:', error); + connection.on("error", (error) => { + console.error("Voice connection error:", error); }); connection.receiver.speaking.on("start", (userId: string) => {