diff --git a/commands/help.js b/commands/help.js index 963504e..cb0dd42 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,4 +1,5 @@ -const { EmbedBuilder } = require("discord.js"); +const { EmbedBuilder, ActionRowBuilder, SelectMenuBuilder } = require("discord.js"); +const settings = require('../config/settingsHelp'); module.exports = { name: "help", @@ -109,58 +110,40 @@ module.exports = { return interaction.send(embed); } } else if (args[0].name == 'settings') { - const settingsHelp = new EmbedBuilder() - .setColor(client.config.Colors.Default) - .setTitle('Using settings command to configure your guild') - .setDescription(`Some features of QuarksBot require, or recommend settings. - - **__1. Action Channel:__** - Optionally you can have a dedicated channel for the \`/me\` command, keeping your channels clean. - Use \`/settings action_channel set [channel]\` to configure this setting. - - or... + let settingsMenu = new SelectMenuBuilder() + .setCustomId(`settingSelect-${interaction.member.user.id}`) + .setPlaceholder('Select Setting you require help with') - use \`/settings action_channel remove [channel]\` to remove your dedicated action channel. + settings.settings.map((setting) => { + settingsMenu.addOptions({ + label: setting.name, + description: 'Get help with this setting', + value: setting.name, + }) + }) + + const SelectSettings = new ActionRowBuilder().addComponents(settingsMenu); - **__2. Tweet Channel:__** - Optionally you can have a dedicated channel for the \`/tweet\` command, keeping your channels clean. - Use \`/settings tweet_channel set [channel]\` to configure this setting. - - or ... - - use \`/settings tweet_channel remove [channel]\` to remove your dedicated tweet channel. - - - **__3. Allowed Channels:__** - If you want to limit what channels people can use QuarksBot, - use \`/settings allowed_channels add [channel]\` to add a channel to a list of allowed channels. - - or... + interaction.send({ components: [SelectSettings], flags: (1 << 6) }); - use \`/settings allowed_channels remove [channel]\` to remove a channel from the list of allowed channels. + client.on("interactionCreate", async MenuInteraction => { + if(!MenuInteraction.isSelectMenu()) return; + if (!MenuInteraction.customId.endsWith(MenuInteraction.member.user.id)) { + return MenuInteraction.reply({ + content: "This button is not for you", + flags: (1 << 6) + }) + } - **__4. Starting Balance:__** - When a user joins your server, they get a starting balance. This can be configured, - use \`/settings starting_balance [amount]\` to set the starting balance. - - **__5. Income Roles:__** - The \`/work\` command required a user to have a role that has a defined income. - Use \`/settings set_income_role [role] [amount]\` to add a role to the list of roles to earn income. - - or... - - use \`/settings remove_income_role [role]\` to remove a role from the list of roles to earn income. - - **Note:** - - Users may only use \`/work\` command once every 24 hours. - - If a user has more than one role that can earn income, the bot will pay them for the role with the highest income. - - The amount you enter for a role to earn is the amount they will be paid when using the \`/work\` command. Be sure that the amount you choose is a daily income, not hourly, etc. - - **__6. Viewing Settings:__** - If you are unsure of your current configured settings, use \`/settings view\` to get a detailed view of your configurations.`); - - return interaction.send({ embeds: [settingsHelp] }); + const setting = settings.settings.find(setting => setting.name === MenuInteraction.values[0]); + const settingEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setTitle(setting.name) + .setDescription(setting.description) + return MenuInteraction.update({ embeds: [settingEmbed], components: [] }); + }); + } else if (args[0].name == 'support') { const supportEmbed = new EmbedBuilder() .setColor(client.config.Colors.Default) diff --git a/commands/inventory.js b/commands/inventory.js index a680a7c..a129335 100644 --- a/commands/inventory.js +++ b/commands/inventory.js @@ -235,7 +235,7 @@ module.exports = { interaction.send({ components: [opt], flags: (1 << 6) }) - client.once("interactionCreate", async MenuInteraction => { + client.on("interactionCreate", async MenuInteraction => { if(!MenuInteraction.isSelectMenu()) return; if (!MenuInteraction.customId.endsWith(MenuInteraction.member.user.id)) { return MenuInteraction.reply({ @@ -294,7 +294,7 @@ module.exports = { } }); - return; + } else if (args[0].name == 'wallet') { // Display wallet @@ -447,7 +447,7 @@ module.exports = { interaction.send({ components: [opt], flags: (1 << 6) }) - client.once("interactionCreate", async MenuInteraction => { + client.on("interactionCreate", async MenuInteraction => { if(!MenuInteraction.isSelectMenu()) return; if (!MenuInteraction.customId.endsWith(MenuInteraction.member.user.id)) { return MenuInteraction.reply({ @@ -518,7 +518,7 @@ module.exports = { return MenuInteraction.update({ embeds: [successEmbed], components: [] }); }); - return; + } else if (args[0].name == 'clear') { const prompt = new EmbedBuilder() @@ -540,7 +540,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -571,7 +571,7 @@ module.exports = { return ButtonInteraction.update({ embeds: [successEmbed], components: [] }); }); - return; + } }, }, diff --git a/commands/reset.js b/commands/reset.js index e6a606c..acb87c2 100644 --- a/commands/reset.js +++ b/commands/reset.js @@ -22,7 +22,7 @@ module.exports = { /** * * @param {require("../structures/QuarksBot")} client - * @param {import("discord.js").MessageCreate} message + * @param {import("discord.js").Message} message * @param {string[]} args * @param {*} param3 */ @@ -55,7 +55,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", async (ButtonInteraction) => { + client.on("interactionCreate", async (ButtonInteraction) => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -115,7 +115,7 @@ module.exports = { return ButtonInteraction.update({ embeds: [successEmbed], components: [] }); } }); - return; + }, }, } \ No newline at end of file diff --git a/commands/settings.js b/commands/settings.js index dcd1a3e..32c2dc8 100644 --- a/commands/settings.js +++ b/commands/settings.js @@ -5,7 +5,7 @@ module.exports = { name: "settings", debug: false, description: "Configure your server settings", - usage: "[opt], flags: (1 << 6) [action] [value]", + usage: "[opt] [action] [value]", permissions: { channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], member: ["MANAGE_GUILD"], @@ -409,7 +409,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -439,7 +439,7 @@ module.exports = { return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); - return; + } else console.log('exception?'); } else if (args[0].name == 'action_channel') { @@ -487,7 +487,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -517,7 +517,7 @@ module.exports = { return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); - return; + } } else if (args[0].name == 'tweet_channel') { @@ -565,7 +565,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -595,7 +595,7 @@ module.exports = { return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); - return; + } } else if (args[0].name == 'adverts_channel') { @@ -643,7 +643,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -673,7 +673,7 @@ module.exports = { return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); - return; + } } else if (args[0].name == 'dispatcher_channel') { @@ -722,7 +722,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -752,7 +752,7 @@ module.exports = { return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); - return; + } } else if (args[0].name == 'starting_balance') { @@ -850,7 +850,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -880,7 +880,7 @@ module.exports = { return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); - return; + } } @@ -924,7 +924,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -954,7 +954,7 @@ module.exports = { return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); - return; + } } else if (args[0].name == 'officer_role') { @@ -998,7 +998,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -1028,7 +1028,7 @@ module.exports = { return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); - return; + } } else if (args[0].name == 'dispatcher_role') { @@ -1072,7 +1072,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -1103,7 +1103,7 @@ module.exports = { return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] }); }); } - return; + } else if (args[0].name == 'bot_admin_role') { @@ -1146,7 +1146,7 @@ module.exports = { interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - client.once("interactionCreate", ButtonInteraction => { + client.on("interactionCreate", ButtonInteraction => { if(!ButtonInteraction.isButton()) return; const queryString = ButtonInteraction.customId; if (!queryString.endsWith(ButtonInteraction.member.user.id)) { @@ -1177,7 +1177,7 @@ module.exports = { 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) { diff --git a/config/settingsHelp.js b/config/settingsHelp.js new file mode 100644 index 0000000..c5bbf54 --- /dev/null +++ b/config/settingsHelp.js @@ -0,0 +1,110 @@ +module.exports = { + settings: [ + { + name: "allowed_channels", + description: ` + If you wish to limit users to use the bot in some channels, you can configure \`allowed_channels\`. To do so, use \`/settings allowed_channels add \` to add a channel to a list of allowed channels. + + To remove a channel, use \`/settings allowed_channel remove \`. + ` + }, + { + name: "action_channel", + description: ` + To save the hastle of cluttered channels, you can configure a dedicated channel for the \`/action\` command. To do so, use \`/settings action_channel set \`. This will send any output for the \`/action\` command to this channel. + + To remove this configuration, use \`/settings action_channel remove\` + ` + }, + { + name: "tweet_channel", + description: ` + To save the hastle of cluttered channels, you can configure a dedicated channel for the \`/tweet\` command. To do so, use \`/settings tweet_channel set \`. This will send any output for the \`/tweet\` command to this channel. + + To remove this configuration, use \`/settings tweet_channel remove\` + ` + }, + { + name: "adverts_channel", + description: ` + Users with the configured commercial role can create advertisements for their commercial business. To keep your channels clean, you can limit the output of this command to a dedicated channel. To do so, use \`/settings adverts_channel set \`. This will send any adverts to this channel. + + To remove this configuration, use \`/settings adverts_channel remove\`. + ` + }, + { + name: "dispatcher_channel", + description: ` + In order for the \`/311\` or \`/911\` commands to be used, you need to configure two settings. \`dispatcher_channel\` is one of the settings to configure. This will redirect all \`/311\` or \`/911\` reports to a dedicated channel. Use \`/settings dispatcher_channel set \` to configure this setting. + + To remove this configuration, use \`/settings dispatcher_channel remove\`. + ` + }, + { + name: "starting_balance", + description: ` + New users in your guild receive $1000.00 as their starting balance. This can be configured, use \`/settings starting_balance \`. This can be a floating point number, e.g 150.40 + + floating point number: a number value with a decimal. + ` + }, + { + name: "income_role", + description: ` + Users can work once a day to earn money, but this will require a role with a set daily income. To configure a new income role, use \`/settings income_role set \`. + + Users with one of these configured roles can use the \`/work\` command once a day to earn their set daily income. + + Note: If a user has more than one role to earn income, using the \`/work\` command will earn them the highest income from one of the roles they have. + + To remove one of the configured roles, use \`/settings income_roles remove \`. + ` + }, + { + name: "bot_admin_role", + description: ` + Some commands are limited to users who can manage the guild (Admin privilages), but if you wish for users without admin privilages to access commands such as \`/settings\` \`/money\` or \`/reset\`. You can configure a bot admin role. + + Use \`/settings bot_admin_role set \` to configure the bot admin role. + + To remove this configuration, use \`/settings bot_admin_role remove\`. + ` + }, + { + name: "commercial_role", + description: ` + Users with the commercial_role have access to business related commands, to configure this role to give to some users, use \`/settings commercial_role set \`. + + To remove this configured role, use \`/settings commercial_role remove\`. + ` + }, + { + name: "officer_role", + description: ` + The \`/fine\` command requires a user to have a configured officer role. To configure this role, use \`/settings officer_role set \` + + To remove this configured role, use \`/settings officer_role remove\`. + ` + }, + { + name: "dispatcher_role", + description: ` + In order for the \`/311\` or \`/911\` commands to be used, you need to configure two settings. \`dispatcher_role\` is one of the settings to configure. This will allow users to interact with all \`/311\` or \`/911\` reports. Use \`/settings dispatcher_role set \` to configure this setting. + + To remove this configuration, use \`/settings dispatcher_role remove\`. + ` + }, + { + name: "only_officers_search", + description: ` + The \`/search\` command allows users to view other users inventories. If you wish to limit this command, you can do so by configuring \`only_officers_search\`. Use \`/settings only_officers_search \`. This will optionally limit the \`/search\` command to users with the configured officer role. + ` + }, + { + name: "view", + description: ` + There is a lot of settings you can configure. To view a all configured settings, use the following: \`/settings view\`. This will display all configured settings, and their values if configured. + ` + } + ] +} \ No newline at end of file