Updated guild command formatting
This commit is contained in:
@@ -3,9 +3,7 @@ import { color, devMessage } from "config/options.json"
|
||||
import { ChatInputCommandInteraction } from "discord.js"
|
||||
import { GuildData } from "interfaces"
|
||||
|
||||
export default async function guildInfo(
|
||||
interaction: ChatInputCommandInteraction
|
||||
): Promise<void> {
|
||||
export default async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void> {
|
||||
await interaction.deferReply()
|
||||
|
||||
const query = interaction.options.getString("query")!
|
||||
@@ -15,111 +13,91 @@ export default async function guildInfo(
|
||||
|
||||
if (type === "ign") {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "Fetching your uuid...",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: "Fetching your uuid...",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
const uuid = await getUUID(query)
|
||||
if (!uuid) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "That player doen't exist!",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: "That player doen't exist!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "Fetching your player data...",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: "Fetching your player data...",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "That player has never joined the server!",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: "That player has never joined the server!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "Fetching your guild data...",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: "Fetching your guild data...",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
guild = await getGuild(uuid, "player")
|
||||
if (!guild) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "That player is not in a guild!",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
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
|
||||
}
|
||||
]
|
||||
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
|
||||
}
|
||||
]
|
||||
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
|
||||
}
|
||||
]
|
||||
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
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: "That guild doesn't exist!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -142,95 +120,57 @@ export default async function guildInfo(
|
||||
const guildCreatedSecond = guildCreated.getSeconds()
|
||||
|
||||
const guildCreatedTime =
|
||||
guildCreatedDate +
|
||||
"." +
|
||||
guildCreatedMonth +
|
||||
"." +
|
||||
guildCreatedYear +
|
||||
" " +
|
||||
guildCreatedHour +
|
||||
":" +
|
||||
guildCreatedMinute +
|
||||
":" +
|
||||
guildCreatedDate + "." +
|
||||
guildCreatedMonth + "." +
|
||||
guildCreatedYear + " " +
|
||||
guildCreatedHour + ":" +
|
||||
guildCreatedMinute + ":" +
|
||||
guildCreatedSecond
|
||||
|
||||
const guildOwner = guildMembers.find(m => m.rank === "Guild Master")!.uuid
|
||||
const guildOwnerName = await getIGN(guildOwner)
|
||||
const guildRanksUnsorted = guild!.ranks.sort(
|
||||
(a, b) => b.priority - a.priority
|
||||
const guildRanksUnsorted = guild!.ranks.sort((a, b) => b.priority - a.priority
|
||||
)
|
||||
const guildRanks = guildRanksUnsorted
|
||||
.map(r => "**➺ " + r.name + "** `[" + r.tag + "]`")
|
||||
.join("\n")
|
||||
const guildRanks = guildRanksUnsorted.map(r => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n")
|
||||
|
||||
const allGuildMembersWeeklyXP = guildMembers.map(
|
||||
member => member.expHistory
|
||||
)
|
||||
const guildMembersWeeklyXP = allGuildMembersWeeklyXP.map(member => {
|
||||
return Object.values(member).reduce((a, b) => a + b, 0)
|
||||
})
|
||||
const allGuildMembersWeeklyXP = guildMembers.map(member => member.expHistory)
|
||||
const guildMembersWeeklyXP = allGuildMembersWeeklyXP.map(member => { return Object.values(member).reduce((a, b) => a + b, 0) })
|
||||
|
||||
const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce(
|
||||
(a, b) => a + b,
|
||||
0
|
||||
)
|
||||
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
|
||||
totalGuildMembersWeeklyXPUnformatted
|
||||
)
|
||||
const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce((a, b) => a + b, 0)
|
||||
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(totalGuildMembersWeeklyXPUnformatted)
|
||||
|
||||
const averageGuildMembersWeeklyXPUnformatted = Math.round(
|
||||
totalGuildMembersWeeklyXPUnformatted / 7
|
||||
)
|
||||
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
|
||||
averageGuildMembersWeeklyXPUnformatted
|
||||
)
|
||||
const averageGuildMembersWeeklyXPUnformatted = Math.round(totalGuildMembersWeeklyXPUnformatted / 7)
|
||||
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(averageGuildMembersWeeklyXPUnformatted)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
title: "**Info on** " + guildName,
|
||||
description:
|
||||
"**Guild Name: **`" +
|
||||
guildName +
|
||||
"`\n" +
|
||||
"**Guild Tag: **`" +
|
||||
guildTag +
|
||||
"`\n" +
|
||||
"**Guild Level: **`" +
|
||||
guildLvl +
|
||||
"`\n" +
|
||||
"**Guild Owner: **`" +
|
||||
guildOwnerName +
|
||||
"`",
|
||||
fields: [
|
||||
{
|
||||
name: "**Guild Ranks**",
|
||||
value: guildRanks
|
||||
},
|
||||
{
|
||||
name: "**GEXP**",
|
||||
value:
|
||||
"**➺ Total weekly GEXP:** `" +
|
||||
totalGuildMembersWeeklyXP +
|
||||
"`\n" +
|
||||
"**➺ Daily avarage:** `" +
|
||||
averageGuildMembersWeeklyXP +
|
||||
"`\n" +
|
||||
"**➺ Total GEXP:** `" +
|
||||
guildExp +
|
||||
"`"
|
||||
},
|
||||
{
|
||||
name: "**Guild Created**",
|
||||
value: "**➺ **`" + guildCreatedTime + "`"
|
||||
}
|
||||
],
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild!.name + " | " + devMessage,
|
||||
icon_url: interaction.guild!.iconURL() || undefined
|
||||
embeds: [{
|
||||
title: "**Info on** " + guildName,
|
||||
description: "**Guild Name: **`" + guildName + "`\n" +
|
||||
"**Guild Tag: **`" + guildTag + "`\n" +
|
||||
"**Guild Level: **`" + guildLvl + "`\n" +
|
||||
"**Guild Owner: **`" + guildOwnerName + "`",
|
||||
fields: [
|
||||
{
|
||||
name: "**Guild Ranks**",
|
||||
value: guildRanks
|
||||
},
|
||||
{
|
||||
name: "**GEXP**",
|
||||
value:
|
||||
"**➺ Total weekly GEXP:** `" + totalGuildMembersWeeklyXP + "`\n" +
|
||||
"**➺ Daily avarage:** `" + averageGuildMembersWeeklyXP + "`\n" +
|
||||
"**➺ Total GEXP:** `" + guildExp + "`"
|
||||
},
|
||||
{
|
||||
name: "**Guild Created**",
|
||||
value: "**➺ **`" + guildCreatedTime + "`"
|
||||
}
|
||||
],
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild!.name + " | " + devMessage,
|
||||
icon_url: interaction.guild!.iconURL() || undefined
|
||||
}
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user