aboutsummaryrefslogtreecommitdiff
path: root/commands/findColeweight.js
blob: a2c51561260cfbd6c6edb467aa5c2be64796a5dc (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
27
28
29
30
import axios from "../../axios"
import { findGriefer } from "../chat/grieferTrack"
import settings from "../settings"
import constants from "../util/constants"
const PREFIX = constants.PREFIX

export function findColeweight(arg)
{
    ChatLib.chat(`${PREFIX}Finding Coleweight!`)
    let username = ""
    if(arg == undefined) 
        username = Player.getUUID()
    else 
        username = arg 
    axios.get(`https://ninjune.dev/api/coleweight?username=${username}`)
        .then(res => {
            let griefer = findGriefer(username), coleweightMessage
            console.log(griefer.offenses)
            if(griefer.found)
                coleweightMessage = new TextComponent(`${PREFIX}&b${res.data.rank}. ${res.data.name}&b's Coleweight: ${res.data.coleweight} (Top &l${res.data.percentile}&b%) &c&lGriefed ${griefer.offences} time(s) &c(last grief: &a${griefer.dateObj.toString().slice(4, 15)}&c)`)
            else
                coleweightMessage = new TextComponent(`${PREFIX}&b${res.data.rank}. ${res.data.name}&b's Coleweight: ${res.data.coleweight} (Top &l${res.data.percentile}&b%)`)
            coleweightMessage.setHoverValue(`&fExperience&f: &a${Math.round(res.data.experience.total*100) / 100}\n&fPowder&f: &a${Math.round(res.data.powder.total*100) / 100}\n&fCollection&f: &a${Math.round(res.data.collection.total*100) / 100}\n&fMiscellaneous&f: &a${Math.round(res.data.miscellaneous.total*100) / 100}`)
            ChatLib.chat(coleweightMessage)
        }) 
        .catch(err => {
            if(settings.debug) ChatLib.chat(`${PREFIX}&eError. (api may be down) ${err}`)
            else ChatLib.chat(`${PREFIX}&eError. (api may be down)`)
        })
}