/[sudobot]/branches/2.x/deploy-commands.js
ViewVC logotype

Contents of /branches/2.x/deploy-commands.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: text/javascript
File size: 23781 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 #!/bin/node
2
3 const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('@discordjs/builders');
4 const { REST } = require('@discordjs/rest');
5 const { Routes } = require('discord-api-types/v9');
6 const { config } = require('dotenv');
7 const { existsSync } = require('fs');
8 const { Permissions, ApplicationCommand } = require('discord.js');
9 const path = require('path');
10 const { ActivityType, ApplicationCommandType } = require('discord-api-types/v10');
11
12 if (existsSync(path.join(__dirname, '.env'))) {
13 config();
14 }
15 else {
16 process.env.ENV = 'prod';
17 }
18
19 const { CLIENT_ID, GUILD_ID, TOKEN } = process.env;
20
21 let commands = [
22 // SETTINGS
23 new SlashCommandBuilder().setName('help').setDescription('A short documentation about the commands')
24 .addStringOption(option => option.setName('command').setDescription("The command")),
25 new SlashCommandBuilder().setName('about').setDescription('Show information about the bot'),
26 new SlashCommandBuilder().setName('eval').setDescription('Execute raw code in the runtime environment')
27 .addStringOption(option => option.setName('code').setDescription('The code to be executed').setRequired(true)),
28 new SlashCommandBuilder().setName('system').setDescription('Show the system status'),
29 new SlashCommandBuilder().setName('restart').setDescription('Restart the system'),
30 new SlashCommandBuilder().setName('setstatus').setDescription('Set status for the bot system')
31 .addStringOption(option => option.setName('activity').setDescription('The activity').setRequired(true))
32 .addStringOption(option => option.setName('status').setDescription('The status').setChoices(...[
33 {
34 name: 'Online',
35 value: 'online'
36 },
37 {
38 name: 'Idle',
39 value: 'idle'
40 },
41 {
42 name: 'DND',
43 value: 'dnd'
44 },
45 {
46 name: 'Invisible',
47 value: 'invisible'
48 }
49 ]))
50 .addStringOption(option => option.setName('type').setDescription('The activity type').setChoices(...[
51 {
52 name: 'Playing',
53 value: 'PLAYING'
54 },
55 {
56 name: 'Watching',
57 value: 'WATCHING'
58 },
59 {
60 name: 'Competing',
61 value: 'COMPETING'
62 }
63 ])),
64 new SlashCommandBuilder().setName('config').setDescription('View/change the system settings for this server')
65 .addStringOption(option => option.setName('key').setDescription('The setting key (e.g. spam_filter.enabled)').setRequired(true))
66 .addStringOption(option => option.setName('value').setDescription('New value for the setting')),
67
68 // INFORMATION
69 new SlashCommandBuilder().setName('stats').setDescription('Show the server statistics'),
70 new SlashCommandBuilder().setName('profile').setDescription('Show someone\'s profile')
71 .addUserOption(option => option.setName('user').setDescription('The user')),
72 new SlashCommandBuilder().setName('avatar').setDescription('Show someone\'s avatar')
73 .addUserOption(option => option.setName('user').setDescription('The user')),
74 new SlashCommandBuilder().setName('rolelist').setDescription('List all roles or show info about a role')
75 .addRoleOption(option => option.setName('role').setDescription('The role'))
76 .addIntegerOption(option => option.setName('page').setDescription('The page number')),
77
78 // AUTOMATION
79 new SlashCommandBuilder().setName('ballot').setDescription('Ballot engine')
80 .addSubcommand(subcommand =>
81 subcommand
82 .setName('create')
83 .setDescription('Send a ballot/poll message for collecting votes')
84 .addStringOption(option => option.setName('content').setDescription('Message content').setRequired(true))
85 .addBooleanOption(option => option.setName('anonymous').setDescription('If this is set to true then the syetem won\'t show your username'))
86 .addChannelOption(option => option.setName('channel').setDescription('The channel where the message should be sent')))
87 .addSubcommand(subcommand =>
88 subcommand
89 .setName('view')
90 .setDescription('Get information/stats about a ballot')
91 .addIntegerOption(option => option.setName('id').setDescription('The ballot ID'))),
92
93 new SlashCommandBuilder().setName('embed').setDescription('Make an embed')
94 .addSubcommand(subcmd =>
95 subcmd.setName("send").setDescription("Make and send an embed")
96 .addStringOption(option => option.setName('author_name').setDescription('The embed author name'))
97 .addStringOption(option => option.setName('author_iconurl').setDescription('The embed author icon URL'))
98 .addStringOption(option => option.setName('title').setDescription('The embed title'))
99 .addStringOption(option => option.setName('description').setDescription('The embed description'))
100 .addStringOption(option => option.setName('thumbnail').setDescription('The embed thumbnail URL'))
101 .addStringOption(option => option.setName('image').setDescription('The embed image attachment URL'))
102 .addStringOption(option => option.setName('video').setDescription('The embed video attachment URL'))
103 .addStringOption(option => option.setName('footer_text').setDescription('The embed footer text'))
104 .addStringOption(option => option.setName('footer_iconurl').setDescription('The embed footer icon URL'))
105 .addStringOption(option => option.setName('timestamp').setDescription('The embed timestamp, use \'current\' to set current date'))
106 .addStringOption(option => option.setName('color').setDescription('The embed color (default is #007bff)'))
107 .addStringOption(option => option.setName('url').setDescription('The embed URL'))
108 .addStringOption(option => option.setName('fields').setDescription('The embed fields, should be in `Field 1: Value 1, Field 2: Value 2` format'))
109 )
110 .addSubcommand(subcmd =>
111 subcmd.setName("schema").setDescription("Make and send an embed schema representation")
112 .addStringOption(option => option.setName('author_name').setDescription('The embed author name'))
113 .addStringOption(option => option.setName('author_iconurl').setDescription('The embed author icon URL'))
114 .addStringOption(option => option.setName('title').setDescription('The embed title'))
115 .addStringOption(option => option.setName('description').setDescription('The embed description'))
116 .addStringOption(option => option.setName('thumbnail').setDescription('The embed thumbnail URL'))
117 .addStringOption(option => option.setName('image').setDescription('The embed image attachment URL'))
118 .addStringOption(option => option.setName('video').setDescription('The embed video attachment URL'))
119 .addStringOption(option => option.setName('footer_text').setDescription('The embed footer text'))
120 .addStringOption(option => option.setName('footer_iconurl').setDescription('The embed footer icon URL'))
121 .addStringOption(option => option.setName('timestamp').setDescription('The embed timestamp, use \'current\' to set current date'))
122 .addStringOption(option => option.setName('color').setDescription('The embed color (default is #007bff)'))
123 .addStringOption(option => option.setName('url').setDescription('The embed URL'))
124 .addStringOption(option => option.setName('fields').setDescription('The embed fields, should be in `Field 1: Value 1, Field 2: Value 2` format'))
125 )
126 .addSubcommand(subcmd =>
127 subcmd.setName("build").setDescription("Build an embed from schema")
128 .addStringOption(option => option.setName('json_schema').setDescription('The embed JSON schema'))
129 ),
130
131 new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'),
132
133 new SlashCommandBuilder().setName('schedule').setDescription('Schedule a message for sending later')
134 .addStringOption(option => option.setName('time').setDescription('The time interval').setRequired(true))
135 .addStringOption(option => option.setName('content').setDescription('Message content').setRequired(true))
136 .addChannelOption(option => option.setName('channel').setDescription('The channel where the message should be sent')),
137
138 new SlashCommandBuilder().setName('expire').setDescription('Expire (delete) a message after a certain amount of time')
139 .addStringOption(option => option.setName('time').setDescription('The time interval').setRequired(true))
140 .addStringOption(option => option.setName('content').setDescription('Message content').setRequired(true))
141 .addChannelOption(option => option.setName('channel').setDescription('The channel where the message should be sent')),
142
143 new SlashCommandBuilder().setName('expiresc').setDescription('Schedule and expire (delete) a message after a certain amount of time')
144 .addStringOption(option => option.setName('send-after').setDescription('The time after the message should be sent').setRequired(true))
145 .addStringOption(option => option.setName('delete-after').setDescription('The time after the message should be deleted').setRequired(true)) // (the system will start counting this after the message gets sent)
146 .addStringOption(option => option.setName('content').setDescription('Message content').setRequired(true))
147 .addChannelOption(option => option.setName('channel').setDescription('The channel where the message should be sent')),
148
149 // FUN
150 new SlashCommandBuilder().setName('cat').setDescription('Fetch a random kitty image'),
151
152 new SlashCommandBuilder().setName('dog').setDescription('Fetch a random doggy image'),
153
154 new SlashCommandBuilder().setName('joke').setDescription('Fetch a random joke from the Joke API'),
155
156 new SlashCommandBuilder().setName('httpcat').setDescription('Fetch a funny cat meme associated with an HTTP status code')
157 .addIntegerOption(option => option.setName('status').setDescription('The HTTP status Code').setRequired(true).setMinValue(100).setMaxValue(599)),
158
159 new SlashCommandBuilder().setName('httpdog').setDescription('Fetch a funny dog meme associated with an HTTP status code')
160 .addIntegerOption(option => option.setName('status').setDescription('The HTTP status Code').setRequired(true).setMinValue(100).setMaxValue(599)),
161
162 new SlashCommandBuilder().setName('pixabay').setDescription('Search & fetch images from the Pixabay API')
163 .addSubcommand(subcommand =>
164 subcommand
165 .setName('image')
166 .setDescription('Get any type of image')
167 .addStringOption(option => option.setName('query').setDescription('Search query')))
168 .addSubcommand(subcommand =>
169 subcommand
170 .setName('photo')
171 .setDescription('Get photos')
172 .addStringOption(option => option.setName('query').setDescription('Search query')))
173 .addSubcommand(subcommand =>
174 subcommand
175 .setName('illustration')
176 .setDescription('Get illustrations')
177 .addStringOption(option => option.setName('query').setDescription('Search query')))
178 .addSubcommand(subcommand =>
179 subcommand
180 .setName('vector')
181 .setDescription('Get vectors')
182 .addStringOption(option => option.setName('query').setDescription('Search query'))),
183
184 // UTILS
185 new SlashCommandBuilder().setName('snippet').setDescription('Snippets are instant custom messages')
186 .addSubcommand(subcommand =>
187 subcommand
188 .setName('get')
189 .setDescription('Get a snippet')
190 .addStringOption(option => option.setName('name').setDescription('The snippet name').setRequired(true)))
191 .addSubcommand(subcommand =>
192 subcommand
193 .setName('create')
194 .setDescription('Create a snippet')
195 .addStringOption(option => option.setName('name').setDescription('The snippet name').setRequired(true))
196 .addStringOption(option => option.setName('content').setDescription('Snippet message content').setRequired(true))
197 .addAttachmentOption(option => option.setName('file').setDescription('Snippet message file')))
198 .addSubcommand(subcommand =>
199 subcommand
200 .setName('rename')
201 .setDescription('Rename a snippet')
202 .addStringOption(option => option.setName('old-name').setDescription('The old snippet name').setRequired(true))
203 .addStringOption(option => option.setName('new-name').setDescription('The new name').setRequired(true)))
204 .addSubcommand(subcommand =>
205 subcommand
206 .setName('delete')
207 .setDescription('Delete a snippet')
208 .addStringOption(option => option.setName('name').setDescription('The snippet name').setRequired(true))),
209
210 new SlashCommandBuilder().setName('afk').setDescription('Set your AFK status')
211 .addStringOption(option => option.setName('reason').setDescription("The reason for going AFK")),
212
213 new SlashCommandBuilder().setName('hash').setDescription('Generate hash for a string (text) data')
214 .addStringOption(option => option.setName('content').setDescription("The content to be hashed").setRequired(true))
215 .addStringOption(option =>
216 option
217 .setName('algorithm')
218 .setDescription("Hash algorithm")
219 .setChoices(
220 {
221 name: 'SHA1',
222 value: 'sha1'
223 },
224 {
225 name: 'SHA256',
226 value: 'sha256'
227 },
228 {
229 name: 'SHA512',
230 value: 'sha512'
231 },
232 {
233 name: 'MD5',
234 value: 'md5'
235 },
236 )
237 )
238 .addStringOption(option =>
239 option
240 .setName('digest')
241 .setDescription("Digest mode")
242 .setChoices(
243 {
244 name: 'HEX',
245 value: 'hex'
246 },
247 {
248 name: 'Base64',
249 value: 'base64'
250 },
251 {
252 name: 'Base64 URL',
253 value: 'base64url'
254 },
255 )
256 ),
257
258 new SlashCommandBuilder().setName('announce').setDescription('Announce something')
259 .addStringOption(option => option.setName('content').setDescription("The announcemnt message content")),
260
261 // MODERATION
262 new SlashCommandBuilder().setName('antijoin').setDescription('Enable antijoin system which will kick any new users joining the server'),
263
264 new SlashCommandBuilder().setName('ban').setDescription('Ban a user')
265 .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
266 .addStringOption(option => option.setName('reason').setDescription("The reason for banning this user"))
267 .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user").setMinValue(0).setMaxValue(7)),
268
269 new SlashCommandBuilder().setName('softban').setDescription('Softban a user')
270 .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
271 .addStringOption(option => option.setName('reason').setDescription("The reason for softbanning this user"))
272 .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user (default is 7)").setMinValue(0).setMaxValue(7)),
273
274 new SlashCommandBuilder().setName('tempban').setDescription('Temporarily ban a user')
275 .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
276 .addStringOption(option => option.setName('time').setDescription("TBan duration").setRequired(true))
277 .addStringOption(option => option.setName('reason').setDescription("The reason for softbanning this user"))
278 .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user (default is 7)").setMinValue(0).setMaxValue(7)),
279
280 new SlashCommandBuilder().setName('massban').setDescription('Ban multiple users')
281 .addStringOption(option => option.setName('users').setDescription("The user IDs (separated by spaces)").setRequired(true))
282 .addStringOption(option => option.setName('reason').setDescription("The reason for banning"))
283 .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of these users").setMinValue(0).setMaxValue(7)),
284
285 new SlashCommandBuilder().setName('kick').setDescription('Kick a member')
286 .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
287 .addStringOption(option => option.setName('reason').setDescription("The reason for kicking this user")),
288
289 new SlashCommandBuilder().setName('shot').setDescription('Give a shot to a member')
290 .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
291 .addStringOption(option => option.setName('reason').setDescription("The reason for giving shot to this user")),
292
293 new SlashCommandBuilder().setName('warn').setDescription('Warn a member')
294 .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
295 .addStringOption(option => option.setName('reason').setDescription("The reason for warning this user")),
296
297 new SlashCommandBuilder().setName('note').setDescription('Take a note for a user')
298 .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
299 .addStringOption(option => option.setName('note').setDescription("The note content").setRequired(true)),
300
301 new SlashCommandBuilder().setName('mute').setDescription('Mute a member')
302 .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
303 .addStringOption(option => option.setName('reason').setDescription("The reason for muting this user"))
304 .addStringOption(option => option.setName('time').setDescription("Mute duration"))
305 .addBooleanOption(option => option.setName('hardmute').setDescription("Specify if the system should take out all roles of the user during the mute")),
306
307 new SlashCommandBuilder().setName('unmute').setDescription('Unmute a member')
308 .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),
309
310 new SlashCommandBuilder().setName('unban').setDescription('Unban a user')
311 .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
312
313 new SlashCommandBuilder().setName('warning').setDescription('Clear, remove or view warnings')
314 .addSubcommand(subcmd => {
315 return subcmd.setName('view').setDescription('View information about a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true));
316 })
317 .addSubcommand(subcmd => {
318 return subcmd.setName('remove').setDescription('Remove a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true));
319 })
320 .addSubcommand(subcmd => {
321 return subcmd.setName('list').setDescription('List warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true));
322 })
323 .addSubcommand(subcmd => {
324 return subcmd.setName('clear').setDescription('Clear all warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true));
325 }),
326
327 new SlashCommandBuilder().setName('noteget').setDescription('Get information about a note')
328 .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),
329
330 new SlashCommandBuilder().setName('notedel').setDescription('Delete a note')
331 .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),
332
333 new SlashCommandBuilder().setName('notes').setDescription('Fetch all notes for a user')
334 .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
335
336 new SlashCommandBuilder().setName('history').setDescription('Fetch all moderation history for a user')
337 .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
338
339 new SlashCommandBuilder().setName('clear').setDescription('Clear messages in bulk')
340 .addUserOption(option => option.setName('user').setDescription("The user"))
341 .addIntegerOption(option => option.setName('count').setDescription("The amount of messages to delete").setMaxValue(400).setMinValue(0))
342 .addChannelOption(option => option.setName('channel').setDescription("The channel where the messages will be deleted")),
343
344 new SlashCommandBuilder().setName('echo').setDescription('Re-send a message from the bot system')
345 .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))
346 .addChannelOption(option => option.setName('channel').setDescription("The channel where the message should be sent")),
347
348 new SlashCommandBuilder().setName('lock').setDescription('Lock a channel')
349 .addRoleOption(option => option.setName('role').setDescription("Lock channel for the given role. Default is @everyone"))
350 .addChannelOption(option => option.setName('channel').setDescription("The channel that will be locked. Default is the current channel")),
351
352 new SlashCommandBuilder().setName('setchperms').setDescription('Set permissions for channels')
353 .addChannelOption(option => option.setName('channel').setDescription("The channel that (or its children) will be updated").setRequired(true))
354 .addRoleOption(option => option.setName('role').setDescription("Lock channel for the given role.").setRequired(true))
355 .addStringOption(option => option.setName('permission').setDescription("The permission codename").setRequired(true).setAutocomplete(true))
356 .addStringOption(option => option.setName('value').setDescription("The permission value").addChoices(...[
357 {
358 name: 'Allow',
359 value: 'true'
360 },
361 {
362 name: 'Deny',
363 value: 'false',
364 },
365 {
366 name: 'Default',
367 value: 'null',
368 }
369 ]).setRequired(true)),
370
371 new SlashCommandBuilder().setName('lockall').setDescription('Lock multiple channels')
372 .addStringOption(option => option.setName('channels').setDescription("The channels, must be separated by spaces"))
373 .addRoleOption(option => option.setName('role').setDescription("Lock channels for the given role. Default is @everyone"))
374 .addBooleanOption(option => option.setName('raid').setDescription("The raid protected channels will be locked. Default is `false`")),
375
376 new SlashCommandBuilder().setName('unlockall').setDescription('Unlock multiple channels')
377 .addStringOption(option => option.setName('channels').setDescription("The channels, must be separated by spaces"))
378 .addRoleOption(option => option.setName('role').setDescription("Unlock channels for the given role. Default is @everyone"))
379 .addBooleanOption(option => option.setName('force').setDescription("Force set the channel permissions to `true`"))
380 .addBooleanOption(option => option.setName('raid').setDescription("The raid protected channels will be unlocked. Default is `false`")),
381
382 new SlashCommandBuilder().setName('unlock').setDescription('Unlock a channel')
383 .addRoleOption(option => option.setName('role').setDescription("Unlock channel for the given role. Default is @everyone"))
384 .addBooleanOption(option => option.setName('force').setDescription("Force set the channel permission to `true`"))
385 .addChannelOption(option => option.setName('channel').setDescription("The channel that will be unlocked. Default is the current channel")),
386
387 new SlashCommandBuilder().setName('send').setDescription('Send a DM to a user')
388 .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))
389 .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),
390
391
392 new SlashCommandBuilder().setName('appeal').setDescription('Send us a messages about a punishment appeal')
393 ].map(command => command.toJSON());
394
395 let contextMenuCommands = [
396 new ContextMenuCommandBuilder().setName('Moderation History').setType(ApplicationCommandType.User),
397 new ContextMenuCommandBuilder().setName('Ban').setType(ApplicationCommandType.User),
398 new ContextMenuCommandBuilder().setName('Shot').setType(ApplicationCommandType.User),
399 new ContextMenuCommandBuilder().setName('Kick').setType(ApplicationCommandType.User),
400 ].map(command => command.toJSON());
401
402 commands = commands.concat(contextMenuCommands);
403
404 if (process.argv.includes('--clear')) {
405 commands = [];
406 contextMenuCommands = [];
407 }
408
409 const rest = new REST({ version: '9' }).setToken(TOKEN);
410
411 rest.put(Routes[process.argv.includes('--guild') ? 'applicationGuildCommands' : 'applicationCommands'](CLIENT_ID, GUILD_ID), { body: commands })
412 .then(() => console.log('Successfully registered application ' + (process.argv.includes('--guild') ? 'guild ' : '') + 'commands.'))
413 .catch(console.error);

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26