From e3e91529d7b8177378eb7aaea0fd24744e134fa5 Mon Sep 17 00:00:00 2001 From: rhearmas <34490428+qu-ota@users.noreply.github.com> Date: Sat, 21 Dec 2019 16:38:39 -0500 Subject: [PATCH] minecraft player info --- commands/Information/playerinfo.js | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 commands/Information/playerinfo.js diff --git a/commands/Information/playerinfo.js b/commands/Information/playerinfo.js new file mode 100644 index 0000000..2f8eea3 --- /dev/null +++ b/commands/Information/playerinfo.js @@ -0,0 +1,60 @@ +const got = require('got'); +const cheerio = require('cheerio'); + +exports.run = async (client, message, args, level) => { + if (args.length < 1) { + message.delete(); + return (await message.reply("please provide the username of a player.")).delete(5000); + } + + const username = args[0]; + + const uuid = await getUUID(username); + if (!uuid) { + message.delete(); + return (await message.reply("that player could not be found.")).delete(5000); + } + + message.delete(); + return message.channel.send({ + embed: client.embed('', '', [ + { + name: 'Username', + value: username + }, + { + name: 'UUID', + value: `\`${uuid}\`` + }, + { + name: 'Skin', + value: `[Download](https://crafatar.com/skins/${uuid}.png)` + } + ], { thumbnail: `https://crafatar.com/avatars/${uuid}.png?size=250&overlay=true` }) + }); +}; + +async function getUUID(username) { + const res = await got(`https://mcuuid.net/?q=${username}`); + const $ = cheerio.load(res.body); + const input = $('input')[1]; + + if (!input) { + return; + } + return input.attribs['value']; +} + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: ["mcinfo","minecraftuser"], + permLevel: "User" +}; + +exports.help = { + name: "playerinfo", + category: "Information", + description: "Shows information about a Minecraft player.", + usage: "playerinfo " +}; \ No newline at end of file