Fixed formatting for event files
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
hypixelGuildID,
|
||||
guildLogChannel,
|
||||
color,
|
||||
devMessage
|
||||
} from "config/options.json"
|
||||
import { hypixelGuildID, guildLogChannel, color, devMessage } from "config/options.json"
|
||||
import colorLog from "utils/functions/colors"
|
||||
import { getGuild, getIGN } from "utils/Hypixel"
|
||||
import { Cron, GuildData } from "interfaces"
|
||||
@@ -22,18 +17,15 @@ async function guildWeekly() {
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const message = await channel.send({
|
||||
embeds: [
|
||||
{
|
||||
description: "Starting to fetch guild data...",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: "Starting to fetch guild data...",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
const guild = (await getGuild(hypixelGuildID, "id")) as GuildData
|
||||
const guildMembersList: string[] = []
|
||||
const topWeeklyMembers: { name: string; value: string; inline: boolean }[] =
|
||||
[]
|
||||
const topWeeklyMembers: { name: string; value: string; inline: boolean }[] = []
|
||||
|
||||
const guildName = guild.name
|
||||
const guildMembers = guild.members
|
||||
@@ -41,24 +33,18 @@ async function guildWeekly() {
|
||||
const sliceSize = guildMembers.length / 4
|
||||
|
||||
// top weekly members
|
||||
const allMembersGexpSorted = guildMembers
|
||||
.map(member => {
|
||||
return {
|
||||
uuid: member.uuid,
|
||||
exp: Object.values(member.expHistory).reduce((a, b) => a + b, 0)
|
||||
}
|
||||
})
|
||||
.sort((a, b) => b.exp - a.exp)
|
||||
const allMembersGexpSorted = guildMembers.map(member => {
|
||||
return {
|
||||
uuid: member.uuid,
|
||||
exp: Object.values(member.expHistory).reduce((a, b) => a + b, 0)
|
||||
}
|
||||
}).sort((a, b) => b.exp - a.exp)
|
||||
|
||||
for (let i = 0; i < allMembersGexpSorted.length; i++) {
|
||||
const ign = await getIGN(allMembersGexpSorted[i].uuid)
|
||||
const gexp = new Intl.NumberFormat("en-US").format(
|
||||
allMembersGexpSorted[i].exp
|
||||
)
|
||||
const gexp = new Intl.NumberFormat("en-US").format(allMembersGexpSorted[i].exp)
|
||||
const position = i + 1
|
||||
guildMembersList.push(
|
||||
"**#" + position + " " + ign + ":** `" + gexp + "`"
|
||||
)
|
||||
guildMembersList.push("**#" + position + " " + ign + ":** `" + gexp + "`")
|
||||
}
|
||||
|
||||
const list = Array.from({ length: sliceSize }, (_, i) =>
|
||||
@@ -76,46 +62,30 @@ async function guildWeekly() {
|
||||
})
|
||||
|
||||
// combined weekly gexp
|
||||
const allGuildMembersWeeklyXP = guildMembers.map(
|
||||
member => member.expHistory
|
||||
)
|
||||
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 averageGuildMembersDailyXPUnformatted =
|
||||
totalGuildMembersWeeklyXPUnformatted / 7
|
||||
const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce((a, b) => a + b, 0)
|
||||
const averageGuildMembersDailyXPUnformatted = totalGuildMembersWeeklyXPUnformatted / 7
|
||||
|
||||
// final values
|
||||
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
|
||||
totalGuildMembersWeeklyXPUnformatted
|
||||
)
|
||||
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
|
||||
averageGuildMembersDailyXPUnformatted
|
||||
)
|
||||
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(totalGuildMembersWeeklyXPUnformatted)
|
||||
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(averageGuildMembersDailyXPUnformatted)
|
||||
|
||||
await message.edit({
|
||||
embeds: [
|
||||
{
|
||||
title: "**Weekly Guild XP for " + guildName + "**",
|
||||
description:
|
||||
"**Total weekly guild XP:** `" +
|
||||
totalGuildMembersWeeklyXP +
|
||||
"`\n**Average daily guild XP:** `" +
|
||||
averageGuildMembersWeeklyXP +
|
||||
"`",
|
||||
color: embedColor,
|
||||
fields: topWeeklyMembers,
|
||||
timestamp: new Date().toISOString(),
|
||||
footer: {
|
||||
text: channel.guild.name + " | " + devMessage,
|
||||
icon_url: channel.guild.iconURL() || undefined
|
||||
}
|
||||
embeds: [{
|
||||
title: "**Weekly Guild XP for " + guildName + "**",
|
||||
description: "**Total weekly guild XP:** `" + totalGuildMembersWeeklyXP +
|
||||
"`\n**Average daily guild XP:** `" + averageGuildMembersWeeklyXP + "`",
|
||||
color: embedColor,
|
||||
fields: topWeeklyMembers,
|
||||
timestamp: new Date().toISOString(),
|
||||
footer: {
|
||||
text: channel.guild.name + " | " + devMessage,
|
||||
icon_url: channel.guild.iconURL() || undefined
|
||||
}
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -13,25 +13,20 @@ export = {
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
logToChannel("bot", {
|
||||
embeds: [
|
||||
{
|
||||
title: "New Member",
|
||||
description:
|
||||
userMention(member.id) +
|
||||
" has joined the server.\n" +
|
||||
"Account created: " +
|
||||
member.user.createdAt.toLocaleString(),
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: member.user.avatarURL() || ""
|
||||
},
|
||||
footer: {
|
||||
text: "ID: " + member.id,
|
||||
icon_url: member.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
title: "New Member",
|
||||
description: userMention(member.id) + " has joined the server.\n" +
|
||||
"Account created: " + member.user.createdAt.toLocaleString(),
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: member.user.avatarURL() || ""
|
||||
},
|
||||
footer: {
|
||||
text: "ID: " + member.id,
|
||||
icon_url: member.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
}
|
||||
} as Event
|
||||
|
||||
@@ -12,20 +12,16 @@ export = {
|
||||
try {
|
||||
console.log(
|
||||
color(
|
||||
interaction.user.username +
|
||||
" ran " +
|
||||
interaction.commandName +
|
||||
" " +
|
||||
interaction.options.getSubcommand(),
|
||||
"pink"
|
||||
interaction.user.username + " ran " +
|
||||
interaction.commandName + " " +
|
||||
interaction.options.getSubcommand(), "pink"
|
||||
)
|
||||
)
|
||||
} catch {
|
||||
console.log(
|
||||
color(
|
||||
interaction.user.username +
|
||||
" ran " +
|
||||
interaction.commandName,
|
||||
interaction.user.username + " ran " +
|
||||
interaction.commandName,
|
||||
"pink"
|
||||
)
|
||||
)
|
||||
@@ -35,11 +31,9 @@ export = {
|
||||
if (interaction.isButton()) {
|
||||
console.log(
|
||||
color(
|
||||
interaction.user.username +
|
||||
"#" +
|
||||
interaction.user.discriminator +
|
||||
" clicked " +
|
||||
interaction.customId,
|
||||
interaction.user.username + "#" +
|
||||
interaction.user.discriminator + " clicked " +
|
||||
interaction.customId,
|
||||
"pink"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -19,19 +19,15 @@ export = {
|
||||
const output = eval(code)
|
||||
const outputString = String(output)
|
||||
await message.channel.send({
|
||||
embeds: [
|
||||
{
|
||||
description: `\`\`\`js\n${outputString}\`\`\``
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: `\`\`\`js\n${outputString}\`\`\``
|
||||
}]
|
||||
})
|
||||
} catch (error) {
|
||||
await message.channel.send({
|
||||
embeds: [
|
||||
{
|
||||
description: `\`\`\`js\n${error}\`\`\``
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: `\`\`\`js\n${error}\`\`\``
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,7 @@ export = {
|
||||
event: "messageCreate",
|
||||
|
||||
async execute(message: Message) {
|
||||
if (
|
||||
message.content.toLowerCase().includes("ur mom") &&
|
||||
message.author.username === "taken.lua"
|
||||
) {
|
||||
if (message.content.toLowerCase().includes("ur mom") && message.author.username === "taken.lua") {
|
||||
message.react("Woot:734345936347725885")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,10 @@ export = {
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
logToChannel("online", {
|
||||
embeds: [
|
||||
{
|
||||
description: "Bot is online!",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
description: "Bot is online!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
} as Event
|
||||
|
||||
@@ -17,64 +17,45 @@ export = {
|
||||
|
||||
if (oldChannel === null && newChannel !== null) {
|
||||
logToChannel("bot", {
|
||||
embeds: [
|
||||
{
|
||||
title: "Voice Channel Join",
|
||||
description:
|
||||
userMention(newState.member!.id) +
|
||||
" joined " +
|
||||
channelMention(newChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + newState.member!.id,
|
||||
icon_url:
|
||||
newState.member!.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
title: "Voice Channel Join",
|
||||
description: userMention(newState.member!.id) + " joined " + channelMention(newChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + newState.member!.id,
|
||||
icon_url: newState.member!.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
} else if (oldChannel !== null && newChannel === null) {
|
||||
logToChannel("bot", {
|
||||
embeds: [
|
||||
{
|
||||
title: "Voice Channel Leave",
|
||||
description:
|
||||
userMention(oldState.member!.id) +
|
||||
" left " +
|
||||
channelMention(oldChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member!.id,
|
||||
icon_url:
|
||||
oldState.member!.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
title: "Voice Channel Leave",
|
||||
description: userMention(oldState.member!.id) + " left " + channelMention(oldChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member!.id,
|
||||
icon_url: oldState.member!.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
} else if (oldChannel !== null && newChannel !== null) {
|
||||
if (oldChannel.id === newChannel.id) return
|
||||
|
||||
logToChannel("bot", {
|
||||
embeds: [
|
||||
{
|
||||
title: "Voice Channel Switch",
|
||||
description:
|
||||
userMention(oldState.member!.id) +
|
||||
" switched from " +
|
||||
channelMention(oldChannel.id) +
|
||||
" to " +
|
||||
channelMention(newChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member!.id,
|
||||
icon_url:
|
||||
oldState.member!.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
]
|
||||
embeds: [{
|
||||
title: "Voice Channel Switch",
|
||||
description: userMention(oldState.member!.id) + " switched from " + channelMention(oldChannel.id) +
|
||||
" to " + channelMention(newChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member!.id,
|
||||
icon_url: oldState.member!.user.avatarURL() || undefined
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user