Moved code to src folder

This commit is contained in:
2023-11-23 12:38:55 +01:00
parent 932bce6057
commit 0eeb48b2dd
68 changed files with 59 additions and 70 deletions

103
src/commands/guild/info.js Normal file
View File

@@ -0,0 +1,103 @@
const { getUUID, getIGN, getPlayer, getGuild, guildLevel } = require("../../utils/utils.js")
const { color } = require("../../../config/options.json")
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function guildInfo(interaction) {
const ign = interaction.options.getString("ign")
const embedColor = Number(color.replace("#", "0x"))
const uuid = await getUUID(ign)
if (!uuid) {
interaction.editReply({
embeds: [{
description: "That player doen't exist!",
color: embedColor
}]
})
return
}
const player = await getPlayer(uuid)
if (!player) {
interaction.editReply({
embeds: [{
description: "That player has never joined the server!",
color: embedColor
}]
})
return
}
const guild = await getGuild(uuid)
if (!guild) {
interaction.editReply({
embeds: [{
description: "That player is not in a guild!",
color: embedColor
}]
})
return
}
const guildName = guild.name
const guildCreatedMS = guild.created
const guildCreated = new Date(guildCreatedMS)
const guildTag = guild.tag
const guildExp = guild.exp
const guildLvl = guildLevel(guildExp)
const guildMembers = guild.members
const guildCreatedDate = guildCreated.getDate()
const guildCreatedMonth = guildCreated.getMonth() + 1
const guildCreatedYear = guildCreated.getFullYear()
const guildCreatedHour = guildCreated.getHours()
const guildCreatedMinute = guildCreated.getMinutes()
const guildCreatedSecond = guildCreated.getSeconds()
const guildCreatedTime = guildCreatedDate + "." +
guildCreatedMonth + "." +
guildCreatedYear + " " +
guildCreatedHour + ":" +
guildCreatedMinute + ":" +
guildCreatedSecond
const guildOwner = guildMembers.find((m) => m.rank === "Guild Master").uuid
const guildOwnerName = await getIGN(guildOwner)
const guildRanks = guild.ranks.map((r) => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n")
const guildMembersDailyXP = Object.values(guildMembers).map((m) => m.expHistory[Object.keys(m.expHistory)[0]])
const totalGuildMembersDailyXP = guildMembersDailyXP.reduce((a, b) => a + b, 0)
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:** `" + totalGuildMembersDailyXP + "`"
},
{
name: "**Guild Created**",
value: "**➺ **`" + guildCreatedTime + "`"
}
],
color: embedColor,
footer: {
text: interaction.guild.name + " | Developed by taken.lua",
icon_url: interaction.guild.iconURL({ dynamic: true })
}
}]
})
}
module.exports = { guildInfo }

View File

@@ -0,0 +1,148 @@
const { getUUID, getPlayer, getGuild, getHeadURL } = require("../../utils/utils.js")
const { color } = require("../../../config/options.json")
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function guildMember(interaction) {
const ign = interaction.options.getString("ign")
const embedColor = Number(color.replace("#", "0x"))
const uuid = await getUUID(ign)
if (!uuid) {
interaction.editReply({
embeds: [
{
description: "This user does not exist",
color: embedColor,
footer: {
text: interaction.guild.name + " | Developed by taken.lua",
icon_url: interaction.guild.iconURL({ dynamic: true }),
},
},
],
})
}
const head = await getHeadURL(ign)
const player = await getPlayer(uuid)
if (!player) {
await interaction.editReply({
embeds: [
{
description: "This user never logged on to hypixel",
color: embedColor,
thumbnail: {
url: head,
},
footer: {
text: interaction.guild.name + " | Developed by taken.lua",
icon_url: interaction.guild.iconURL({ dynamic: true }),
},
},
],
})
}
const serverRank = player.newPackageRank
const monthlyRank = player.monthlyPackageRank
const displayName = player.displayname
let rank = ""
if (serverRank === "VIP") {
rank = "[VIP] "
} else if (serverRank === "VIP_PLUS") {
rank = "[VIP+] "
} else if (serverRank === "MVP") {
rank = "[MVP] "
} else if (serverRank === "MVP_PLUS" && monthlyRank === "NONE") {
rank = "[MVP+] "
} else if (serverRank === "MVP_PLUS" && monthlyRank === "SUPERSTAR") {
rank = "[MVP++] "
}
const guild = await getGuild(uuid)
if (!guild) {
await interaction.editReply({
embeds: [
{
description: "This user is not in a guild",
color: embedColor,
thumbnail: {
url: head,
},
footer: {
text: interaction.guild.name + " | Developed by taken.lua",
icon_url: interaction.guild.iconURL({ dynamic: true }),
},
},
],
})
}
const guildName = guild.name
const guildTag = " [" + guild.tag + "]" ?? ""
const guildMembers = guild.members
const guildMember = guildMembers.find((member) => member.uuid === uuid)
const guildRank = guildMember.rank
const memberGexp = guildMember.expHistory
const allDaysGexp = Object.keys(memberGexp).map((key) => {
return "**➺ " + key + ":** " + "`" + memberGexp[key] + "`" + "\n"
})
const expValue = allDaysGexp.join("")
const totalWeeklyGexp = Object.values(memberGexp).reduce((a, b) => a + b, 0)
const averageWeeklyGexp = Math.round(totalWeeklyGexp / 7)
const guildMemberJoinMS = guildMember.joined
const guildMemberJoinTime = new Date(guildMemberJoinMS)
const guildMemberJoinDate = guildMemberJoinTime.getDate()
const guildMemberJoinMonth = guildMemberJoinTime.getMonth() + 1
const guildMemberJoinYear = guildMemberJoinTime.getFullYear()
const guildMemberJoinHours = guildMemberJoinTime.getHours()
const guildMemberJoinMinutes = guildMemberJoinTime.getMinutes()
const guildMemberJoinSeconds = guildMemberJoinTime.getSeconds()
const guildMemberJoin =
guildMemberJoinDate + "." +
guildMemberJoinMonth + "." +
guildMemberJoinYear + " " +
guildMemberJoinHours + ":" +
guildMemberJoinMinutes + ":" +
guildMemberJoinSeconds
await interaction.editReply({
embeds: [
{
title: rank + displayName + guildTag,
description: "**Guild Name:** `" + guildName + "`\n" +
"**Guild Rank:** `" + guildRank + "`\n",
color: embedColor,
thumbnail: {
url: head,
},
fields: [
{
name: "**Daily GEXP**",
value: expValue,
},
{
name: "**Weekly GEXP**",
value: "**➺ Total:** `" + totalWeeklyGexp + "`\n" +
"**➺ Daily avarage:** `" + averageWeeklyGexp + "`",
},
{
name: "**Join date**",
value: "**➺ **`" + guildMemberJoin + "`",
},
],
footer: {
text: interaction.guild.name + " | Developed by taken.lua",
icon_url: interaction.guild.iconURL({ dynamic: true }),
},
},
],
})
return
}
module.exports = { guildMember }