From 8d010d336bb1b67cf1f6d1635569bd907f583787 Mon Sep 17 00:00:00 2001 From: SowinskiBraeden Date: Wed, 7 Dec 2022 17:49:59 -0800 Subject: [PATCH] 4.1.8 prevent command usage in non allowed channels --- commands/armbands.js | 2 ++ commands/claim.js | 5 +++-- commands/factions.js | 2 ++ commands/help.js | 12 ++++++------ package.json | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/commands/armbands.js b/commands/armbands.js index 3c1abb0..5e46939 100644 --- a/commands/armbands.js +++ b/commands/armbands.js @@ -21,6 +21,8 @@ module.exports = { * @param {*} param3 */ run: async (client, interaction, args, { GuildDB }) => { + if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) + return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) }); let available = new SelectMenuBuilder() .setCustomId(`View-1-${interaction.member.user.id}`) diff --git a/commands/claim.js b/commands/claim.js index b99e1e1..a04bd85 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -27,12 +27,13 @@ module.exports = { * @param {*} param3 */ run: async (client, interaction, args, { GuildDB }) => { + if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) + return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) }); + // Handle invalid roles let des; - if (GuildDB.excludedRoles.includes(args[0].value)) des = '**Notice:**\n> This role has been configured to be excluded to claim an armband.'; if (!interaction.member.roles.includes(args[0].value)) des = '**Notice:**\n> You cannot claim an armband for a role you don\'t have.'; - if (des) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(des)], flags: (1 << 6) }); // If this faction has an existing record in the db diff --git a/commands/factions.js b/commands/factions.js index ca0c705..fd95e0a 100644 --- a/commands/factions.js +++ b/commands/factions.js @@ -20,6 +20,8 @@ module.exports = { * @param {*} param3 */ run: async (client, interaction, args, { GuildDB }) => { + if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) + return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) }); let factions = new EmbedBuilder() .setColor(client.config.Colors.Default) diff --git a/commands/help.js b/commands/help.js index 06c942e..aef8f4a 100644 --- a/commands/help.js +++ b/commands/help.js @@ -53,13 +53,13 @@ module.exports = { */ run: async (client, interaction, args) => { - if (args[0].name == 'version') { - const versionEmbed = new EmbedBuilder() - .setTitle(`Current DayzArmbands Version`) - .setDescription(client.config.Version); + if (args[0].name == 'version') { + const versionEmbed = new EmbedBuilder() + .setTitle(`Current DayzArmbands Version`) + .setDescription(client.config.Version); - return interaction.send({ embeds: [versionEmbed] }); - } else if (args[0].name == 'commands') { + return interaction.send({ embeds: [versionEmbed] }); + } else if (args[0].name == 'commands') { let Commands = client.commands.filter((cmd) => { return !cmd.debug }).map((cmd) => diff --git a/package.json b/package.json index b66773b..3e22b4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayz-armbands", - "version": "4.1.7", + "version": "4.1.8", "description": "A Discord Bot to handle DayZ server flags and armbands for in game factions.", "main": "index.js", "nodemonConfig": {