/[sudobot]/trunk/deploy-commands.js
ViewVC logotype

Contents of /trunk/deploy-commands.js

Parent Directory Parent Directory | Revision Log Revision Log


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26