const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const bitfieldCalculator = require('discord-bitfield-calculator'); module.exports = { name: "settings", debug: false, description: "Configure your server settings", usage: "[opt], flags: (1 << 6) [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, required: true, }] }, { name: "remove", description: "Remove channel", value: "remove", type: 1, options: [{ 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: 2, options: [ { name: "set", description: "Set channel", value: "set", type: 1, options: [{ name: "channel", description: "The channel to configure", value: "channel", type: 7, 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, 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, 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, }] }, { 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: 5, 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: 5, min_value: 0.01, required: false, } ] }, { 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: "view", description: "View current settings configuration", value: "view", type: 1, } ], SlashCommand: { /** * * @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.`); } 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('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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); 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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } 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.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } 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 ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); return; } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); 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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } 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.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } 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 ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); return; } } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); 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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } 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.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } 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 ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); return; } } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); 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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } 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.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } 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 ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); return; } } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); 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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } let action = ''; if (queryString==`yes-${interaction.member.user.id}`) { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.dispatchChannel": null}},function(err, res) { if (err) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } 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 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.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); let successEmbed = new EmbedBuilder() .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 == '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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } 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('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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } let action = ''; if (queryString==`yes-${interaction.member.user.id}`) { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": roleId}}, function(err, res) { if (err) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } else if (queryString==`no-${interaction.member.user.id}`) action = 'kept'; const successEmbed = new EmbedBuilder() .setColor(client.config.Colors.Green) .setTitle(`Successfully ${action} <@&${roleId}> from income roles.`) return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); return; } } } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); const successEmbed = new EmbedBuilder() .setDescription(`Successfully set <@&${roleId}> as commercial role.\nUsers with this role can now use business commands.`) .setColor('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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } let action = ''; if (queryString==`yes-${interaction.member.user.id}`) { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.commercialRole": null}}, function(err, res) { if (err) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } else if (queryString==`no-${interaction.member.user.id}`) action = 'kept'; const successEmbed = new EmbedBuilder() .setColor(client.config.Colors.Green) .setTitle(`Successfully ${action} <@&${roleId}> as commercial role.`) return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); return; } } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); const successEmbed = new EmbedBuilder() .setDescription(`Successfully set <@&${roleId}> 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].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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } let action = ''; if (queryString==`yes-${interaction.member.user.id}`) { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.officerRole": null}}, function(err, res) { if (err) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } else if (queryString==`no-${interaction.member.user.id}`) action = 'kept'; const successEmbed = new EmbedBuilder() .setColor(client.config.Colors.Green) .setTitle(`Successfully ${action} <@&${roleId}> as officer role.`) return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); return; } } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); const successEmbed = new EmbedBuilder() .setDescription(`Successfully set <@&${roleId}> as dispatcher role.\nUsers with this role can now receive 911/311 notifications.`) .setColor('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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } let action = ''; if (queryString==`yes-${interaction.member.user.id}`) { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.dispatcherRole": null}}, function(err, res) { if (err) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } else if (queryString==`no-${interaction.member.user.id}`) action = 'kept'; const successEmbed = new EmbedBuilder() .setColor(client.config.Colors.Green) .setTitle(`Successfully ${action} <@&${roleId}> as dispatcher role.`) return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); } return; } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); const successEmbed = new EmbedBuilder() .setDescription(`Successfully set <@&${roleId}> as a bot admin role.\nUsers with this role can use restricted commands.`) .setColor('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(`yes-${interaction.member.user.id}`) .setLabel("Yes") .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId(`no-${interaction.member.user.id}`) .setLabel("No") .setStyle(ButtonStyle.Success) ) interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); client.once("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", flags: (1 << 6) }) } let action = ''; if (queryString==`yes-${interaction.member.user.id}`) { action = 'removed'; client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.botAdmin": null}}, function(err, res) { if (err) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); } else if (queryString==`no-${interaction.member.user.id}`) action = 'kept'; const successEmbed = new EmbedBuilder() .setColor(client.config.Colors.Green) .setTitle(`Successfully ${action} <@&${roleId}> as dispatcher role.`) return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); } return; } 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) { client.error(err); const embed = new EmbedBuilder() .setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`) .setColor(client.config.Colors.Red) return interaction.send({ embeds: [embed] }); } }); const title = setting ? 'Only officers can use /search' : '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 == '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] }); } }, }, }