mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 22:15:37 +00:00
fix: Also validate is user is in same voice channel as bot for commands
This commit is contained in:
1 parent
f59055807f
commit
311e141992
14 files changed
+94
-17
No files matched your search
@@ -8,7 +8,7 @@ exports.notInVoiceChannel = async (interaction) => {
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nYou need to be in a voice channel to use this command.`
|
||||
`**${embedOptions.icons.warning} Not in a voice channel**\nYou need to be in a voice channel to use this command.`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
@@ -20,3 +20,26 @@ exports.notInVoiceChannel = async (interaction) => {
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.notInSameVoiceChannel = async (interaction, queue) => {
|
||||
if (!queue.dispatcher) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (interaction.member.voice.channel.id !== queue.dispatcher.channel.id) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Not in same voice channel**\nYou need to be in the same voice channel as me to use this command.\n\n**Voice channel:** ${queue.dispatcher.channel.name}`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
|
||||
logger.debug(`User tried to use command ${interaction.commandName} but was not in the same voice channel.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
Reference in new issue
Block a user