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

Diff of /trunk/deploy-commands.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 64 by rakin, Mon Jul 29 17:28:27 2024 UTC revision 290 by rakin, Mon Jul 29 17:29:23 2024 UTC
# Line 1  Line 1 
1  #!/bin/node  #!/bin/node
2    
3  const { SlashCommandBuilder } = require('@discordjs/builders');  const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('@discordjs/builders');
4  const { REST } = require('@discordjs/rest');  const { REST } = require('@discordjs/rest');
5  const { Routes } = require('discord-api-types/v9');  const { Routes } = require('discord-api-types/v9');
6  const { config } = require('dotenv');  const { config } = require('dotenv');
7  const { existsSync } = require('fs');  const { existsSync } = require('fs');
8  const { Permissions } = require('discord.js');  const { Permissions, ApplicationCommand } = require('discord.js');
9  const path = require('path');  const path = require('path');
10    const { ActivityType, ApplicationCommandType } = require('discord-api-types/v10');
11    
12  if (existsSync(path.join(__dirname, '.env'))) {  if (existsSync(path.join(__dirname, '.env'))) {
13      config();      config();
# Line 17  else { Line 18  else {
18    
19  const { CLIENT_ID, GUILD_ID, TOKEN } = process.env;  const { CLIENT_ID, GUILD_ID, TOKEN } = process.env;
20    
21  const commands = [  let commands = [
22      // SETTINGS      // SETTINGS
23      new SlashCommandBuilder().setName('help').setDescription('A short documentation about the commands')      new SlashCommandBuilder().setName('help').setDescription('A short documentation about the commands')
24          .addStringOption(option => option.setName('command').setDescription("The command")),          .addStringOption(option => option.setName('command').setDescription("The command")),
25      new SlashCommandBuilder().setName('about').setDescription('Show information about the bot'),      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'),      new SlashCommandBuilder().setName('system').setDescription('Show the system status'),
29      new SlashCommandBuilder().setName('restart').setDescription('Restart the system'),      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      // INFORMATION
69      new SlashCommandBuilder().setName('stats').setDescription('Show the server statistics'),      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("server").setDescription("The ID of the server/guild to lookup").setRequired(true))  
76            ),
77    
78      new SlashCommandBuilder().setName('profile').setDescription('Show someone\'s profile')      new SlashCommandBuilder().setName('profile').setDescription('Show someone\'s profile')
79          .addUserOption(option => option.setName('user').setDescription('The user')),          .addUserOption(option => option.setName('user').setDescription('The user')),
80      new SlashCommandBuilder().setName('avatar').setDescription('Show someone\'s avatar')      new SlashCommandBuilder().setName('avatar').setDescription('Show someone\'s avatar')
81          .addUserOption(option => option.setName('user').setDescription('The user')),          .addUserOption(option => option.setName('user').setDescription('The user')),
82      new SlashCommandBuilder().setName('rolelist').setDescription('List all roles or show info about a role')      new SlashCommandBuilder().setName('rolelist').setDescription('List all roles or show info about a role')
83          .addUserOption(option => option.setName('role').setDescription('The role')),          .addRoleOption(option => option.setName('role').setDescription('The role'))
84            .addIntegerOption(option => option.setName('page').setDescription('The page number')),
85    
86      // AUTOMATION      // AUTOMATION
87      new SlashCommandBuilder().setName('ballot').setDescription('Ballot engine')      new SlashCommandBuilder().setName('ballot').setDescription('Ballot engine')
# Line 49  const commands = [ Line 98  const commands = [
98                  .setDescription('Get information/stats about a ballot')                  .setDescription('Get information/stats about a ballot')
99                  .addIntegerOption(option => option.setName('id').setDescription('The ballot ID'))),                  .addIntegerOption(option => option.setName('id').setDescription('The ballot ID'))),
100                    
101        new SlashCommandBuilder().setName('embed').setDescription('Make an embed')
102            .addSubcommand(subcmd =>
103                 subcmd.setName("send").setDescription("Make and send an embed")
104                    .addStringOption(option => option.setName('author_name').setDescription('The embed author name'))
105                    .addStringOption(option => option.setName('author_iconurl').setDescription('The embed author icon URL'))
106                    .addStringOption(option => option.setName('title').setDescription('The embed title'))
107                    .addStringOption(option => option.setName('description').setDescription('The embed description'))
108                    .addStringOption(option => option.setName('thumbnail').setDescription('The embed thumbnail URL'))
109                    .addStringOption(option => option.setName('image').setDescription('The embed image attachment URL'))
110                    .addStringOption(option => option.setName('video').setDescription('The embed video attachment URL'))
111                    .addStringOption(option => option.setName('footer_text').setDescription('The embed footer text'))
112                    .addStringOption(option => option.setName('footer_iconurl').setDescription('The embed footer icon URL'))
113                    .addStringOption(option => option.setName('timestamp').setDescription('The embed timestamp, use \'current\' to set current date'))
114                    .addStringOption(option => option.setName('color').setDescription('The embed color (default is #007bff)'))
115                    .addStringOption(option => option.setName('url').setDescription('The embed URL'))
116                    .addStringOption(option => option.setName('fields').setDescription('The embed fields, should be in `Field 1: Value 1, Field 2: Value 2` format'))
117            )
118            .addSubcommand(subcmd =>
119                 subcmd.setName("schema").setDescription("Make and send an embed schema representation")
120                    .addStringOption(option => option.setName('author_name').setDescription('The embed author name'))
121                    .addStringOption(option => option.setName('author_iconurl').setDescription('The embed author icon URL'))
122                    .addStringOption(option => option.setName('title').setDescription('The embed title'))
123                    .addStringOption(option => option.setName('description').setDescription('The embed description'))
124                    .addStringOption(option => option.setName('thumbnail').setDescription('The embed thumbnail URL'))
125                    .addStringOption(option => option.setName('image').setDescription('The embed image attachment URL'))
126                    .addStringOption(option => option.setName('video').setDescription('The embed video attachment URL'))
127                    .addStringOption(option => option.setName('footer_text').setDescription('The embed footer text'))
128                    .addStringOption(option => option.setName('footer_iconurl').setDescription('The embed footer icon URL'))
129                    .addStringOption(option => option.setName('timestamp').setDescription('The embed timestamp, use \'current\' to set current date'))
130                    .addStringOption(option => option.setName('color').setDescription('The embed color (default is #007bff)'))
131                    .addStringOption(option => option.setName('url').setDescription('The embed URL'))
132                    .addStringOption(option => option.setName('fields').setDescription('The embed fields, should be in `Field 1: Value 1, Field 2: Value 2` format'))
133            )
134            .addSubcommand(subcmd =>
135                 subcmd.setName("build").setDescription("Build an embed from schema")
136                    .addStringOption(option => option.setName('json_schema').setDescription('The embed JSON schema'))
137            ),
138    
139      new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'),      new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'),
140    
141      new SlashCommandBuilder().setName('schedule').setDescription('Schedule a message for sending later')      new SlashCommandBuilder().setName('schedule').setDescription('Schedule a message for sending later')
# Line 131  const commands = [ Line 218  const commands = [
218      new SlashCommandBuilder().setName('afk').setDescription('Set your AFK status')      new SlashCommandBuilder().setName('afk').setDescription('Set your AFK status')
219          .addStringOption(option => option.setName('reason').setDescription("The reason for going AFK")),          .addStringOption(option => option.setName('reason').setDescription("The reason for going AFK")),
220            
221        new SlashCommandBuilder().setName('hash').setDescription('Generate hash for a string (text) data')
222            .addStringOption(option => option.setName('content').setDescription("The content to be hashed").setRequired(true))
223            .addStringOption(option =>
224                option
225                .setName('algorithm')
226                .setDescription("Hash algorithm")
227                .setChoices(
228                    {
229                        name: 'SHA1',
230                        value: 'sha1'
231                    },
232                    {
233                        name: 'SHA256',
234                        value: 'sha256'
235                    },
236                    {
237                        name: 'SHA512',
238                        value: 'sha512'
239                    },
240                    {
241                        name: 'MD5',
242                        value: 'md5'
243                    },
244                )
245            )
246            .addStringOption(option =>
247                option
248                .setName('digest')
249                .setDescription("Digest mode")
250                .setChoices(
251                    {
252                        name: 'HEX',
253                        value: 'hex'
254                    },
255                    {
256                        name: 'Base64',
257                        value: 'base64'
258                    },
259                    {
260                        name: 'Base64 URL',
261                        value: 'base64url'
262                    },
263                )
264            ),
265        
266      new SlashCommandBuilder().setName('announce').setDescription('Announce something')      new SlashCommandBuilder().setName('announce').setDescription('Announce something')
267          .addStringOption(option => option.setName('content').setDescription("The announcemnt message content")),          .addStringOption(option => option.setName('content').setDescription("The announcemnt message content")),
268    
269      // MODERATION      // MODERATION
270        new SlashCommandBuilder().setName('antijoin').setDescription('Enable antijoin system which will kick any new users joining the server'),
271    
272      new SlashCommandBuilder().setName('ban').setDescription('Ban a user')      new SlashCommandBuilder().setName('ban').setDescription('Ban a user')
273          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
274          .addStringOption(option => option.setName('reason').setDescription("The reason for banning this user"))          .addStringOption(option => option.setName('reason').setDescription("The reason for banning this user"))
275          .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user").setMinValue(0).setMaxValue(7)),          .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user").setMinValue(0).setMaxValue(7)),
276    
277        new SlashCommandBuilder().setName('softban').setDescription('Softban a user')
278            .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
279            .addStringOption(option => option.setName('reason').setDescription("The reason for softbanning this user"))
280            .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user (default is 7)").setMinValue(0).setMaxValue(7)),
281    
282        new SlashCommandBuilder().setName('tempban').setDescription('Temporarily ban a user')
283            .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
284            .addStringOption(option => option.setName('time').setDescription("TBan duration").setRequired(true))
285            .addStringOption(option => option.setName('reason').setDescription("The reason for softbanning this user"))
286            .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user (default is 7)").setMinValue(0).setMaxValue(7)),
287    
288      new SlashCommandBuilder().setName('massban').setDescription('Ban multiple users')      new SlashCommandBuilder().setName('massban').setDescription('Ban multiple users')
289          .addStringOption(option => option.setName('users').setDescription("The user IDs (separated by spaces)").setRequired(true))          .addStringOption(option => option.setName('users').setDescription("The user IDs (separated by spaces)").setRequired(true))
290          .addStringOption(option => option.setName('reason').setDescription("The reason for banning"))          .addStringOption(option => option.setName('reason').setDescription("The reason for banning"))
# Line 149  const commands = [ Line 294  const commands = [
294          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
295          .addStringOption(option => option.setName('reason').setDescription("The reason for kicking this user")),          .addStringOption(option => option.setName('reason').setDescription("The reason for kicking this user")),
296    
297      new SlashCommandBuilder().setName('bean').setDescription('Bean a member')      new SlashCommandBuilder().setName('shot').setDescription('Give a shot to a member')
298          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
299          .addStringOption(option => option.setName('reason').setDescription("The reason for beaning this user")),          .addStringOption(option => option.setName('reason').setDescription("The reason for giving shot to this user")),
300    
301      new SlashCommandBuilder().setName('warn').setDescription('Warn a member')      new SlashCommandBuilder().setName('warn').setDescription('Warn a member')
302          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
303          .addStringOption(option => option.setName('reason').setDescription("The reason for warning this user")),          .addStringOption(option => option.setName('reason').setDescription("The reason for warning this user")),
304    
305      new SlashCommandBuilder().setName('note').setDescription('Take a note for a member')      new SlashCommandBuilder().setName('note').setDescription('Take a note for a user')
306          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
307          .addStringOption(option => option.setName('note').setDescription("The note content").setRequired(true)),          .addStringOption(option => option.setName('note').setDescription("The note content").setRequired(true)),
308    
309      new SlashCommandBuilder().setName('mute').setDescription('Mute a member')      new SlashCommandBuilder().setName('mute').setDescription('Mute a member')
310          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
311          .addStringOption(option => option.setName('reason').setDescription("The reason for muting this user"))          .addStringOption(option => option.setName('reason').setDescription("The reason for muting this user"))
312          .addStringOption(option => option.setName('time').setDescription("Mute duration")),          .addStringOption(option => option.setName('time').setDescription("Mute duration"))
313            .addBooleanOption(option => option.setName('hardmute').setDescription("Specify if the system should take out all roles of the user during the mute")),
314    
315      new SlashCommandBuilder().setName('unmute').setDescription('Unmute a member')      new SlashCommandBuilder().setName('unmute').setDescription('Unmute a member')
316          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),
# Line 172  const commands = [ Line 318  const commands = [
318      new SlashCommandBuilder().setName('unban').setDescription('Unban a user')      new SlashCommandBuilder().setName('unban').setDescription('Unban a user')
319          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
320    
321      new SlashCommandBuilder().setName('warndel').setDescription('Delete a warning')      new SlashCommandBuilder().setName('warning').setDescription('Clear, remove or view warnings')
322          .addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)),          .addSubcommand(subcmd => {
323                return subcmd.setName('view').setDescription('View information about a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true));
324      new SlashCommandBuilder().setName('warning').setDescription('Get information about a warning')          })
325          .addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)),          .addSubcommand(subcmd => {
326                return subcmd.setName('remove').setDescription('Remove a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true));
327            })
328            .addSubcommand(subcmd => {
329                return subcmd.setName('list').setDescription('List warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true));
330            })
331            .addSubcommand(subcmd => {
332                return subcmd.setName('clear').setDescription('Clear all warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true));
333            }),
334    
335      new SlashCommandBuilder().setName('noteget').setDescription('Get information about a note')      new SlashCommandBuilder().setName('noteget').setDescription('Get information about a note')
336          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),
# Line 184  const commands = [ Line 338  const commands = [
338      new SlashCommandBuilder().setName('notedel').setDescription('Delete a note')      new SlashCommandBuilder().setName('notedel').setDescription('Delete a note')
339          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),
340    
     new SlashCommandBuilder().setName('warnings').setDescription('Fetch all warnings')  
         .addUserOption(option => option.setName('member').setDescription("Show warnings for only this member")),  
   
341      new SlashCommandBuilder().setName('notes').setDescription('Fetch all notes for a user')      new SlashCommandBuilder().setName('notes').setDescription('Fetch all notes for a user')
342          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
343    
344      new SlashCommandBuilder().setName('history').setDescription('Fetch all moderation history for a user')      new SlashCommandBuilder().setName('history').setDescription('Fetch all moderation history for a user')
345          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
346    
347      new SlashCommandBuilder().setName('clear').setDescription('Clear all messages in the current channel for a user')      new SlashCommandBuilder().setName('clear').setDescription('Clear messages in bulk')
348          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user"))
349            .addIntegerOption(option => option.setName('count').setDescription("The amount of messages to delete").setMaxValue(400).setMinValue(0))
350            .addChannelOption(option => option.setName('channel').setDescription("The channel where the messages will be deleted")),
351    
352      new SlashCommandBuilder().setName('echo').setDescription('Re-send a message from the bot system')      new SlashCommandBuilder().setName('echo').setDescription('Re-send a message from the bot system')
353          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))
# Line 224  const commands = [ Line 377  const commands = [
377          ]).setRequired(true)),          ]).setRequired(true)),
378    
379      new SlashCommandBuilder().setName('lockall').setDescription('Lock multiple channels')      new SlashCommandBuilder().setName('lockall').setDescription('Lock multiple channels')
380            .addStringOption(option => option.setName('channels').setDescription("The channels, must be separated by spaces"))
381          .addRoleOption(option => option.setName('role').setDescription("Lock channels for the given role. Default is @everyone"))          .addRoleOption(option => option.setName('role').setDescription("Lock channels for the given role. Default is @everyone"))
382          .addBooleanOption(option => option.setName('raid').setDescription("The raid protected channels will be locked. Default is `false`")),          .addBooleanOption(option => option.setName('raid').setDescription("The raid protected channels will be locked. Default is `false`")),
383    
384      new SlashCommandBuilder().setName('unlockall').setDescription('Unlock multiple channels')      new SlashCommandBuilder().setName('unlockall').setDescription('Unlock multiple channels')
385            .addStringOption(option => option.setName('channels').setDescription("The channels, must be separated by spaces"))
386          .addRoleOption(option => option.setName('role').setDescription("Unlock channels for the given role. Default is @everyone"))          .addRoleOption(option => option.setName('role').setDescription("Unlock channels for the given role. Default is @everyone"))
387          .addBooleanOption(option => option.setName('force').setDescription("Force set the channel permissions to `true`"))          .addBooleanOption(option => option.setName('force').setDescription("Force set the channel permissions to `true`"))
388          .addBooleanOption(option => option.setName('raid').setDescription("The raid protected channels will be unlocked. Default is `false`")),          .addBooleanOption(option => option.setName('raid').setDescription("The raid protected channels will be unlocked. Default is `false`")),
# Line 240  const commands = [ Line 395  const commands = [
395      new SlashCommandBuilder().setName('send').setDescription('Send a DM to a user')      new SlashCommandBuilder().setName('send').setDescription('Send a DM to a user')
396          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))
397          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),
398    
399    
400        new SlashCommandBuilder().setName('appeal').setDescription('Send us a messages about a punishment appeal')
401  ].map(command => command.toJSON());  ].map(command => command.toJSON());
402    
403    let contextMenuCommands = [
404        new ContextMenuCommandBuilder().setName('Moderation History').setType(ApplicationCommandType.User),
405        new ContextMenuCommandBuilder().setName('Ban').setType(ApplicationCommandType.User),
406        new ContextMenuCommandBuilder().setName('Shot').setType(ApplicationCommandType.User),
407        new ContextMenuCommandBuilder().setName('Kick').setType(ApplicationCommandType.User),
408    ].map(command => command.toJSON());
409    
410    commands = commands.concat(contextMenuCommands);
411    
412    if (process.argv.includes('--clear')) {
413        commands = [];
414        contextMenuCommands = [];
415    }
416    
417  const rest = new REST({ version: '9' }).setToken(TOKEN);  const rest = new REST({ version: '9' }).setToken(TOKEN);
418    
 rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands })  
     .then(() => console.log('Successfully registered application commands.'))  
     .catch(console.error);  
419    rest.put(Routes[process.argv.includes('--guild') ? 'applicationGuildCommands' : 'applicationCommands'](CLIENT_ID, GUILD_ID), { body: commands })
420        .then(() => console.log('Successfully registered application ' + (process.argv.includes('--guild') ? 'guild ' : '') + 'commands.'))
421        .catch(console.error);

Legend:
Removed from v.64  
changed lines
  Added in v.290

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26