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: "action", description: "remove action channel", value: "action", type: 1, required: false, }, { name: "tweet", description: "remove tweet channel", value: "tweet", type: 1, required: false, }, { name: "allowed", description: "remove an allowed channel", value: "allowed", type: 1, required: false, options: [ { name: "channel", description: "Channel to send add to allowed channels", value: "channel", type: 7, required: true, }, ] }, ], /** * * @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.`); } if (args[0].name == 'allowed') { let channelid = args[0].options[0].value; let embed = new MessageEmbed() .setTitle('Channel is not in allowed Channels') .setColor("RED") if (!GuildDB.allowedChannels.includes(channelid)) return interaction.send({ embeds: [embed] }); client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) { }); let message = new MessageEmbed() .setTitle(`Are you sure you want to remove this channel from allowed channels?`) .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":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, 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'; } let successEmbed = new MessageEmbed() .setColor("GREEN") .setTitle(`Successfully ${action} channel.`) return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); return; } let channelType = args[0].name; 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'; } let successEmbed = new MessageEmbed() .setColor("GREEN") .setTitle(`Successfully ${action} channel.`) return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); return; }, }, }