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