Files
quarksBot/commands/removeActionChannel.js
T

59 lines
1.9 KiB
JavaScript

const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
module.exports = {
name: "removeactionchannel",
description: "Remove action channel",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
}
let message = new MessageEmbed()
.setTitle('Are you sure you want to stop using this channel for actions?')
.setColor(client.config.EmbedColor)
let row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [message], components: [row] });
client.once("interactionCreate", ButtonInteraction => {
let queryString = ButtonInteraction.customId;
let action = ''
if (queryString=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.actionChannel":null}},function(err, res) {
if (err) throw err;
});
} else if (queryString=='no') {
action = 'kept';
}
return ButtonInteraction.update({ content: `Successfully ${action} channel.`, embeds: [], components: [] });
});
return;
},
},
}