Updated guild info command to query name and id as well

This commit is contained in:
2023-12-05 00:00:08 +01:00
parent bc54546788
commit 4c29b8dd47
2 changed files with 89 additions and 39 deletions

View File

@@ -7,7 +7,7 @@ module.exports = {
name: "guild", name: "guild",
description: "Subcommands for guilds", description: "Subcommands for guilds",
type: "slash", type: "slash",
dev: false, dev: true,
public: true, public: true,
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@@ -30,9 +30,19 @@ module.exports = {
.setDescription("Get info about a guild.") .setDescription("Get info about a guild.")
.addStringOption(option => .addStringOption(option =>
option option
.setName("ign") .setName("query")
.setDescription("The IGN of a member.") .setDescription("The IGN of a member.")
.setRequired(true) .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" }
)
) )
), ),

View File

@@ -5,61 +5,101 @@ const { color, devMessage } = require("../../../config/options.json")
async function guildInfo(interaction) { 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")) const embedColor = Number(color.replace("#", "0x"))
let guild
await interaction.editReply({ if (type === "ign") {
embeds: [{ await interaction.editReply({
description: "Fetching your uuid...",
color: embedColor
}]
})
const uuid = await getUUID(ign)
if (!uuid) {
interaction.editReply({
embeds: [{ embeds: [{
description: "That player doen't exist!", description: "Fetching your uuid...",
color: embedColor color: embedColor
}] }]
}) })
return
}
await interaction.editReply({ const uuid = await getUUID(query)
embeds: [{ if (!uuid) {
description: "Fetching your player data...", interaction.editReply({
color: embedColor embeds: [{
}] description: "That player doen't exist!",
}) color: embedColor
}]
})
return
}
const player = await getPlayer(uuid) await interaction.editReply({
if (!player) {
interaction.editReply({
embeds: [{ embeds: [{
description: "That player has never joined the server!", description: "Fetching your player data...",
color: embedColor color: embedColor
}] }]
}) })
return
}
await interaction.editReply({ const player = await getPlayer(uuid)
embeds: [{ if (!player) {
description: "Fetching your guild data...", interaction.editReply({
color: embedColor embeds: [{
}] description: "That player has never joined the server!",
}) color: embedColor
}]
})
return
}
const guild = await getGuild(uuid) await interaction.editReply({
if (!guild) {
interaction.editReply({
embeds: [{ embeds: [{
description: "That player is not in a guild!", description: "Fetching your guild data...",
color: embedColor 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 const guildName = guild.name