Files
quarksBot/commands/settings.js
T

1187 lines
45 KiB
JavaScript

const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
const bitfieldCalculator = require('discord-bitfield-calculator');
module.exports = {
name: "settings",
debug: false,
global: false,
description: "Configure your server settings",
usage: "[opt] [action] [value]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
options: [
{
name: "allowed_channels",
description: "Set channels you're allowed to use the bot in",
value: "allowed_channels",
type: 2,
options: [
{
name: "add",
description: "Add channel",
value: "add",
type: 1,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
channel_types: [0], // Restrict to text channel
required: true,
}]
},
{
name: "remove",
description: "Remove channel",
value: "remove",
type: 1,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
channel_types: [0], // Restrict to text channel
required: true,
}]
},
]
},
{
name: "action_channel",
description: "Set the channel to be used for /me commands",
value: "action_channel",
type: 2,
options: [
{
name: "set",
description: "Set channel",
value: "set",
type: 1,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
channel_types: [0], // Restrict to text channel
required: true,
}]
},
{
name: "remove",
description: "Remove channel",
value: "remove",
type: 1,
},
]
},
{
name: "tweet_channel",
description: "Set the channel to be used for /tweet commands",
value: "tweet_channel",
type: 2,
options: [
{
name: "set",
description: "Set channel",
value: "set",
type: 1,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
channel_types: [0], // Restrict to text channel
required: true,
}]
},
{
name: "remove",
description: "Remove channel",
value: "remove",
type: 1,
},
]
},
{
name: "adverts_channel",
description: "Set the channel for users to send commercial adverts",
value: "adverts_channel",
type: 2,
options: [
{
name: "set",
description: "Set channel",
value: "set",
type: 1,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
channel_types: [0], // Restrict to text channel
required: true,
}]
},
{
name: "remove",
description: "Remove channel",
value: "remove",
type: 1,
},
]
},
{
name: "dispatcher_channel",
description: "Set the channel for dispatchers to recieve notifications.",
value: "adverts_channel",
type: 2,
options: [
{
name: "set",
description: "Set channel",
value: "set",
type: 1,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
channel_types: [0], // Restrict to text channel,
required: true,
}]
},
{
name: "remove",
description: "Remove channel",
value: "remove",
type: 1,
},
]
},
{
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: "amount",
type: 10,
min_value: 0.01,
required: true,
}]
},
{
name: "income_role",
description: "Add/update a role to earn income on /work command",
value: "set_income_role",
type: 2,
options: [
{
name: "set",
description: "Set role",
value: "set",
type: 1,
options: [
{
name: "role",
description: "Role to set",
value: "role",
type: 8,
required: true,
},
{
name: "amount",
description: "The amount to earn in 1 day of work",
value: 120.00,
type: 10,
min_value: 0.01,
required: true,
}
]
},
{
name: "remove",
description: "Remove role",
value: "remove",
type: 1,
options: [{
name: "role",
description: "Role to remove",
value: "role",
type: 8,
required: true,
}]
},
],
},
{
name: "bot_admin_role",
description: "Set/remove bot admin role",
value: "bot_admin_role",
type: 2,
options: [
{
name: "set",
description: "Set role",
value: "role",
type: 1,
options: [{
name: "role",
description: "Role to set",
value: "role",
type: 8,
required: true,
}]
},
{
name: "remove",
description: "Remove role",
value: "remove",
type: 1,
},
]
},
{
name: "commercial_role",
description: "Set/remove commercial role",
value: "commercial_role",
type: 2,
options: [
{
name: "set",
description: "Set role",
value: "set",
type: 1,
options: [{
name: "role",
description: "Role to set",
value: "role",
type: 8,
required: true,
}]
},
{
name: "remove",
description: "Remove role",
value: "remove",
type: 1,
},
]
},
{
name: "officer_role",
description: "Set/remove officer role",
value: "officer_role",
type: 2,
options: [
{
name: "set",
description: "Set role",
value: "set",
type: 1,
options: [{
name: "role",
description: "Role to set",
value: "role",
type: 8,
required: true,
}]
},
{
name: "remove",
description: "Remove role",
value: "remove",
type: 1,
},
]
},
{
name: "dispatcher_role",
description: "Set/remove dispatcher role",
value: "officer_role",
type: 2,
options: [
{
name: "set",
description: "Set role",
value: "set",
type: 1,
options: [{
name: "role",
description: "Role to set",
value: "role",
type: 8,
required: true,
}],
},
{
name: "remove",
description: "Remove role",
value: "remove",
type: 1,
},
]
},
{
name: "only_officers_search",
description: "Determine if only officers can use /search",
value: "only_officers_search",
type: 1,
options: [{
name: "true_or_false",
description: "Enable or Disable setting",
value: false,
type: 5,
required: true,
}]
},
{
name: "casino_multiplier",
description: "Change the multuplier for the amount to win back in casino games",
value: "casino_win_multiplier",
type: 1,
options: [{
name: "mutliplier",
description: "Set the multiplier for winnings",
value: 2,
type: 10,
min_value: 1,
}]
},
{
name: "reset",
description: "Restore all settings to default configurations",
value: "reset",
type: 1,
},
{
name: "view",
description: "View current settings configuration",
value: "view",
type: 1,
}
],
SlashCommand: {
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
const permissions = bitfieldCalculator.permissions(interaction.member.permissions);
let canUseCommand = false;
if (permissions.includes("MANAGE_GUILD")) canUseCommand = true;
if (client.exists(GuildDB.botAdmin) && interaction.member.roles.includes(GuildDB.botAdmin)) canUseCommand = true;
if (!canUseCommand) return interaction.send({ content: 'You don\'t have the permissions to use this command.' });
if (args[0].name == 'allowed_channels') {
const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].name == 'add') {
const channel = client.channels.cache.get(channelid);
const errorEmbed = new EmbedBuilder().setColor(client.config.Colors.Red)
let error = false;
if (!channel) {error=true;errorEmbed.setDescription(`**Error Notice:** Cannot find that channel.`);}
if (channel.type=="voice") {error=true;errorEmbed.setDescription(`**Error Notice:** Cannot add voice 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) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> as an allowed channel.`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name=='remove') {
const embed = new EmbedBuilder()
.setDescription(`**Error Notice:** <#${channelid}> is not in allowed channels.`)
.setColor(client.config.Colors.Red)
if (!GuildDB.allowedChannels.includes(channelid)) return interaction.send({ embeds: [embed] });
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to remove this channel from allowed channels?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveAllowedChannels-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveAllowedChannels-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
} else console.log('exception?');
} else if (args[0].name == 'action_channel') {
if (args[0].options[0].name=='set') {
const channelid = args[0].options[0].options[0].value;
const channelSetting = GuildDB.actionChannel;
const presetEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.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) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> as the action channel.`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to stop using this channel for actions?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveActionChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveActionChannel-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
}
} else if (args[0].name == 'tweet_channel') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value;
const channelSetting = GuildDB.tweetChannel;
const presetEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.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.tweetChannel":channelid}},function(err, res) {
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> as the tweet channel.`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to stop using this channel for tweets?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveTweetChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveTweetChannel-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
}
} else if (args[0].name == 'adverts_channel') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value;
const channelSetting = GuildDB.advertsChannel;
const presetEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.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) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> for advertisements.`)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to stop using this channel for advertisements?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveAdvertsChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveAdvertsChannel-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
}
} else if (args[0].name == 'dispatcher_channel') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value;
const channelSetting = GuildDB.advertsChannel;
const presetEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription(`The channel <#${channelid}> has already been set for dispatchers.`)
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.dispatchChannel":channelid}},function(err, res) {
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set <#${channelid}> for dispatchers.`)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to stop using this channel for advertisements?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveDispatcherChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveDispatcherChannel-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
}
} else if (args[0].name == 'starting_balance') {
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.startingBalance":args[0].options[0].value}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
let successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as starting balance`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'income_role') {
if (args[0].options[0].name== 'set') {
const roleId = args[0].options[0].options[0].value
if (args[0].options[0].options[1].value <= 0) {
let embed = new EmbedBuilder()
.setDescription('**Error Notice:** Amount cannot be $0 or less than $0.')
.setColor(client.config.Colors.Red);
return interaction.send({ embeds: [embed] });
}
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==roleId);
if (searchIndex == -1) {
const newIncome = {
role: roleId,
income: args[0].options[0].options[1].value,
}
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else {
client.dbo.collection("guilds").updateOne({
"server.serverID": GuildDB.serverID,
"server.incomeRoles.role": roleId
},
{
$set: {
"server.incomeRoles.$.income": args[0].options[0].options[1].value
}
}, function(err, res) {
if (err) return client.sendInternalError(err);
});
}
const perform = searchIndex == -1 ? 'set' : 'updated';
const successEmbed = new EmbedBuilder()
.setDescription(`Successfully ${perform} <@&${roleId}>'s income to $${args[0].options[0].options[1].value}`)
.setColor(client.config.Colors.Green);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==roleId);
if (searchIndex == -1) {
const errorEmbed = new EmbedBuilder()
.setDescription('**Error Notice:** Role not found')
.setColor(client.config.Colors.Red);
return interaction.send({ embeds: [errorEmbed] });
} else {
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to remove this role as an income?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveIncomeRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveIncomeRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
}
}
} else if (args[0].name == 'commercial_role') {
if (args[0].options[0].name== 'set') {
const roleId = args[0].options[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.commercialRole": roleId}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setDescription(`Successfully set <@&${roleId}> as commercial role.\nUsers with this role can now use business commands.`)
.setColor(client.config.Colors.Green);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to remove this role as commercial role?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveCommercialRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveCommercialRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
}
} else if (args[0].name == 'officer_role') {
const roleId = args[0].options[0].options[0].value;
if (args[0].options[0].name== 'set') {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.officerRole": roleId}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setDescription(`Successfully set <@&${roleId}> as officer role.\nUsers with this role can now fine other users.`)
.setColor(client.config.Colors.Green);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to remove this role as officer role?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveOfficerRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveOfficerRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
}
} else if (args[0].name == 'dispatcher_role') {
if (args[0].options[0].name == 'set') {
const roleId = args[0].options[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.dispatcherRole": roleId}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setDescription(`Successfully set <@&${roleId}> as dispatcher role.\nUsers with this role can now receive 911/311 notifications.`)
.setColor(client.config.Colors.Green);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to remove this role as dispatcher role?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveDispatcherRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveDispatcherRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
}
} else if (args[0].name == 'bot_admin_role') {
if (args[0].options[0].name == 'set') {
const roleId = args[0].options[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.botAdmin": roleId}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setDescription(`Successfully set <@&${roleId}> as a bot admin role.\nUsers with this role can use restricted commands.`)
.setColor(client.config.Colors.Green);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to remove this role as a bot admin?`)
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`RemoveBotAdminRole-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`RemoveBotAdminRole-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
}
} else if (args[0].name == 'only_officers_search') {
const setting = args[0].options[0];
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.onlyOfficersSearch": setting}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
const title = setting ? 'True: Only officers can use /search' : 'False: Any user can use /search';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(title)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'casino_multiplier') {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.casinoMultiplier": args[0].options[0]}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setDescription(`**Success:** Set casino winnings multiplier to **${args[0].options[0]}x**`);
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'reset') {
const prompt = new EmbedBuilder()
.setTitle(`Woah!? Hold on.`)
.setDescruotion('Are you sure you wish to remove all your configurations for this guild?')
.setColor(client.config.Colors.Default)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`ResetSettings-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`ResetSettings-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Success)
)
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
} 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 oos = GuildDB.onlyOfficersSearch; // only officers search (oos)
const oosColor = GuildDB.onlyOfficersSearch ? '+ ' : '- ';
const dispatchRole = GuildDB.dispatcherRole ? `\n╚➤ <@&${GuildDB.dispatcherRole}>` : '';
const dispatchRoleColor = GuildDB.dispatcherRole ? `+ ` : '- ';
const dispatchChannel = GuildDB.dispatchChannel ? `\n╚➤ <#${GuildDB.dispatcherRole}>` : '';
const dispatchChannelColor = GuildDB.dispatchChannel ? `+ ` : '- ';
const botAdminRole = GuildDB.botAdmin ? `\n╚➤ <#${GuildDB.botAdmin}>` : '';
const botAdminRoleColor = GuildDB.botAdmin ? `+ ` : '- ';
const settingsEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.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\n${advertsColor}${client.exists(GuildDB.advertsChannel)}\`\`\`${advertsChannel}`, inline: true },
{ name: 'Has Commercial Role?', value: `\`\`\`diff\n${commercialRoleColor}${client.exists(GuildDB.commercialRole)}\`\`\`${commercialRole}`, inline: true },
{ name: 'Has Officer Role?', value: `\`\`\`diff\n${officerRoleColor}${client.exists(GuildDB.officerRole)}\`\`\`${officerRole}`, inline: true },
{ name: 'Only Officers Search?', value: `\`\`\`diff\n${oosColor}${oos}\`\`\``, inline: true },
{ name: 'Has Disptach Role?', value: `\`\`\`diff\n${dispatchRoleColor}${client.exists(GuildDB.dispatcherRole)}\`\`\`${dispatchRole}`, inline: true },
{ name: 'Has Dispatch Channel?', value: `\`\`\`diff\n${dispatchChannelColor}${client.exists(GuildDB.dispatchChannel)}\`\`\`${dispatchChannel}`, inline: true },
{ name: 'Has bot admin role?', value: `\`\`\`diff\n${botAdminRoleColor}${client.exists(GuildDB.botAdmin)}\`\`\`${botAdminRole}`, inline: true },
);
return interaction.send({ embeds: [settingsEmbed] });
}
},
},
Interactions: {
RemoveAllowedChannels: {
run: async (client, interaction, GuildDB) => {
if (!queryString.endsWith(interaction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interactino.update({ embeds: [successEmbed], components: [] });
}
},
RemoveActionChannel: {
run: async (client, interaction, GuildDB) => {
if (!queryString.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.actionChannel": null}},function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveTweetChannel: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.tweetChannel": null}},function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveAdvertsChannel: {
run: async (client, interaction, GuildDB) => {
if (!interaction.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.advertsChannel": null}},function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveDispatcherChannel: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.dispatchChannel": null}},function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveIncomeRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": roleId}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> from income roles.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveCommercialRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.commercialRole": null}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as commercial role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveOfficerRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='no') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.officerRole": null}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as officer role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveDispatcherRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.dispatcherRole": null}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as dispatcher role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
RemoveBotAdminRole: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.botAdmin": null}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as the bot admin role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
},
ResetSettings: {
run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'reset';
const defaultGuildConfig = {
serverID: GuildDB.serverID,
allowedChannels: [],
actionChannel: null,
tweetChannel: null,
advertsChannel: null,
dispatchChannel: null,
startingBalance: 1000.00,
incomeRoles: [],
botAdmin: null,
commercialRole: null,
officerRole: null,
dispatcherRole: null,
onlyOfficersSearch: false,
}
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server": defaultGuildConfig}}, function(err, res) {
if (err) return client.sendInternalError(err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} guild configurations.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
}
}
}