From e053d8fc855dba51791d49fea20699b5ae31565c Mon Sep 17 00:00:00 2001 From: Taken Date: Wed, 21 Jun 2023 12:21:40 +0200 Subject: [PATCH] Fixed verify command to actually use new usernames --- commands/verify.js | 284 ++++++++++++++++++++++----------------------- 1 file changed, 141 insertions(+), 143 deletions(-) diff --git a/commands/verify.js b/commands/verify.js index 2fa94d2..69b2b41 100644 --- a/commands/verify.js +++ b/commands/verify.js @@ -8,172 +8,170 @@ const mongoose = require("mongoose"); const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require("../config/roles.json"); module.exports = { - name: "verify", - description: "Verify yourself as a member of the server.", - type: "slash", + name: "verify", + description: "Verify yourself as a member of the server.", + type: "slash", - data: new SlashCommandBuilder() - .setName("verify") - .setDescription("Verify yourself as a member of the server.") - .addStringOption((option) => option.setName("ign").setDescription("Your in-game name.")) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName("verify") + .setDescription("Verify yourself as a member of the server.") + .addStringOption((option) => option.setName("ign").setDescription("Your in-game name.")) + .setDMPermission(false), - async execute(interaction) { - await interaction.deferReply(); + async execute(interaction) { + await interaction.deferReply(); - const user1 = interaction.user - const user = interaction.guild.members.cache.get(user1.id); - const ign = interaction.options.getString("ign"); - const mojang = "https://api.mojang.com/users/profiles/minecraft/"; - const slothPixel = "https://api.slothpixel.me/api/players/"; - const guildAPI = "https://api.slothpixel.me/api/guilds/"; - const minotar = "https://minotar.net/helm/"; - const embedColor = Number(color.replace("#", "0x")); + const user1 = interaction.user + const user = interaction.guild.members.cache.get(user1.id); + const ign = interaction.options.getString("ign"); + const mojang = "https://api.mojang.com/users/profiles/minecraft/"; + const slothPixel = "https://api.slothpixel.me/api/players/"; + const guildAPI = "https://api.slothpixel.me/api/guilds/"; + const minotar = "https://minotar.net/helm/"; + const embedColor = Number(color.replace("#", "0x")); - const verifyData = await verify.findOne({ userID: user.id }); + const verifyData = await verify.findOne({ userID: user.id }); - if (verifyData) { - interaction.editReply("You are already verified."); - return; - } + if (verifyData) { + interaction.editReply("You are already verified."); + return; + } - if (!ign) { - interaction.editReply("Please provide a player's IGN."); - return; - } + if (!ign) { + interaction.editReply("Please provide a player's IGN."); + return; + } - try { - await fetch(mojang + ign); - } catch (err) { - interaction.editReply("That player doesn't exist. [Mojang]"); - return; - } + try { + await fetch(mojang + ign); + } catch (err) { + interaction.editReply("That player doesn't exist. [Mojang]"); + return; + } - const userCheck = await fetch(mojang + ign); - const userUUID = userCheck.data.id; + const userCheck = await fetch(mojang + ign); + const userUUID = userCheck.data.id; - try { - await fetch(slothPixel + userUUID); - } catch (err) { - interaction.editReply("That player doesn't exist. [Hypixel]"); - return; - } + try { + await fetch(slothPixel + userUUID); + } catch (err) { + interaction.editReply("That player doesn't exist. [Hypixel]"); + return; + } - const hypixelCheck = await fetch(slothPixel + userUUID); - const head = minotar + ign; + const hypixelCheck = await fetch(slothPixel + userUUID); + const head = minotar + ign; - if (user1.discriminator === "0") { - var verifyUsername = user1.username + "#0000" - var username = user1.username - } else { - var verifyUsername = user1.username + "#" + user1.discriminator - var username = user1.username + "#" + user1.discriminator - } + if (user1.discriminator === "0") { + var username = user1.username + } else { + var username = user1.username + "#" + user1.discriminator + } - if (hypixelCheck.data.links.DISCORD !== verifyUsername) { - interaction.editReply({ - embeds: [ - { - description: " The discord tag for `" + userCheck.data.name + "` is not `" + verifyUsername + "`. Please link your discord account to your hypixel account.\n" + - "**If you are are using a new username then you will have to set your discord on hypixel to** `yourusername#0000`", - color: embedColor - } - ] - }); - return; - } + if (hypixelCheck.data.links.DISCORD !== username) { + interaction.editReply({ + embeds: [ + { + description: " The discord tag for `" + userCheck.data.name + "` is not `" + username + "`. Please link your discord account to your hypixel account.\n" + + "**If you are are using a new username then you will have to set your discord on hypixel to** `yourusername#0000`", + color: embedColor + } + ] + }); + return; + } - try { - const guildCheck = await fetch(guildAPI + userUUID); - var responseGuildID = guildCheck.data.id; - } catch (err) { - var responseGuildID = null; - } + try { + const guildCheck = await fetch(guildAPI + userUUID); + var responseGuildID = guildCheck.data.id; + } catch (err) { + var responseGuildID = null; + } - if (responseGuildID !== hypixelGuildID) { - await user.roles.add(defaultMember, "Verification"); + if (responseGuildID !== hypixelGuildID) { + await user.roles.add(defaultMember, "Verification"); - await interaction.editReply({ - embeds: [ - { - title: interaction.guild.name, - description: " You have successfully verified `" + username + "` with the account `" + hypixelCheck.data.username + "`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - icon_url: interaction.guild.iconURL(), - text: interaction.guild.name + " | Developed by Taken#0002" - } - } - ] - }); - return; - } + await interaction.editReply({ + embeds: [ + { + title: interaction.guild.name, + description: " You have successfully verified `" + username + "` with the account `" + hypixelCheck.data.username + "`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + icon_url: interaction.guild.iconURL(), + text: interaction.guild.name + " | Developed by Taken#0002" + } + } + ] + }); + return; + } - const guildCheck = await fetch(guildAPI + userUUID); - const GuildMembers = await guildCheck.data.members; - const guildRank = GuildMembers.find((member) => member.uuid === hypixelCheck.data.uuid).rank; + const guildCheck = await fetch(guildAPI + userUUID); + const GuildMembers = await guildCheck.data.members; + const guildRank = GuildMembers.find((member) => member.uuid === hypixelCheck.data.uuid).rank; - if (guildRank === "Guild Master" && responseGuildID === hypixelGuildID) { - await user.roles.add(gm, "Verification"); - await user.roles.add(guildRole, "Verification"); - await user.roles.add(guildStaff, "Verification"); - } + if (guildRank === "Guild Master" && responseGuildID === hypixelGuildID) { + await user.roles.add(gm, "Verification"); + await user.roles.add(guildRole, "Verification"); + await user.roles.add(guildStaff, "Verification"); + } - if (guildRank === "Manager" && responseGuildID === hypixelGuildID) { - await user.roles.add(manager, "Verification"); - await user.roles.add(guildRole, "Verification"); - await user.roles.add(guildStaff, "Verification"); - } + if (guildRank === "Manager" && responseGuildID === hypixelGuildID) { + await user.roles.add(manager, "Verification"); + await user.roles.add(guildRole, "Verification"); + await user.roles.add(guildStaff, "Verification"); + } - if (guildRank === "Moderator" && responseGuildID === hypixelGuildID) { - await user.roles.add(moderator, "Verification"); - await user.roles.add(guildRole, "Verification"); - await user.roles.add(guildStaff, "Verification"); - } + if (guildRank === "Moderator" && responseGuildID === hypixelGuildID) { + await user.roles.add(moderator, "Verification"); + await user.roles.add(guildRole, "Verification"); + await user.roles.add(guildStaff, "Verification"); + } - if (guildRank === "Beast" && responseGuildID === hypixelGuildID) { - await user.roles.add(beast, "Verification"); - await user.roles.add(guildRole, "Verification"); - } + if (guildRank === "Beast" && responseGuildID === hypixelGuildID) { + await user.roles.add(beast, "Verification"); + await user.roles.add(guildRole, "Verification"); + } - if (guildRank === "Member" && responseGuildID === hypixelGuildID) { - await user.roles.add(member, "Verification"); - await user.roles.add(guildRole, "Verification"); - } + if (guildRank === "Member" && responseGuildID === hypixelGuildID) { + await user.roles.add(member, "Verification"); + await user.roles.add(guildRole, "Verification"); + } - if (guildRank === "Trial Member" && responseGuildID === hypixelGuildID) { - await user.roles.add(trialmember, "Verification"); - await user.roles.add(guildRole, "Verification"); - } + if (guildRank === "Trial Member" && responseGuildID === hypixelGuildID) { + await user.roles.add(trialmember, "Verification"); + await user.roles.add(guildRole, "Verification"); + } - await user.roles.add(defaultMember, "Verification"); + await user.roles.add(defaultMember, "Verification"); - const newVerify = new verify({ - _id: new mongoose.Types.ObjectId(), - userID: user.id, - uuid: userUUID - }); + const newVerify = new verify({ + _id: new mongoose.Types.ObjectId(), + userID: user.id, + uuid: userUUID + }); - await newVerify.save(); + await newVerify.save(); - await interaction.editReply({ - embeds: [ - { - title: interaction.guild.name, - description: "You have successfully verified `" + username + "` with the account `" + hypixelCheck.data.username + "`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - icon_url: interaction.guild.iconURL(), - text: interaction.guild.name + " | Developed by Taken#0002" - } - } - ] - }); - } -}; + await interaction.editReply({ + embeds: [ + { + title: interaction.guild.name, + description: "You have successfully verified `" + username + "` with the account `" + hypixelCheck.data.username + "`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + icon_url: interaction.guild.iconURL(), + text: interaction.guild.name + " | Developed by Taken#0002" + } + } + ] + }); + } +}; \ No newline at end of file