aboutsummaryrefslogtreecommitdiff
path: root/commands/fetchDiscord.js
blob: f44c385e86dfdc2b272a3873b96026d815b05765 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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! `)
        })
}