From b34fb3af49f3d3b61feedf4152b63fe2e7f8f3fd Mon Sep 17 00:00:00 2001 From: Taken Date: Sun, 2 Apr 2023 17:46:24 +0200 Subject: [PATCH] Adding list all verified members --- commands/devel.js | 30 ++++++++++++++++++++++-- commands/whois.js | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 commands/whois.js diff --git a/commands/devel.js b/commands/devel.js index 0dc84ee..1645f3d 100644 --- a/commands/devel.js +++ b/commands/devel.js @@ -33,6 +33,7 @@ module.exports = { const user = interaction.user; const userMentioned = userMention(user.id); const guild = interaction.guild; + const embedColor = Number(color.replace("#", "0x")); if (subcommand === 'dbclearnonguildmembers') { @@ -69,8 +70,33 @@ module.exports = { if (subcommand === 'listallverified') { - await interaction.reply({ content: 'In development', ephemeral: true }) - return + const verifiedUsers = await verify.find() + const mojang = "https://api.mojang.com/user/profile/" + + let embed = new EmbedBuilder() + .setTitle(guild.name) + .setColor(embedColor) + .setDescription('List of all verified users') + + for (let i = 0; i < verifiedUsers.length; i++) { + + const user = verifiedUsers[i]; + + const userCheck = await fetch(mojang + user.uuid); + const ign = userCheck.data.name; + + const mentionedUser = userMention(user.userID); + + embed.addFields({ + name: "**IGN:** " + ign, + value: "**Discord:** " + mentionedUser + }) + + } + + await interaction.reply({ + embeds: [embed] + }) } diff --git a/commands/whois.js b/commands/whois.js new file mode 100644 index 0000000..e730a61 --- /dev/null +++ b/commands/whois.js @@ -0,0 +1,58 @@ +const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); +const { color } = require('../config/options.json'); +const verify = require('../schemas/verifySchema.js'); +const fetch = require('axios'); + +module.exports = { + name: 'whois', + description: 'Get\'s the ign of a user.', + type: 'slash', + + data: new SlashCommandBuilder() + .setName('whois') + .setDescription('Get\'s the ign of a user.') + .addUserOption(option => + option + .setName('user') + .setDescription('The user to get the ign of.') + .setRequired(true)) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), + + async execute(interaction) { + + await interaction.deferReply(); + + const user = interaction.options.getUser('user'); + const embedColor = Number(color.replace("#", "0x")); + const mojang = "https://api.mojang.com/user/profile/" + const minotar = "https://minotar.net/helm/"; + + const verifiedUser = await verify.findOne({ userID: user.id }); + + if (!verifiedUser) { + interaction.editReply({ content: 'This user has not verified their account.' }); + return + } + + const userCheck = await fetch(mojang + verifiedUser.uuid); + const ign = userCheck.data.name; + const head = minotar + ign; + + await interaction.editReply({ + embeds: [{ + title: interaction.guild.name, + description: "**User:** " + userMention(user.id) + "\n**IGN:** " + ign, + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by: @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + + } +}; \ No newline at end of file