const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js'); module.exports = { name: "remove-channel", description: "Remove channel", usage: "[channel type]", permissions: { channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], member: ["MANAGE_GUILD"], }, SlashCommand: { options: [ { name: "channel-type", description: "What the channel is used for", value: "channel-type", type: 3, required: true, choices: [ { name: "action", value: "action" }, { name: "tweet", value: "tweet" }, ], }, ], /** * * @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 channelType = args[0].value; let query; if (channelType == "action") { query = { $set: { "server.actionChannel": null } } } else query = { $set: { "server.tweetChannel": null } } let message = new MessageEmbed() .setTitle(`Are you sure you want to stop using this channel for ${channelType}s?`) .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},query,function(err, res) { if (err) { client.log(err); let embed = new MessageEmbed() .setTitle(err) .setColor("RED") return interaction.send({ embeds: [embed] }); } }); } else if (queryString=='no') { action = 'kept'; } return ButtonInteraction.update({ content: `Successfully ${action} channel.`, embeds: [], components: [] }); }); return; }, }, }