diff options
Diffstat (limited to 'Commands/leave.js')
| -rw-r--r-- | Commands/leave.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Commands/leave.js b/Commands/leave.js index cea791a..5d01822 100644 --- a/Commands/leave.js +++ b/Commands/leave.js @@ -22,14 +22,17 @@ import { SlashCommandBuilder } from 'discord.js'; import { destroyAudio } from '../AudioBackend/Shutdown.js'; import { PermissionFlagsBits } from 'discord-api-types/v10'; +import { readFileSync } from 'node:fs'; +const { djRole, ownerID } = JSON.parse(readFileSync('./config.json', 'utf-8')); export default { data: new SlashCommandBuilder() .setName('leave') - .setDescription('Leaves the voice chat') - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - async execute(interaction) { + .setDescription('Leaves the voice chat'), + async execute(interaction, bot) { if (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); + if (!interaction.member.roles.cache.has(djRole) && interaction.user.id !== ownerID && !interaction.member.permission.has(PermissionFlagsBits.ManageGuild)) return interaction.reply({ content: 'You need a specific role to execute this command', ephemeral: true }); + console.log('Leaving voice channel...'); await destroyAudio(interaction); return await interaction.reply({ content: 'Leaving voice channel', ephemeral: true }); |
