Skip to content

Commit

Permalink
fix voice perms
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Nov 20, 2024
1 parent b31f600 commit e512c61
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 e512c61

Please sign in to comment.