fix banking db calls, add permission check for settings command
This commit is contained in:
8 files changed
+79
-51
No files matched your search
+23
-7
@@ -1,4 +1,5 @@
|
||||
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
|
||||
const bitfieldCalculator = require('discord-bitfield-calculator');
|
||||
|
||||
module.exports = {
|
||||
name: "settings",
|
||||
@@ -322,18 +323,33 @@ module.exports = {
|
||||
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
||||
}
|
||||
|
||||
const permissions = bitfieldCalculator.permissions(interaction.member.permissions);
|
||||
|
||||
let canUseCommand = false;
|
||||
|
||||
if (permissions.includes("MANAGE_GUILD")) {
|
||||
canUseCommand = true;
|
||||
}
|
||||
|
||||
if (client.exists(GuildDB.botAdmin) && interaction.member.roles.includes(GuildDB.botAdmin)) {
|
||||
canUseCommand = true;
|
||||
}
|
||||
|
||||
if (!canUseCommand) {
|
||||
return interaction.send('You don\'t have the permissions to use this command.');
|
||||
}
|
||||
|
||||
if (args[0].name == 'allowed_channels') {
|
||||
const channelid = args[0].options[0].options[0].value;
|
||||
|
||||
if (args[0].options[0].value == 'add') {
|
||||
if (args[0].options[0].name == 'add') {
|
||||
const channel = client.channels.cache.get(channelid);
|
||||
|
||||
const errorEmbed = new MessageEmbed().setColor("RED")
|
||||
let error = false;
|
||||
|
||||
if (!channel) errorEmbed.setDescription(`**Error Notice:** Cannot find that channel.`);
|
||||
if (channel.type=="voice") errorEmbed.setDescriptions(`**Error Notice:** Cannot add voice channel to allowed channels.`);
|
||||
if (channel.deleted) errorEmbed.setDescription(`**Error Notice":** Cannot add deleted channel to allowed channels.`);
|
||||
if (!channel) {error=true;errorEmbed.setDescription(`**Error Notice:** Cannot find that channel.`);}
|
||||
if (channel.type=="voice") {error=true;errorEmbed.setDescriptions(`**Error Notice:** Cannot add voice channel to allowed channels.`);}
|
||||
if (error) return interaction.send({ embeds: [errorEmbed] });
|
||||
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push:{"server.allowedChannels": channelid}}, function (err, res) {
|
||||
@@ -352,7 +368,7 @@ module.exports = {
|
||||
.setDescription(`**Success:** Set <#${channelid}> as an allowed channel.`);
|
||||
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
} else if (args[0].options[0].name== 'remove') {
|
||||
} else if (args[0].options[0].name=='remove') {
|
||||
|
||||
const embed = new MessageEmbed()
|
||||
.setDescription(`**Error Notice:** <#${channelid}> is not in allowed channels.`)
|
||||
@@ -409,10 +425,10 @@ module.exports = {
|
||||
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
|
||||
});
|
||||
return;
|
||||
}
|
||||
} else console.log('exception?');
|
||||
|
||||
} else if (args[0].name == 'action_channel') {
|
||||
if (args[0].options[0].name== 'set') {
|
||||
if (args[0].options[0].name=='set') {
|
||||
const channelid = args[0].options[0].options[0].value;
|
||||
const channelSetting = GuildDB.actionChannel;
|
||||
|
||||
|
||||
Reference in new issue
Block a user