diff options
author | Ninjune x <enderknight537@gmail.com> | 2022-11-17 16:56:06 -0600 |
---|---|---|
committer | Ninjune x <enderknight537@gmail.com> | 2022-11-17 16:56:06 -0600 |
commit | fb63481d2c5b7b468df6c5ebdee30178bc9155f5 (patch) | |
tree | 3ec467f8acb9594c7b5547426a3b640856dc7e37 /commands/fetchDiscord.js | |
parent | 9085ac77ce364572b14f132b64ead5cde2194607 (diff) | |
download | coleweight-fb63481d2c5b7b468df6c5ebdee30178bc9155f5.tar.gz coleweight-fb63481d2c5b7b468df6c5ebdee30178bc9155f5.tar.bz2 coleweight-fb63481d2c5b7b468df6c5ebdee30178bc9155f5.zip |
1.6.0 Changelog in releasesv1.6.1
Diffstat (limited to 'commands/fetchDiscord.js')
-rw-r--r-- | commands/fetchDiscord.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/commands/fetchDiscord.js b/commands/fetchDiscord.js new file mode 100644 index 0000000..f44c385 --- /dev/null +++ b/commands/fetchDiscord.js @@ -0,0 +1,26 @@ +import axios from "../../axios" +import constants from "../util/constants" +const PREFIX = constants.PREFIX + +export function fetchDiscord(arg) +{ + if(arg == undefined) { ChatLib.chat(`${PREFIX}&eRequires a username!`); return } + + axios.get(`https://api.ashcon.app/mojang/v2/user/${arg}`) + .then(res => { + let uuid = res.data.uuid + axios.get(`https://api.hypixel.net/player?key=${constants.data.api_key}&uuid=${uuid}`) + .then(res2 => { + let discordMessage = new TextComponent(`${PREFIX}&a${res.data.username}'s Discord: `) + ChatLib.chat(discordMessage); + ChatLib.chat(`&b${res2.data.player.socialMedia.links.DISCORD}`) + }) + .catch(err => { + ChatLib.chat(`${PREFIX}&eNo discord linked :( (or no key linked)`) + }) + }) + .catch(err => { + ChatLib.chat(`${PREFIX}&eInvalid name! `) + }) +} + |