From 9f5280d90259ac41bb5c1a1437bfb40818fe0295 Mon Sep 17 00:00:00 2001 From: Taken Date: Tue, 5 Dec 2023 14:22:26 +0100 Subject: [PATCH 1/5] Added sorting to ranks based on position Signed-off-by: Taken --- src/commands/guild/info.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/guild/info.js b/src/commands/guild/info.js index 4498188..ab965e7 100644 --- a/src/commands/guild/info.js +++ b/src/commands/guild/info.js @@ -127,7 +127,8 @@ async function guildInfo(interaction) { const guildOwner = guildMembers.find((m) => m.rank === "Guild Master").uuid const guildOwnerName = await getIGN(guildOwner) - const guildRanks = guild.ranks.map((r) => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n") + const guildRanksUnsorted = guild.ranks.sort((a, b) => b.priority - a.priority) + const guildRanks = guildRanksUnsorted.map((r) => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n") const guildMembersDailyXP = Object.values(guildMembers).map((m) => m.expHistory[Object.keys(m.expHistory)[0]]) const totalGuildMembersDailyXPUnformatted = guildMembersDailyXP.reduce((a, b) => a + b, 0) From b0732bdaabfc4bcd191bbb200ba16cf3cc2f244e Mon Sep 17 00:00:00 2001 From: Taken Date: Tue, 5 Dec 2023 14:30:37 +0100 Subject: [PATCH 2/5] Added logging of subcommands as well --- src/events/server/interactions/logBtnsCmds.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/events/server/interactions/logBtnsCmds.js b/src/events/server/interactions/logBtnsCmds.js index b317c06..cf021fd 100644 --- a/src/events/server/interactions/logBtnsCmds.js +++ b/src/events/server/interactions/logBtnsCmds.js @@ -8,10 +8,16 @@ module.exports = { execute(interaction) { if (interaction.isCommand()) { - console.log(interaction.user.username + "#" + - interaction.user.discriminator + " ran " + - interaction.commandName - ) + try { + console.log(interaction.user.username + " ran " + + interaction.commandName + " " + + interaction.options.getSubcommand() + ) + } catch { + console.log(interaction.user.username + " ran " + + interaction.commandName + ) + } } else if (interaction.isButton()) { console.log(interaction.user.username + "#" + interaction.user.discriminator + " clicked " + From df82a6692110e11e46646671b5c21bea02c44c9b Mon Sep 17 00:00:00 2001 From: Taken Date: Tue, 5 Dec 2023 14:37:18 +0100 Subject: [PATCH 3/5] Updated command descriptions --- src/commands/ban.js | 2 +- src/commands/guild.js | 2 +- src/commands/help.js | 2 +- src/commands/ping.js | 2 +- src/commands/update.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/commands/ban.js b/src/commands/ban.js index f31794e..dd0e0a0 100644 --- a/src/commands/ban.js +++ b/src/commands/ban.js @@ -11,7 +11,7 @@ module.exports = { data: new SlashCommandBuilder() .setName("ban") - .setDescription("Ban a user") + .setDescription("Bans a user") .addUserOption(option => option .setName("user") diff --git a/src/commands/guild.js b/src/commands/guild.js index d1b2ba6..2e20ce2 100644 --- a/src/commands/guild.js +++ b/src/commands/guild.js @@ -31,7 +31,7 @@ module.exports = { .addStringOption(option => option .setName("query") - .setDescription("The IGN of a member.") + .setDescription("The query to search for. [Default: player]") .setRequired(true) ). addStringOption(option => diff --git a/src/commands/help.js b/src/commands/help.js index 158caa7..397a5dc 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -11,7 +11,7 @@ module.exports = { data: new SlashCommandBuilder() .setName("help") - .setDescription("Help command") + .setDescription("List's all commands usable by a member") .setDMPermission(true), /** @param { import('discord.js').ChatInputCommandInteraction } interaction */ diff --git a/src/commands/ping.js b/src/commands/ping.js index c1c1618..f7cd433 100644 --- a/src/commands/ping.js +++ b/src/commands/ping.js @@ -10,7 +10,7 @@ module.exports = { data: new SlashCommandBuilder() .setName("ping") - .setDescription("Get the bot's ping."), + .setDescription("Get's the bot's ping."), /** * @param { import("discord.js").ChatInputCommandInteraction } interaction diff --git a/src/commands/update.js b/src/commands/update.js index 119cab2..ab03246 100644 --- a/src/commands/update.js +++ b/src/commands/update.js @@ -14,7 +14,7 @@ module.exports = { data: new SlashCommandBuilder() .setName("update") - .setDescription("Update your guild rank.") + .setDescription("Update your discord roles.") .setDMPermission(false), /** @param { import('discord.js').ChatInputCommandInteraction } interaction */ From cf42d05d89fa80269c0661276d9e844161ccd62f Mon Sep 17 00:00:00 2001 From: Taken Date: Tue, 5 Dec 2023 15:29:41 +0100 Subject: [PATCH 4/5] Updated help command to include subcommands --- src/commands/guild.js | 10 ++++++++++ src/commands/help.js | 20 ++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/commands/guild.js b/src/commands/guild.js index 2e20ce2..fa513a0 100644 --- a/src/commands/guild.js +++ b/src/commands/guild.js @@ -9,6 +9,16 @@ module.exports = { type: "slash", dev: false, public: true, + subcommands: [ + { + name: "member", + description: "Get info about a guild memeber", + }, + { + name: "info", + description: "Get info about a guild.", + } + ], data: new SlashCommandBuilder() .setName("guild") diff --git a/src/commands/help.js b/src/commands/help.js index 397a5dc..ed24d83 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -6,7 +6,7 @@ module.exports = { name: "help", description: "Help command", type: "slash", - dev: false, + dev: true, public: true, data: new SlashCommandBuilder() @@ -24,10 +24,26 @@ module.exports = { const commandFiles = fs.readdirSync(__dirname).filter(file => file.endsWith(".js")) for (const file of commandFiles) { const command = require(`./${file}`) - if (command.public) { + if (command.public && !command.subcommands) { commands.push(command) + } else if (command.public && command.subcommands) { + const commandName = command.name + + const subcommands = command.subcommands.map((subcommand) => { + return { + name: commandName + " " + subcommand.name, + description: subcommand.description + } + }) + + console.log(subcommands) + + for (const subcommand of subcommands) { + commands.push(subcommand) + } } } + const commandList = commands.map((command) => { return { name: "**/" + command.name + "**", From e42d7ed70f524ceb66815a9d8c7bcc76d8ba3253 Mon Sep 17 00:00:00 2001 From: Taken Date: Tue, 5 Dec 2023 15:31:55 +0100 Subject: [PATCH 5/5] Removed dev flag Signed-off-by: Taken --- src/commands/help.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/help.js b/src/commands/help.js index ed24d83..37d8d59 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -6,7 +6,7 @@ module.exports = { name: "help", description: "Help command", type: "slash", - dev: true, + dev: false, public: true, data: new SlashCommandBuilder()