Skip to content

Commit 671be77

Browse files
committed
fix discord voice and dms
1 parent cae6a5c commit 671be77

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

core/src/clients/discord/messages.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,14 @@ function splitMessage(content: string): string[] {
112112

113113

114114
function canSendMessage(channel) {
115-
// Get the bot member in the guild
115+
console.log("canSendMessage", channel);
116+
// if it is a DM channel, we can always send messages
117+
if (channel.type === ChannelType.DM) {
118+
return {
119+
canSend: true,
120+
reason: null
121+
};
122+
}
116123
const botMember = channel.guild?.members.cache.get(channel.client.user.id);
117124

118125
if (!botMember) {
@@ -147,18 +154,11 @@ function canSendMessage(channel) {
147154
// Check each required permission
148155
const missingPermissions = requiredPermissions.filter(perm => !permissions.has(perm));
149156

150-
// Convert BigInts to strings to avoid serialization issues
151-
const missingPermNames = missingPermissions.map(perm => {
152-
// Find the flag name by its value
153-
return Object.entries(PermissionsBitField.Flags)
154-
.find(([_, val]) => val === perm)?.[0] || String(perm);
155-
});
156-
157157
return {
158158
canSend: missingPermissions.length === 0,
159-
missingPermissions: missingPermNames, // Now using string names instead of BigInts
159+
missingPermissions: missingPermissions,
160160
reason: missingPermissions.length > 0
161-
? `Missing permissions: ${missingPermNames.join(', ')}`
161+
? `Missing permissions: ${missingPermissions.map(p => String(p)).join(', ')}`
162162
: null
163163
};
164164
}

core/src/clients/discord/voice.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,4 +680,4 @@ export class VoiceManager extends EventEmitter {
680680
await interaction.reply("Failed to leave the voice channel.");
681681
}
682682
}
683-
}
683+
}

0 commit comments

Comments
 (0)