-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcommandManager.js
122 lines (101 loc) · 3.38 KB
/
commandManager.js
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
import settings from "./settings"
import constants from "./util/constants"
let commands = [],
commandNames = [],
helpCommands = {info: [], settings: [], waypoints: [], miscellaneous: []}
export function registerCommand(command)
{
commands.push(command)
commandNames.push(command.aliases[0])
if(command.showInHelp ?? true)
helpCommands[command.category].push({name: command.aliases[0], description: command.description, options: command.options})
}
export default helpCommands
register("command", (...args) => {
let stop = false
if (args == undefined || args[0] == undefined) { settings.openGUI(); return }
commands.forEach(command => {
if((command.cw ?? true) && command.aliases.includes(args[0].toString().toLowerCase()))
{
command.execute(args)
stop = true
}
})
if(!stop) ChatLib.chat(`${constants.PREFIX}&bUnknown command. Type "/cw help" to see all commands.`)
}).setTabCompletions((args) => {
let output = []
if(args[0].length == 0 || args[0] == undefined)
return commandNames
if(args[1] == undefined)
output = findTabOutput(args[0], commandNames)
commands.forEach(command => {
if(command.aliases.includes(args[0].toLowerCase()) && command.subcommands != undefined)
{
for(let i = 0; i < command.subcommands.length && i <= args.length-1; i++)
output = findTabOutput(args[i+1], command.subcommands[i])
}
})
if(output.length == 0)
output = findTabOutput(args[0], commandNames)
return output
}).setName("cw").setAliases(["coleweight"])
register("command", (...args) => {
ChatLib.command(`cw fetchdiscord ${args[0]}`, true)
}).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"])
function findTabOutput(input, options)
{
let output = []
if(input == undefined || input == "") return options
options.forEach(option => {
for(let char = 0; char < input.length; char++)
{
if(option[char] != input[char])
break
else if(char == input.length - 1)
output.push(option)
}
})
return output
}
// command registering
import "./commands/coords/automatons"
import "./commands/coords/divans"
import "./commands/coords/spiral"
import "./commands/coords/temple"
import "./commands/coords/throne"
import "./commands/coords/yog"
import "./commands/calculate.js"
import "./commands/config"
import "./commands/coords.js"
import "./commands/credits"
import "./commands/cw"
import "./commands/deleteroute"
import "./commands/drawLine"
import "./commands/fetchDiscord"
import "./commands/gemstone"
import "./commands/help"
import "./commands/import"
import "./commands/info"
import "./commands/leaderboard"
import "./commands/markingLobbies"
import "./commands/miningtest"
import "./commands/move"
import "./commands/optimize"
import "./commands/ordered"
import "./commands/quickswitch"
import "./commands/rankcolor"
import "./commands/reload"
import "./commands/resetabilities"
import "./commands/setkey"
import "./commands/stopwatch"
import "./commands/structure"
import "./commands/timer"
import "./commands/track"
import "./commands/waypoints"