-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdeploy-commands.ts
308 lines (293 loc) · 17.9 KB
/
deploy-commands.ts
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
import { SlashCommandBuilder } from '@discordjs/builders';
import { REST } from '@discordjs/rest';
import { Routes } from 'discord-api-types/v9';
require('dotenv').config();
const commands = [
new SlashCommandBuilder().setName('sphelp').setDescription('View commands and information regarding the bot.'),
new SlashCommandBuilder().setName('spitems').setDescription('View list of items'),
new SlashCommandBuilder().setName('spsetamount')
.setDescription('Sets the <amount> that an <item> has in crates inside the <stockpile>')
.addStringOption((option) =>
option.setName("item").setDescription("The item name").setRequired(true)
).addIntegerOption(option =>
option.setName("amount").setDescription("The amount of that item").setRequired(true)
).addStringOption(option =>
option.setName("stockpile").setDescription("The name of the stockpile").setRequired(true).setAutocomplete(true))
,
new SlashCommandBuilder().setName('spsettimeleft')
.setDescription('Sets the time left for a reserve <stockpile> before it expires. NOTE: <time> is a UNIX TIMESTAMP')
.addStringOption((option) =>
option.setName("stockpile").setDescription("The stockpile name").setRequired(true).setAutocomplete(true)
).addIntegerOption(option =>
option.setName("time").setDescription("The time till the reserve stockpile expires. A Unix Timestamp.").setRequired(true))
,
new SlashCommandBuilder().setName('sptarget')
.setDescription('Command to edit the stockpile targets that the regiment (clan) should aim towards')
.addSubcommand(subcommand =>
subcommand
.setName("set")
.setDescription("Sets the target <minimum_amount> that an <item> should have in crates.")
.addStringOption((option) =>
option.setName("item").setDescription("The item name").setRequired(true)
).addIntegerOption(option =>
option.setName("minimum_amount").setDescription("The minimum amount of that item").setRequired(true)
)
.addIntegerOption(option =>
option.setName("maximum_amount").setDescription("The maximum amount of that item").setRequired(false)
).addStringOption((option) =>
option.setName("production_location").setDescription("The place to produce this item. Either 'MPF' or 'Factory'")
.addChoices({ name: "MPF", value: "MPF" }, { name: "Factory", value: "Factory" })
.setRequired(false)
)
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Removes target <item> from the target goals to achieve.")
.addStringOption((option) =>
option.setName("item").setDescription("The item name").setRequired(true)
)
),
new SlashCommandBuilder().setName('spstatus').setDescription('Returns the current info. Optionally filter by targets/group targets/stockpile')
.addStringOption(
(option) => option.setName("filter").setDescription("View a filtered version of spstatus such as viewing only targets ")
.addChoices({ name: "Targets", value: "targets" }, { name: "Group Targets", value: "group_targets" })
.setRequired(false)
)
.addStringOption((option) => option.setName("stockpile_group").setDescription("View targets for a specific <stockpile_group>").setRequired(false))
.addStringOption((option) => option.setName("stockpile").setDescription("View items in a <stockpile> only").setRequired(false).setAutocomplete(true))
,
new SlashCommandBuilder().setName('spsetpassword').setDescription('Sets the password the Stockpiler app uses to update information to the database.')
.addStringOption((option) => option.setName("password").setDescription("The new password").setRequired(true)),
new SlashCommandBuilder().setName('spsetorder').setDescription('Sets the order of a <stockpile> to <order> number in the list')
.addStringOption((option) => option.setName("stockpile").setDescription("The name of the stockpile to set the order of").setRequired(true).setAutocomplete(true))
.addIntegerOption((option) => option.setName("order").setDescription("The order number to set to (1-N), where N is the number of stockpiles in the list").setRequired(true)),
new SlashCommandBuilder().setName('spstockpile').setDescription('Commands to manage stockpiles')
.addSubcommand(subcommand =>
subcommand
.setName("add")
.setDescription("Creates an EMPTY stockpile with name <stockpile>")
.addStringOption((option) => option.setName("stockpile").setDescription("Stockpile name").setRequired(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Deletes stockpile with the name <stockpile>")
.addStringOption((option) => option.setName("stockpile").setDescription("Stockpile name").setRequired(true).setAutocomplete(true))
).addSubcommand(subcommand =>
subcommand
.setName("purge")
.setDescription("Deletes all stockpiles and all their information. This is a destructive and irresvesible action")
),
new SlashCommandBuilder().setName('splogichannel')
.setDescription('Logi channel settings to broadcast the stockpile status.')
.addSubcommand(subcommand =>
subcommand
.setName("set")
.setDescription("Sets the target <channel> that the logi message will be in")
.addChannelOption(option => option.setName("channel").setDescription("The channel the message will be in").setRequired(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Removes logi message from the set channel.")
),
new SlashCommandBuilder().setName('sprole')
.setDescription('Permission settings for roles')
.addSubcommand(subcommand =>
subcommand
.setName("set")
.setDescription("Add <perms> to a specified <role>")
.addStringOption(option => option.setName("perms").setDescription("Can be either 'User' or 'Admin'.")
.setRequired(true)
.addChoices({ name: "User", value: "user" }, { name: "Admin", value: "admin" })
)
.addRoleOption(option => option.setName("role").setDescription("The role to operate on").setRequired(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Remove any perms from a specified <role>")
.addRoleOption(option => option.setName("role").setDescription("The role to operate on").setRequired(true))
),
new SlashCommandBuilder().setName('spuser')
.setDescription('Permission settings for users')
.addSubcommand(subcommand =>
subcommand
.setName("set")
.setDescription("Add <perms> to a specified <user>")
.addStringOption(option => option.setName("perms").setDescription("Can be either 'User' or 'Admin'.")
.setRequired(true)
.addChoices({ name: "User", value: "user" }, { name: "Admin", value: "admin" })
)
.addUserOption(option => option.setName("user").setDescription("The <user> to operate on").setRequired(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Remove any perms from a specified <user>")
.addUserOption(option => option.setName("user").setDescription("The role to operate on").setRequired(true))
),
new SlashCommandBuilder().setName('spnotif')
.setDescription('Stockpile expiry notification settings')
.addSubcommand(subcommand =>
subcommand
.setName("add")
.setDescription("Adds <role> to the stockpile expiry notification list")
.addRoleOption(option => option.setName("role").setDescription("The role to add").setRequired(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Remove the specified <role> from the stockpile expiry notification list")
.addRoleOption(option => option.setName("role").setDescription("The role to remove").setRequired(true))
),
new SlashCommandBuilder().setName('spprettyname')
.setDescription('Stockpile pretty name settings.')
.addSubcommand(subcommand =>
subcommand
.setName("add")
.setDescription("Adds a <pretty_name> to the <stockpile>. Pretty names are alternative names")
.addStringOption(option => option.setName("stockpile").setDescription("The stockpile to add a pretty name to").setRequired(true).setAutocomplete(true))
.addStringOption(option => option.setName("pretty_name").setDescription("The pretty name to add").setRequired(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Removes a pretty name from the <stockpile>. Pretty names are alternative names")
.addStringOption(option => option.setName("stockpile").setDescription("The stockpile to remove a pretty name from").setRequired(true).setAutocomplete(true))
),
/*new SlashCommandBuilder().setName('spscan')
.setDescription('Scan a screenshot of a stockpile')
.addAttachmentOption(option => option.setName("screenshot").setDescription("Screenshot of the stockpile to scan").setRequired(true)),*/
new SlashCommandBuilder().setName('spcode')
.setDescription('Set/remove stockpile codes')
.addSubcommand(subcommand =>
subcommand
.setName("add")
.setDescription("Adds a <code> to a <stockpile>")
.addStringOption(option => option.setName("stockpile").setDescription("The stockpile to add a code to").setRequired(true).setAutocomplete(true))
.addStringOption(option => option.setName("code").setDescription("The stockpile code to add").setRequired(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Removes a code from the <stockpile>")
.addStringOption(option => option.setName("stockpile").setDescription("The stockpile to remove a code from").setRequired(true).setAutocomplete(true))
),
new SlashCommandBuilder().setName('sploc')
.setDescription('Set/remove stockpile locations or location list')
.addSubcommand(subcommand =>
subcommand
.setName("add")
.setDescription("Adds a <location> to a <stockpile>")
.addStringOption(option => option.setName("stockpile").setDescription("The stockpile to add a location to").setRequired(true).setAutocomplete(true))
.addStringOption(option => option.setName("location").setDescription("The location to set to").setRequired(true).setAutocomplete(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Removes a location from the <stockpile>")
.addStringOption(option => option.setName("stockpile").setDescription("The stockpile to remove a location from").setRequired(true).setAutocomplete(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("list")
.setDescription("List all the locations and their location codes")
),
new SlashCommandBuilder().setName('spfind')
.setDescription('Finds the <item> specified in the stockpiles')
.addStringOption((option) =>
option.setName("item").setDescription("The item name").setRequired(true)
)
,
new SlashCommandBuilder().setName('spdisabletime')
.setDescription('Disables the time-check feature on Storeman Bot')
.addBooleanOption((option) =>
option.setName("disable").setDescription("True to disable time-check and false to enable time-check").setRequired(true)
),
new SlashCommandBuilder().setName('sprefresh')
.setDescription('Refreshes the timer of ALL stockpiles, or an individual <stockpile> if a name is provided.')
.addStringOption((option) =>
option.setName("stockpile").setDescription("The stockpile name").setRequired(false).setAutocomplete(true)
),
new SlashCommandBuilder().setName('spgroup')
.setDescription('Commands for creating a target list for a list of selected stockpiles')
.addSubcommand(subcommand =>
subcommand
.setName("create")
.setDescription("Creates a stockpile group with <name>")
.addStringOption(option => option.setName("name").setDescription("The name of the stockpile group to create").setRequired(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("remove")
.setDescription("Removes stockpile group with <name>")
.addStringOption(option => option.setName("name").setDescription("The name of the stockpile group to remove").setRequired(true).setAutocomplete(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("addstockpile")
.setDescription("Adds the stockpile with <stockpileName> to the stockpile group with <name>")
.addStringOption(option => option.setName("name").setDescription("The name of the stockpile group to add to").setRequired(true).setAutocomplete(true))
.addStringOption(option => option.setName("stockpile_name").setDescription("The name of the stockpile to add to the stockpile group").setRequired(true).setAutocomplete(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("removestockpile")
.setDescription("Removes the stockpile with <stockpileName> from the stockpile group with <name>")
.addStringOption(option => option.setName("name").setDescription("The name of the stockpile group to remove from").setRequired(true).setAutocomplete(true))
.addStringOption(option => option.setName("stockpile_name").setDescription("The name of the stockpile to remove from the stockpile group").setRequired(true).setAutocomplete(true))
)
.addSubcommand(subcommand =>
subcommand
.setName("settarget")
.setDescription("Sets targets for the stockpile group with <name>")
.addStringOption(option => option.setName("name").setDescription("The name of the stockpile group to modify targets").setRequired(true).setAutocomplete(true))
.addStringOption((option) =>
option.setName("item").setDescription("The item name").setRequired(true)
).addIntegerOption(option =>
option.setName("minimum_amount").setDescription("The minimum amount of that item").setRequired(true)
)
.addIntegerOption(option =>
option.setName("maximum_amount").setDescription("The maximum amount of that item").setRequired(false)
).addStringOption((option) =>
option.setName("production_location").setDescription("The place to produce this item. Either 'MPF' or 'Factory'")
.addChoices({ name: "MPF", value: "MPF" }, { name: "Factory", value: "Factory" })
.setRequired(false)
)
).addSubcommand(subcommand =>
subcommand
.setName("removetarget")
.setDescription("Removes the target <item> from stockpile group with <name>")
.addStringOption(option => option.setName("name").setDescription("The name of the stockpile group to remove from").setRequired(true).setAutocomplete(true))
.addStringOption(option => option.setName("item").setDescription("The name of the item to remove from targets").setRequired(true))
)
].map(command => command.toJSON())
const rest = new REST({ version: '10' }).setToken(<string>process.env.STOCKPILER_TOKEN);
const insertCommands = async (guild_id?: string) => {
if (guild_id) {
await rest.put(Routes.applicationGuildCommands(<string>process.env.STOCKPILER_CLIENT_ID, <string>guild_id), { body: commands })
.then(() => console.log('Successfully registered application commands to guild with ID: ' + guild_id))
.catch(console.error);
}
else {
// Guild based commands for development
// ClientId is the bot "Copy ID"
// GuildId is the server "Copy ID"
if (process.env.STOCKPILER_GUILD_ID && process.env.STOCKPILER_GUILD_ID !== "") {
await rest.put(Routes.applicationGuildCommands(<string>process.env.STOCKPILER_CLIENT_ID, <string>process.env.STOCKPILER_GUILD_ID), { body: commands })
.then(() => console.log('Successfully registered application commands to guild.'))
.catch(console.error);
}
// Global commands for deployment (Global commands take at least 1 hour to update after each change)
else {
await rest.put(
Routes.applicationCommands(<string>process.env.STOCKPILER_CLIENT_ID),
{ body: commands },
).then(() => console.log('Successfully registered application commands globally.'))
.catch(console.error);
}
}
}
export { insertCommands }