aboutsummaryrefslogtreecommitdiff
path: root/commandManager.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 /commandManager.js
parentf2d535d6979cf6cb04a7245925a5bcf71bee2c67 (diff)
downloadcoleweight-1.5.5.tar.gz
coleweight-1.5.5.tar.bz2
coleweight-1.5.5.zip
1.5.4 Fixed bugs (changelog in discord)v1.5.5
Diffstat (limited to 'commandManager.js')
-rw-r--r--commandManager.js45
1 files changed, 7 insertions, 38 deletions
diff --git a/commandManager.js b/commandManager.js
index 9acc4e4..108559f 100644
--- a/commandManager.js
+++ b/commandManager.js
@@ -1,4 +1,3 @@
-import axios from '../axios'
import { help } from "./commands/help.js"
import { reload } from "./commands/reload.js"
import { setkey } from "./commands/setkey.js"
@@ -8,12 +7,12 @@ import { toggle } from "./commands/toggle.js"
import { leaderboard } from "./commands/leaderboard.js"
import { update } from './commands/update'
import { openCwGui } from './gui/cwGui'
-import Settings from "./gui/settingsGui";
-import constants from './util/constants.js'
-
-const PREFIX = constants.PREFIX
+import { fetchDiscord } from './commands/fetchDiscord'
+import { findColeweight } from './commands/findColeweight'
+import Settings from "./gui/settingsGui"
register("command", (arg, arg2, arg3) => {
+ if (arg == undefined) {findColeweight(arg); return}
switch(arg.toLowerCase())
{
case "setkey":
@@ -47,25 +46,11 @@ register("command", (arg, arg2, arg3) => {
Settings.openGUI()
break
default:
- ChatLib.chat(`${constants.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 coleweightMessage = new TextComponent(`${constants.PREFIX}&b${res.data.rank}. ${res.data.name}&b's Coleweight: ${res.data.coleweight} (Top &l${res.data.percentile}&b%)`)
- .setHoverValue(`&fExperience&f: &a${res.data.exp}\n&fPowder&f: &a${res.data.pow}\n&fCollection&f: &a${res.data.col}\n&fMiscellaneous&f: &a${res.data.bes + res.data.nuc}`)
- ChatLib.chat(coleweightMessage)
- })
- .catch(err => {
- ChatLib.chat(`${PREFIX}&eError. (api may be down)`)
- })
+ findColeweight(arg)
}
}).setTabCompletions((args) => {
let output = [],
- commands = ["setkey", "help", "gui", "toggle", "throne", "spiral", "reload", "leaderboard", "settings"]
+ commands = ["setkey", "help", "move", "toggle", "throne", "spiral", "reload", "leaderboard", "settings"]
if(args[0].length == 0 || args[0] == undefined)
output = commands
@@ -86,23 +71,7 @@ register("command", (arg, arg2, arg3) => {
}).setName("cw").setAliases(["coleweight"])
register("command", (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! `)
- });
+ fetchDiscord(arg)
}).setTabCompletions((args) => {
let players = World.getAllPlayers().map((p) => p.getName())
.filter((n) =>