Files
quarksBot/commands/settings.js
T

881 lines
36 KiB
JavaScript

const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
module.exports = {
name: "settings",
debug: false,
description: "Configure your server settings",
usage: "[opt] [action] [value]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
SlashCommand: {
options: [
{
name: "allowed_channels",
description: "Set channels you're allowed to use the bot in",
value: "allowed_channels",
type: 1,
options: [
{
name: "add_or_remove",
description: "Add/remove channel",
value: "add_or_remove",
type: 3,
required: true,
choices: [
{ name: "add", value: "add" }, { name: "remove", value: "remove" },
]
},
{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
required: true,
}
]
},
{
name: "action_channel",
description: "Set the channel to be used for /me commands",
value: "action_channel",
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove channel",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
required: true,
}
]
},
{
name: "tweet_channel",
description: "Set the channel to be used for /tweet commands",
value: "tweet_channel",
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove channel",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
required: true,
}
]
},
{
name: "adverts_channel",
description: "Set the channel for users to send commercial adverts",
value: "adverts_channel",
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove channel",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
required: true,
}
]
},
{
name: "starting_balance",
description: "Set the starting balance",
value: "starting_balance",
type: 1,
options: [{
name: "amount",
description: "The amount to set the starting balance",
value: 1000.00,
type: 10,
required: true,
}]
},
{
name: "set_income_role",
description: "Add/update a role to earn income on /work command",
value: "set_income_role",
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove role",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
name: "role",
description: "Role for this income",
value: "role",
type: 8,
required: true,
},
{
name: "amount",
description: "The amount to earn in 1 day of work",
value: 120.00,
type: 10,
required: false,
}
],
},
{
name: "commercial_role",
description: "Set/remove commercial role",
value: "commercial_role",
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove role",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
name: "role",
description: "Role to set or remove",
value: "role",
type: 8,
required: true,
},
]
},
{
name: "officer_role",
description: "Set/remove officer role",
value: "officer_role",
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove role",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
name: "role",
description: "Role to set or remove",
value: "role",
type: 8,
required: true,
},
]
},
{
name: "view",
description: "View current settings configuration",
value: "view",
type: 1,
}
],
/**
*
* @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_channels') {
const channelid = args[0].options[1].value;
if (args[0].options[0].value == '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 (error) return interaction.send({ embeds: [errorEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push:{"server.allowedChannels": channelid}}, function (err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setDescription(`**Success:** Set <#${channelid}> as an allowed channel.`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') {
const embed = new MessageEmbed()
.setDescription(`**Error Notice:** <#${channelid}> 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) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to remove this channel from allowed channels?`)
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
ephemeral: true
})
}
let action = ''
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
return;
}
} else if (args[0].name == 'action_channel') {
const channelid = args[0].options[1].value;
if (args[0].options[0].value == 'set') {
const guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
const channelSetting = guild.server.actionChannel;
const presetEmbed = new MessageEmbed()
.setColor(client.config.EmbedColor)
.setDescription(`The channel <#${channelid}> has already been set for actions.`)
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.actionChannel":channelid}},function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully set <#${channelid}> for actions.`)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') {
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to stop using this channel for actions?`)
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
ephemeral: true
})
}
let action = ''
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.actionChannel": null}},function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
return;
}
} else if (args[0].name == 'tweet_channel') {
const channelid = args[0].options[1].value;
if (args[0].options[0].value == 'set') {
const guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
const channelSetting = guild.server.tweetChannel;
const presetEmbed = new MessageEmbed()
.setColor(client.config.EmbedColor)
.setDescription(`The channel <#${channelid}> has already been set for tweets.`)
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.actionChannel":channelid}},function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully set <#${channelid}> for tweets.`)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') {
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to stop using this channel for tweets?`)
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
ephemeral: true
})
}
let action = ''
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.tweetChannel": null}},function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
return;
}
} else if (args[0].name == 'adverts_channel') {
const channelid = args[0].options[1].value;
if (args[0].options[0].value == 'set') {
const guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
const channelSetting = guild.server.tweetChannel;
const presetEmbed = new MessageEmbed()
.setColor(client.config.EmbedColor)
.setDescription(`The channel <#${channelid}> has already been set for advertisements.`)
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.advertsChannel":channelid}},function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully set <#${channelid}> for advertisements.`)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') {
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to stop using this channel for advertisements?`)
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
ephemeral: true
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.advertsChannel": null}},function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
return;
}
} else if (args[0].name == 'starting_balance') {
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {"server.startingBalance":args[0].options[0].value}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
let successEmbed = new MessageEmbed()
.setColor('GREEN')
.setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as starting balance`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'set_income_role') {
if (args[0].options[0].value == 'set') {
if (!args[0].options[2]) {
let embed = new MessageEmbed()
.setDescriptions('**Error Notice:** Please provide an income amount.')
.setColor("RED");
return interaction.send({ embeds: [embed] });
}
if (args[0].options[2].value <= 0) {
let embed = new MessageEmbed()
.setDescriptions('**Error Notice:** Amount cannot be $0 or less than $0.')
.setColor("RED");
return interaction.send({ embeds: [embed] });
}
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[1].value);
if (searchIndex == -1) {
const newIncome = {
role: args[0].options[1].value,
income: args[0].options[2].value,
}
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
} else {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID, "server.incomeRoles.role": args[0].options[1].value},
{$set: {"server.incomeRoles.$.income": args[0].options[2].value}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
}
const perform = searchIndex = -1 ? 'set' : 'updated';
const successEmbed = new MessageEmbed()
.setDescription(`Successfully ${perform} <@&${args[0].options[1].value}>'s income to $${args[0].options[2].value}`)
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') {
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[1].value);
if (searchIndex == -1) {
const errorEmbed = new MessageEmbed()
.setDescription('**Error Notice:** Role not found')
.setColor("RED");
return interaction.send({ embeds: [errorEmbed] });
} else {
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to remove this role as an income?`)
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
ephemeral: true
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$pull: {"server.incomeRoles": args[0].options[1].value}}, 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-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} <@&${args[0].options[0].value}> from income roles.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
return;
}
}
} else if (args[0].name == 'commercial_role') {
if (args[0].options[0].value == 'set') {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID},{$set:{"server.commercialRole": args[0].options[1].value}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
const successEmbed = new MessageEmbed()
.setDescription(`Successfully set <@&${args[0].options[1].value}>'s as commercial role.\nUsers with this role can now create invoices and send advertisements.`)
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') {
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to remove this role as commercial role?`)
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
ephemeral: true
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$set: {"server.commercialRole": 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-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} <@&${args[0].options[0].value}> as commercial role.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
return;
}
} else if (args[0].name == 'officer_role') {
if (args[0].options[0].value == 'set') {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID},{$set:{"server.officerRole": args[0].options[1].value}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
const successEmbed = new MessageEmbed()
.setDescription(`Successfully set <@&${args[0].options[1].value}>'s as officer role.\nUsers with this role can now fine other users.`)
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') {
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to remove this role as officer role?`)
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt] });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
ephemeral: true
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$set: {"server.officerRole": 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-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} <@&${args[0].options[0].value}> as officer role.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
return;
}
} else if (args[0].name == 'view') {
const tweetChannel = GuildDB.tweetChannel ? `\n╚➤ <#${GuildDB.tweetChannel}>` : '';
const tweetColor = GuildDB.tweetChannel ? '+ ' : '- ';
const actionChannel = GuildDB.actionChannel ? `\n╚➤ <#${GuildDB.actionChannel}>` : '';
const actionColor = GuildDB.actionChannel ? '+ ' : '- ';
const advertsChannel = GuildDB.advertsChannel ? `\n╚➤ <#${GuildDB.advertsChannel}>` : ''
const advertsColor = GuildDB.advertsChannel ? '+ ' : '- ';
const channelsInfo = GuildDB.customChannelStatus ? '\n╚➤ \`/channels\` to view' : '';
const channelColor = GuildDB.customChannelStatus ? '+ ' : '- ';
const incomeInfo = GuildDB.incomeRoleStatus ? '\n╚➤ \`/work-roles\` to view' : '';
const incomeColor = GuildDB.incomeRoleStatus ? '+ ' : '- ';
const commercialRole = GuildDB.commercialRole ? `\n╚➤ <@&${GuildDB.commercialRole}>` : '';
const commercialRoleColor = GuildDB.commercialRole ? '+ ' : '- ';
const officerRole = GuildDB.officerRole ? `\n╚➤ <@&${GuildDB.officerRole}>` : '';
const officerRoleColor = GuildDB.officerRole ? '+ ' : '- ';
const settingsEmbed = new MessageEmbed()
.setColor(client.config.EmbedColor)
.setTitle('Current Guild Configurations')
.addFields(
{ name: 'Guild ID', value: `\`\`\`arm\n${GuildDB.serverID}\`\`\``, inline: true },
{ name: 'Has Income Roles?', value: `\`\`\`diff\n${incomeColor}${GuildDB.incomeRoleStatus}\`\`\`${incomeInfo}`, inline: true },
{ name: 'Has Allowed Channels?', value: `\`\`\`diff\n${channelColor}${GuildDB.customChannelStatus}\`\`\`${channelsInfo}`, inline: true },
{ name: 'Has Tweet Channel?', value: `\`\`\`diff\n${tweetColor}${client.exists(GuildDB.tweetChannel)}\`\`\`${tweetChannel}`, inline: true },
{ name: 'Has Action Channel?', value: `\`\`\`diff\n${actionColor}${client.exists(GuildDB.actionChannel)}\`\`\`${actionChannel}`, inline: true },
{ name: 'Starting Balance', value: `\`\`\`arm\n$${GuildDB.startingBalance}\`\`\``, inline: true },
{ name: 'Has Adverts Channel?', value: `\`\`\`diff${advertsColor}${client.exists(GuildDB.advertsChannel)}\`\`\`${advertsChannel}`, inline: true },
{ name: 'Has Commercial Role?', value: `\`\`\`diff${commercialRoleColor}${client.exists(GuildDB.commercialRole)}\`\`\`${commercialRole}`, inline: true },
{ name: 'Has Officer Role?', value: `\`\`\`diff${officerRoleColor}${client.exists(GuildDB.officerRole)}\`\`\`${officerRole}`, inline: true },
);
return interaction.send({ embeds: [settingsEmbed] });
}
},
},
}