fix: Also validate is user is in same voice channel as bot for commands

This commit is contained in:
Marius Begby committed 2023-07-27 22:59:13 +02:00
1 parent f59055807f
commit 311e141992
14 files changed
+94 -17

No files matched your search

+24 -1
View File
@@ -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;
};