simplify commands

This commit is contained in:
SowinskiBraeden committed 2022-07-05 18:29:47 -07:00
1 parent c42783a778
commit 1d0ea55e88
5 files changed
+109 -158

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
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 = "server.actionChannel" ? channelType == "action" : "server.tweetChannel";
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},{$set:{query:null}},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;
},
},
}