From 4c29b8dd475a0e9ff1c7d454ecf41bf16cda7a2a Mon Sep 17 00:00:00 2001 From: Taken Date: Tue, 5 Dec 2023 00:00:08 +0100 Subject: [PATCH] Updated guild info command to query name and id as well --- src/commands/guild.js | 14 ++++- src/commands/guild/info.js | 114 +++++++++++++++++++++++++------------ 2 files changed, 89 insertions(+), 39 deletions(-) diff --git a/src/commands/guild.js b/src/commands/guild.js index edb3ed6..80499ee 100644 --- a/src/commands/guild.js +++ b/src/commands/guild.js @@ -7,7 +7,7 @@ module.exports = { name: "guild", description: "Subcommands for guilds", type: "slash", - dev: false, + dev: true, public: true, data: new SlashCommandBuilder() @@ -30,9 +30,19 @@ module.exports = { .setDescription("Get info about a guild.") .addStringOption(option => option - .setName("ign") + .setName("query") .setDescription("The IGN of a member.") .setRequired(true) + ). + addStringOption(option => + option + .setName("type") + .setDescription("The type of query.") + .addChoices( + { name: "Guild Member", value: "ign" }, + { name: "Guild Name", value: "name" }, + { name: "Guild Id", value: "id" } + ) ) ), diff --git a/src/commands/guild/info.js b/src/commands/guild/info.js index 5da89fe..d878790 100644 --- a/src/commands/guild/info.js +++ b/src/commands/guild/info.js @@ -5,61 +5,101 @@ const { color, devMessage } = require("../../../config/options.json") async function guildInfo(interaction) { - const ign = interaction.options.getString("ign") + const query = interaction.options.getString("query") + const type = interaction.options.getString("type") || "ign" const embedColor = Number(color.replace("#", "0x")) + let guild - await interaction.editReply({ - embeds: [{ - description: "Fetching your uuid...", - color: embedColor - }] - }) - - const uuid = await getUUID(ign) - if (!uuid) { - interaction.editReply({ + if (type === "ign") { + await interaction.editReply({ embeds: [{ - description: "That player doen't exist!", + description: "Fetching your uuid...", color: embedColor }] }) - return - } - await interaction.editReply({ - embeds: [{ - description: "Fetching your player data...", - color: embedColor - }] - }) + const uuid = await getUUID(query) + if (!uuid) { + interaction.editReply({ + embeds: [{ + description: "That player doen't exist!", + color: embedColor + }] + }) + return + } - const player = await getPlayer(uuid) - if (!player) { - interaction.editReply({ + await interaction.editReply({ embeds: [{ - description: "That player has never joined the server!", + description: "Fetching your player data...", color: embedColor }] }) - return - } - await interaction.editReply({ - embeds: [{ - description: "Fetching your guild data...", - color: embedColor - }] - }) + const player = await getPlayer(uuid) + if (!player) { + interaction.editReply({ + embeds: [{ + description: "That player has never joined the server!", + color: embedColor + }] + }) + return + } - const guild = await getGuild(uuid) - if (!guild) { - interaction.editReply({ + await interaction.editReply({ embeds: [{ - description: "That player is not in a guild!", + description: "Fetching your guild data...", color: embedColor }] }) - return + + guild = await getGuild(uuid, "player") + if (!guild) { + interaction.editReply({ + embeds: [{ + description: "That player is not in a guild!", + color: embedColor + }] + }) + return + } + } else if (type === "name") { + await interaction.editReply({ + embeds: [{ + description: "Fetching your guild data...", + color: embedColor + }] + }) + + guild = await getGuild(query, "name") + if (!guild) { + interaction.editReply({ + embeds: [{ + description: "That guild doesn't exist!", + color: embedColor + }] + }) + return + } + } else if (type === "id") { + await interaction.editReply({ + embeds: [{ + description: "Fetching your guild data...", + color: embedColor + }] + }) + + guild = await getGuild(query, "id") + if (!guild) { + interaction.editReply({ + embeds: [{ + description: "That guild doesn't exist!", + color: embedColor + }] + }) + return + } } const guildName = guild.name