Skip to content

Commit

Permalink
Merge pull request #447 from ai16z/fix/voice-perms
Browse files Browse the repository at this point in the history
fix: voice perms
  • Loading branch information
ponderingdemocritus authored Nov 20, 2024
2 parents 5d86a5b + e512c61 commit 1bd4de9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/client-discord/src/voice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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) => {
Expand Down

0 comments on commit 1bd4de9

Please sign in to comment.