Merge branch 'dev' into 'main'
Updated guild top commannd and updated commands handler See merge request illegitimate/illegitimate-bot!161
This commit is contained in:
@@ -177,13 +177,16 @@ export default async function guildTop(
|
|||||||
amount = 1
|
amount = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
type GuildTopData = { ign: string; gexp: string }[]
|
type GuildTopData = { ign: string, uuid: string }[]
|
||||||
type NewList = { name: string; value: string; inline: boolean }[]
|
type NewList = { name: string, value: string; inline: boolean }[]
|
||||||
|
|
||||||
let cacheStatus: boolean
|
let cacheStatus: boolean
|
||||||
let guildData: GuildTopData = []
|
let guildData: GuildTopData = []
|
||||||
const fieldsValueRaw: string[] = []
|
const fieldsValueRaw: string[] = []
|
||||||
const allMembersSorted = allMembersDailyGEXP.sort((a, b) => b.gexp - a.gexp)
|
const allMembersSorted = allMembersDailyGEXP.sort((a, b) => b.gexp - a.gexp)
|
||||||
|
const allMembersSortedUUIDArray = allMembersSorted.map(member => {
|
||||||
|
return member.uuid
|
||||||
|
})
|
||||||
|
|
||||||
if (!cachedData) {
|
if (!cachedData) {
|
||||||
cacheStatus = false
|
cacheStatus = false
|
||||||
@@ -201,14 +204,13 @@ export default async function guildTop(
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < allMembersSorted.length; i++) {
|
for (let i = 0; i < allMembersSortedUUIDArray.length; i++) {
|
||||||
const ign = (await getIGN(allMembersSorted[i].uuid)) as string
|
const uuid = allMembersSortedUUIDArray[i]
|
||||||
const gexpUnformatted = allMembersSorted[i].gexp
|
const ign = await getIGN(uuid)
|
||||||
const gexp = new Intl.NumberFormat("en-US").format(gexpUnformatted)
|
|
||||||
|
|
||||||
guildData.push({
|
guildData.push({
|
||||||
ign: ign,
|
ign: ign!,
|
||||||
gexp: gexp,
|
uuid: uuid,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,12 +238,12 @@ export default async function guildTop(
|
|||||||
guildData = JSON.parse(cachedData)
|
guildData = JSON.parse(cachedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
const topMembers = guildData.slice(0, amount)
|
const topMembers = allMembersSorted.slice(0, amount)
|
||||||
const sliceSize = amount / 3
|
const sliceSize = amount / 4
|
||||||
|
|
||||||
for (let i = 0; i < amount; i++) {
|
for (let i = 0; i < amount; i++) {
|
||||||
const ign = topMembers[i].ign
|
const gexp = new Intl.NumberFormat("en-US").format(topMembers[i].gexp)
|
||||||
const gexp = topMembers[i].gexp
|
const ign = guildData.find(member => member.uuid === topMembers[i].uuid)?.ign
|
||||||
|
|
||||||
const position = i + 1
|
const position = i + 1
|
||||||
|
|
||||||
@@ -259,7 +261,7 @@ export default async function guildTop(
|
|||||||
newList[index] = {
|
newList[index] = {
|
||||||
name: "",
|
name: "",
|
||||||
value: item.join("\n"),
|
value: item.join("\n"),
|
||||||
inline: true,
|
inline: false,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.error(error)
|
console.error(error)
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: "There was an error while executing this command!",
|
content: "There was an error while executing this command!",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user