aboutsummaryrefslogtreecommitdiff
path: root/commands/fetchDiscord.js
diff options
context:
space:
mode:
authorNinjune <enderknight537@gmail.com>2022-11-08 13:30:41 -0600
committerNinjune <enderknight537@gmail.com>2022-11-08 13:30:41 -0600
commite72c42345ef32fe9f3eeaf92844c0b77f175fac6 (patch)
treea67ca92dfd4bbd5df1fcdf1beccad9bc0ba36da8 /commands/fetchDiscord.js
parentf2d535d6979cf6cb04a7245925a5bcf71bee2c67 (diff)
downloadcoleweight-e72c42345ef32fe9f3eeaf92844c0b77f175fac6.tar.gz
coleweight-e72c42345ef32fe9f3eeaf92844c0b77f175fac6.tar.bz2
coleweight-e72c42345ef32fe9f3eeaf92844c0b77f175fac6.zip
1.5.4 Fixed bugs (changelog in discord)v1.5.5
Diffstat (limited to 'commands/fetchDiscord.js')
-rw-r--r--commands/fetchDiscord.js26
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! `)
+ })
+}
+