/[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 67 by rakin, Mon Jul 29 17:28:27 2024 UTC revision 261 by rakin, Mon Jul 29 17:29:15 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 24  let commands = [ Line 25  let commands = [
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('system').setDescription('Show the system status'),      new SlashCommandBuilder().setName('system').setDescription('Show the system status'),
27      new SlashCommandBuilder().setName('restart').setDescription('Restart the system'),      new SlashCommandBuilder().setName('restart').setDescription('Restart the system'),
28        new SlashCommandBuilder().setName('setstatus').setDescription('Set status for the bot system')
29            .addStringOption(option => option.setName('activity').setDescription('The activity').setRequired(true))
30            .addStringOption(option => option.setName('status').setDescription('The status').setChoices(...[
31                {
32                    name: 'Online',
33                    value: 'online'
34                },
35                {
36                    name: 'Idle',
37                    value: 'idle'
38                },
39                {
40                    name: 'DND',
41                    value: 'dnd'
42                },
43                {
44                    name: 'Invisible',
45                    value: 'invisible'
46                }
47            ]))
48            .addStringOption(option => option.setName('type').setDescription('The activity type').setChoices(...[
49                {
50                    name: 'Playing',
51                    value: 'PLAYING'
52                },
53                {
54                    name: 'Watching',
55                    value: 'WATCHING'
56                },
57                {
58                    name: 'Competing',
59                    value: 'COMPETING'
60                }
61            ])),
62        new SlashCommandBuilder().setName('config').setDescription('View/change the system settings for this server')
63            .addStringOption(option => option.setName('key').setDescription('The setting key (e.g. spam_filter.enabled)').setRequired(true))
64            .addStringOption(option => option.setName('value').setDescription('New value for the setting')),
65    
66      // INFORMATION      // INFORMATION
67      new SlashCommandBuilder().setName('stats').setDescription('Show the server statistics'),      new SlashCommandBuilder().setName('stats').setDescription('Show the server statistics'),
# Line 32  let commands = [ Line 70  let commands = [
70      new SlashCommandBuilder().setName('avatar').setDescription('Show someone\'s avatar')      new SlashCommandBuilder().setName('avatar').setDescription('Show someone\'s avatar')
71          .addUserOption(option => option.setName('user').setDescription('The user')),          .addUserOption(option => option.setName('user').setDescription('The user')),
72      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')
73          .addUserOption(option => option.setName('role').setDescription('The role')),          .addRoleOption(option => option.setName('role').setDescription('The role'))
74            .addIntegerOption(option => option.setName('page').setDescription('The page number')),
75    
76      // AUTOMATION      // AUTOMATION
77      new SlashCommandBuilder().setName('ballot').setDescription('Ballot engine')      new SlashCommandBuilder().setName('ballot').setDescription('Ballot engine')
# Line 49  let commands = [ Line 88  let commands = [
88                  .setDescription('Get information/stats about a ballot')                  .setDescription('Get information/stats about a ballot')
89                  .addIntegerOption(option => option.setName('id').setDescription('The ballot ID'))),                  .addIntegerOption(option => option.setName('id').setDescription('The ballot ID'))),
90                    
91        new SlashCommandBuilder().setName('embed').setDescription('Make an embed')
92            .addSubcommand(subcmd =>
93                 subcmd.setName("send").setDescription("Make and send an embed")
94                    .addStringOption(option => option.setName('author_name').setDescription('The embed author name'))
95                    .addStringOption(option => option.setName('author_iconurl').setDescription('The embed author icon URL'))
96                    .addStringOption(option => option.setName('title').setDescription('The embed title'))
97                    .addStringOption(option => option.setName('description').setDescription('The embed description'))
98                    .addStringOption(option => option.setName('thumbnail').setDescription('The embed thumbnail URL'))
99                    .addStringOption(option => option.setName('image').setDescription('The embed image attachment URL'))
100                    .addStringOption(option => option.setName('video').setDescription('The embed video attachment URL'))
101                    .addStringOption(option => option.setName('footer_text').setDescription('The embed footer text'))
102                    .addStringOption(option => option.setName('footer_iconurl').setDescription('The embed footer icon URL'))
103                    .addStringOption(option => option.setName('timestamp').setDescription('The embed timestamp, use \'current\' to set current date'))
104                    .addStringOption(option => option.setName('color').setDescription('The embed color (default is #007bff)'))
105                    .addStringOption(option => option.setName('url').setDescription('The embed URL'))
106                    .addStringOption(option => option.setName('fields').setDescription('The embed fields, should be in `Field 1: Value 1, Field 2: Value 2` format'))
107            )
108            .addSubcommand(subcmd =>
109                 subcmd.setName("schema").setDescription("Make and send an embed schema representation")
110                    .addStringOption(option => option.setName('author_name').setDescription('The embed author name'))
111                    .addStringOption(option => option.setName('author_iconurl').setDescription('The embed author icon URL'))
112                    .addStringOption(option => option.setName('title').setDescription('The embed title'))
113                    .addStringOption(option => option.setName('description').setDescription('The embed description'))
114                    .addStringOption(option => option.setName('thumbnail').setDescription('The embed thumbnail URL'))
115                    .addStringOption(option => option.setName('image').setDescription('The embed image attachment URL'))
116                    .addStringOption(option => option.setName('video').setDescription('The embed video attachment URL'))
117                    .addStringOption(option => option.setName('footer_text').setDescription('The embed footer text'))
118                    .addStringOption(option => option.setName('footer_iconurl').setDescription('The embed footer icon URL'))
119                    .addStringOption(option => option.setName('timestamp').setDescription('The embed timestamp, use \'current\' to set current date'))
120                    .addStringOption(option => option.setName('color').setDescription('The embed color (default is #007bff)'))
121                    .addStringOption(option => option.setName('url').setDescription('The embed URL'))
122                    .addStringOption(option => option.setName('fields').setDescription('The embed fields, should be in `Field 1: Value 1, Field 2: Value 2` format'))
123            )
124            .addSubcommand(subcmd =>
125                 subcmd.setName("build").setDescription("Build an embed from schema")
126                    .addStringOption(option => option.setName('json_schema').setDescription('The embed JSON schema'))
127            ),
128    
129      new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'),      new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'),
130    
131      new SlashCommandBuilder().setName('schedule').setDescription('Schedule a message for sending later')      new SlashCommandBuilder().setName('schedule').setDescription('Schedule a message for sending later')
# Line 131  let commands = [ Line 208  let commands = [
208      new SlashCommandBuilder().setName('afk').setDescription('Set your AFK status')      new SlashCommandBuilder().setName('afk').setDescription('Set your AFK status')
209          .addStringOption(option => option.setName('reason').setDescription("The reason for going AFK")),          .addStringOption(option => option.setName('reason').setDescription("The reason for going AFK")),
210            
211        new SlashCommandBuilder().setName('hash').setDescription('Generate hash for a string (text) data')
212            .addStringOption(option => option.setName('content').setDescription("The content to be hashed").setRequired(true))
213            .addStringOption(option =>
214                option
215                .setName('algorithm')
216                .setDescription("Hash algorithm")
217                .setChoices(
218                    {
219                        name: 'SHA1',
220                        value: 'sha1'
221                    },
222                    {
223                        name: 'SHA256',
224                        value: 'sha256'
225                    },
226                    {
227                        name: 'SHA512',
228                        value: 'sha512'
229                    },
230                    {
231                        name: 'MD5',
232                        value: 'md5'
233                    },
234                )
235            )
236            .addStringOption(option =>
237                option
238                .setName('digest')
239                .setDescription("Digest mode")
240                .setChoices(
241                    {
242                        name: 'HEX',
243                        value: 'hex'
244                    },
245                    {
246                        name: 'Base64',
247                        value: 'base64'
248                    },
249                    {
250                        name: 'Base64 URL',
251                        value: 'base64url'
252                    },
253                )
254            ),
255        
256      new SlashCommandBuilder().setName('announce').setDescription('Announce something')      new SlashCommandBuilder().setName('announce').setDescription('Announce something')
257          .addStringOption(option => option.setName('content').setDescription("The announcemnt message content")),          .addStringOption(option => option.setName('content').setDescription("The announcemnt message content")),
258    
259      // MODERATION      // MODERATION
260        new SlashCommandBuilder().setName('antijoin').setDescription('Enable antijoin system which will kick any new users joining the server'),
261    
262      new SlashCommandBuilder().setName('ban').setDescription('Ban a user')      new SlashCommandBuilder().setName('ban').setDescription('Ban a user')
263          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
264          .addStringOption(option => option.setName('reason').setDescription("The reason for banning this user"))          .addStringOption(option => option.setName('reason').setDescription("The reason for banning this user"))
265          .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)),
266    
267        new SlashCommandBuilder().setName('softban').setDescription('Softban a user')
268            .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
269            .addStringOption(option => option.setName('reason').setDescription("The reason for softbanning this user"))
270            .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user (default is 7)").setMinValue(0).setMaxValue(7)),
271    
272        new SlashCommandBuilder().setName('tempban').setDescription('Temporarily ban a user')
273            .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
274            .addStringOption(option => option.setName('time').setDescription("TBan duration").setRequired(true))
275            .addStringOption(option => option.setName('reason').setDescription("The reason for softbanning this user"))
276            .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user (default is 7)").setMinValue(0).setMaxValue(7)),
277    
278      new SlashCommandBuilder().setName('massban').setDescription('Ban multiple users')      new SlashCommandBuilder().setName('massban').setDescription('Ban multiple users')
279          .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))
280          .addStringOption(option => option.setName('reason').setDescription("The reason for banning"))          .addStringOption(option => option.setName('reason').setDescription("The reason for banning"))
# Line 149  let commands = [ Line 284  let commands = [
284          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
285          .addStringOption(option => option.setName('reason').setDescription("The reason for kicking this user")),          .addStringOption(option => option.setName('reason').setDescription("The reason for kicking this user")),
286    
287      new SlashCommandBuilder().setName('bean').setDescription('Bean a member')      new SlashCommandBuilder().setName('shot').setDescription('Give a shot to a member')
288          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
289          .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")),
290    
291      new SlashCommandBuilder().setName('warn').setDescription('Warn a member')      new SlashCommandBuilder().setName('warn').setDescription('Warn a member')
292          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
293          .addStringOption(option => option.setName('reason').setDescription("The reason for warning this user")),          .addStringOption(option => option.setName('reason').setDescription("The reason for warning this user")),
294    
295      new SlashCommandBuilder().setName('note').setDescription('Take a note for a member')      new SlashCommandBuilder().setName('note').setDescription('Take a note for a user')
296          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
297          .addStringOption(option => option.setName('note').setDescription("The note content").setRequired(true)),          .addStringOption(option => option.setName('note').setDescription("The note content").setRequired(true)),
298    
299      new SlashCommandBuilder().setName('mute').setDescription('Mute a member')      new SlashCommandBuilder().setName('mute').setDescription('Mute a member')
300          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
301          .addStringOption(option => option.setName('reason').setDescription("The reason for muting this user"))          .addStringOption(option => option.setName('reason').setDescription("The reason for muting this user"))
302          .addStringOption(option => option.setName('time').setDescription("Mute duration")),          .addStringOption(option => option.setName('time').setDescription("Mute duration"))
303            .addBooleanOption(option => option.setName('hardmute').setDescription("Specify if the system should take out all roles of the user during the mute")),
304    
305      new SlashCommandBuilder().setName('unmute').setDescription('Unmute a member')      new SlashCommandBuilder().setName('unmute').setDescription('Unmute a member')
306          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),
# Line 172  let commands = [ Line 308  let commands = [
308      new SlashCommandBuilder().setName('unban').setDescription('Unban a user')      new SlashCommandBuilder().setName('unban').setDescription('Unban a user')
309          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
310    
311      new SlashCommandBuilder().setName('warndel').setDescription('Delete a warning')      new SlashCommandBuilder().setName('warning').setDescription('Clear, remove or view warnings')
312          .addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)),          .addSubcommand(subcmd => {
313                return subcmd.setName('view').setDescription('View information about a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true));
314      new SlashCommandBuilder().setName('warning').setDescription('Get information about a warning')          })
315          .addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)),          .addSubcommand(subcmd => {
316                return subcmd.setName('remove').setDescription('Remove a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true));
317            })
318            .addSubcommand(subcmd => {
319                return subcmd.setName('list').setDescription('List warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true));
320            })
321            .addSubcommand(subcmd => {
322                return subcmd.setName('clear').setDescription('Clear all warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true));
323            }),
324    
325      new SlashCommandBuilder().setName('noteget').setDescription('Get information about a note')      new SlashCommandBuilder().setName('noteget').setDescription('Get information about a note')
326          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),
# Line 184  let commands = [ Line 328  let commands = [
328      new SlashCommandBuilder().setName('notedel').setDescription('Delete a note')      new SlashCommandBuilder().setName('notedel').setDescription('Delete a note')
329          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),
330    
     new SlashCommandBuilder().setName('warnings').setDescription('Fetch all warnings')  
         .addUserOption(option => option.setName('member').setDescription("Show warnings for only this member")),  
   
331      new SlashCommandBuilder().setName('notes').setDescription('Fetch all notes for a user')      new SlashCommandBuilder().setName('notes').setDescription('Fetch all notes for a user')
332          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
333    
334      new SlashCommandBuilder().setName('history').setDescription('Fetch all moderation history for a user')      new SlashCommandBuilder().setName('history').setDescription('Fetch all moderation history for a user')
335          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
336    
337      new SlashCommandBuilder().setName('clear').setDescription('Clear all messages in the current channel for a user')      new SlashCommandBuilder().setName('clear').setDescription('Clear messages in bulk')
338          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user"))
339            .addIntegerOption(option => option.setName('count').setDescription("The amount of messages to delete").setMaxValue(400).setMinValue(0))
340            .addChannelOption(option => option.setName('channel').setDescription("The channel where the messages will be deleted")),
341    
342      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')
343          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))
# Line 224  let commands = [ Line 367  let commands = [
367          ]).setRequired(true)),          ]).setRequired(true)),
368    
369      new SlashCommandBuilder().setName('lockall').setDescription('Lock multiple channels')      new SlashCommandBuilder().setName('lockall').setDescription('Lock multiple channels')
370            .addStringOption(option => option.setName('channels').setDescription("The channels, must be separated by spaces"))
371          .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"))
372          .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`")),
373    
374      new SlashCommandBuilder().setName('unlockall').setDescription('Unlock multiple channels')      new SlashCommandBuilder().setName('unlockall').setDescription('Unlock multiple channels')
375            .addStringOption(option => option.setName('channels').setDescription("The channels, must be separated by spaces"))
376          .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"))
377          .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`"))
378          .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  let commands = [ Line 385  let commands = [
385      new SlashCommandBuilder().setName('send').setDescription('Send a DM to a user')      new SlashCommandBuilder().setName('send').setDescription('Send a DM to a user')
386          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))
387          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),
388    
389    
390        new SlashCommandBuilder().setName('appeal').setDescription('Send us a messages about a punishment appeal')
391    ].map(command => command.toJSON());
392    
393    let contextMenuCommands = [
394        new ContextMenuCommandBuilder().setName('Moderation History').setType(ApplicationCommandType.User),
395        new ContextMenuCommandBuilder().setName('Ban').setType(ApplicationCommandType.User),
396        new ContextMenuCommandBuilder().setName('Shot').setType(ApplicationCommandType.User),
397        new ContextMenuCommandBuilder().setName('Kick').setType(ApplicationCommandType.User),
398  ].map(command => command.toJSON());  ].map(command => command.toJSON());
399    
400    commands = commands.concat(contextMenuCommands);
401    
402  if (process.argv.includes('--clear')) {  if (process.argv.includes('--clear')) {
403      commands = [];      commands = [];
404        contextMenuCommands = [];
405  }  }
406    
407  const rest = new REST({ version: '9' }).setToken(TOKEN);  const rest = new REST({ version: '9' }).setToken(TOKEN);
408    
409  rest.put(Routes[process.argv.includes('--guild') ? 'applicationGuildCommands' : 'applicationCommands'](CLIENT_ID, GUILD_ID), { body: commands })  rest.put(Routes[process.argv.includes('--guild') ? 'applicationGuildCommands' : 'applicationCommands'](CLIENT_ID, GUILD_ID), { body: commands })
410      .then(() => console.log('Successfully registered application ' + (process.argv.includes('--guild') ? 'guild ' : '') + 'commands.'))      .then(() => console.log('Successfully registered application ' + (process.argv.includes('--guild') ? 'guild ' : '') + 'commands.'))
     .catch(console.error);  
411        .catch(console.error);

Legend:
Removed from v.67  
changed lines
  Added in v.261

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26