aboutsummaryrefslogtreecommitdiff
path: root/commandManager.js
blob: 0985e286d22ea9500493239d9644ef3a8e737c37 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import { openTimerGui } from "./render/timerGui.js"
import { openPowderGui } from "./render/powertrackerGui"
import { openCwGui } from "./render/cwGui"
import { help } from "./commands/help"
import { reload } from "./commands/reload"
import { setkey } from "./commands/setkey"
import { spiral } from "./commands/spiral"
import { throne } from "./commands/throne"
import { yog } from "./commands/yog"
import { leaderboard } from "./commands/leaderboard"
import { update } from "./commands/update"
import { fetchDiscord } from "./commands/fetchDiscord"
import { findColeweight } from "./commands/findColeweight"
import { claim } from "./commands/claim"
import { tick } from "./commands/tick"
import { time } from "./commands/time"
import { info } from "./commands/info"
import Settings from "./settings"
import constants from "./util/constants"
import { clearLobbies } from "./commands/markingLobbies"

register("command", (arg, arg2, arg3) => {
    if (arg == undefined) {findColeweight(arg); return}
    switch(arg.toLowerCase())
    {
        case "setkey":
            setkey(arg2)
            break
        case "help":
            help()
            break
        case "move":
            if (arg2 == undefined) {ChatLib.chat(`${constants.PREFIX}&cNot enough arguments.`); return}
            switch(arg2.toLowerCase())
            {
                case "coleweight":
                    openCwGui()
                    break
                case "powdertracker":
                    openPowderGui()
                    break
                case "time":
                case "timer":
                    openTimerGui()
                    break
                default:
                    ChatLib.chat(`${constants.PREFIX}&cNo such gui as '${arg2}'.`)
            }
            break
        case "throne":
            throne(arg2)
            break
        case "spiral":
            spiral(arg2)
            break
        case "reload":
            reload()
            break
        case "leaderboard":
            leaderboard(arg2, arg3)
            break
        case "update":
            update()
            break
        case "config":
        case "settings":
            Settings.openGUI()
            break
        case "claim":
            claim(arg2)
            break
        case "powdertrackersync":
            updateDisplay()
            break
        case "tick":
            tick(arg2, arg3)
            break
        case "time":
            time()
            break
        case "info":
            info()
            break
        case "clearlobbies":
            clearLobbies()
            break
        case "yog":
            yog(arg2)
            break
        default:
            findColeweight(arg)
    }
}).setTabCompletions((args) => {
    let output = [],
     commands = ["setkey", "help", "move", "toggle", "throne", "spiral", "reload", "leaderboard", "settings", "claim", "tick", "time", "info", "clearlobbies", "yog"]
    
    if(args[0].length == 0 || args[0] == undefined)
        output = commands
    else
    {
        for(let i = 0; i < commands.length; i++)
        {
            for(let j = 0; j < args[0].length; j++)
            {
                if(commands[i][j] != args[0][j])
                    break
                else if(j == args[0].length - 1)
                    output.push(commands[i])
            }
        }
    }
    return output
}).setName("cw").setAliases(["coleweight"])

register("command", (arg) => {
    fetchDiscord(arg)
}).setTabCompletions((args) => {
    let players = World.getAllPlayers().map((p) => p.getName())
    .filter((n) =>
      n.toLowerCase().startsWith(args.length ? args[0].toLowerCase() : "")
    )
    .sort()
        
    return players
}).setName("fetchdiscord").setAliases(["fdiscord"]);