/[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 60 by rakin, Mon Jul 29 17:28:26 2024 UTC revision 248 by rakin, Mon Jul 29 17:29:12 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, 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 16  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('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 31  const commands = [ Line 70  const 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 48  const commands = [ Line 88  const 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 and send an embed')
92            .addStringOption(option => option.setName('author_name').setDescription('The embed author name'))
93            .addStringOption(option => option.setName('author_iconurl').setDescription('The embed author icon URL'))
94            .addStringOption(option => option.setName('title').setDescription('The embed title'))
95            .addStringOption(option => option.setName('description').setDescription('The embed description'))
96            .addStringOption(option => option.setName('thumbnail').setDescription('The embed thumbnail'))
97            .addStringOption(option => option.setName('image').setDescription('The embed image attachment'))
98            .addStringOption(option => option.setName('footer_text').setDescription('The embed footer text'))
99            .addStringOption(option => option.setName('footer_iconurl').setDescription('The embed footer icon URL'))
100            .addStringOption(option => option.setName('timestamp').setDescription('The embed timestamp, use \'current\' to set current date'))
101            .addStringOption(option => option.setName('color').setDescription('The embed color (default is #007bff)'))
102            .addStringOption(option => option.setName('url').setDescription('The embed URL'))
103            .addStringOption(option => option.setName('fields').setDescription('The embed fields, should be in `Field 1: Value 1, Field 2: Value 2` format')),
104    
105      new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'),      new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'),
106    
107      new SlashCommandBuilder().setName('schedule').setDescription('Schedule a message for sending later')      new SlashCommandBuilder().setName('schedule').setDescription('Schedule a message for sending later')
# Line 134  const commands = [ Line 188  const commands = [
188          .addStringOption(option => option.setName('content').setDescription("The announcemnt message content")),          .addStringOption(option => option.setName('content').setDescription("The announcemnt message content")),
189    
190      // MODERATION      // MODERATION
191        new SlashCommandBuilder().setName('antijoin').setDescription('Enable antijoin system which will kick any new users joining the server'),
192    
193      new SlashCommandBuilder().setName('ban').setDescription('Ban a user')      new SlashCommandBuilder().setName('ban').setDescription('Ban a user')
194          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
195          .addStringOption(option => option.setName('reason').setDescription("The reason for banning this user"))          .addStringOption(option => option.setName('reason').setDescription("The reason for banning this user"))
196          .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)),
197    
198        new SlashCommandBuilder().setName('softban').setDescription('Softban a user')
199            .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
200            .addStringOption(option => option.setName('reason').setDescription("The reason for softbanning this user"))
201            .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user (default is 7)").setMinValue(0).setMaxValue(7)),
202    
203        new SlashCommandBuilder().setName('tempban').setDescription('Temporarily ban a user')
204            .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
205            .addStringOption(option => option.setName('time').setDescription("TBan duration").setRequired(true))
206            .addStringOption(option => option.setName('reason').setDescription("The reason for softbanning this user"))
207            .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of this user (default is 7)").setMinValue(0).setMaxValue(7)),
208    
209        new SlashCommandBuilder().setName('massban').setDescription('Ban multiple users')
210            .addStringOption(option => option.setName('users').setDescription("The user IDs (separated by spaces)").setRequired(true))
211            .addStringOption(option => option.setName('reason').setDescription("The reason for banning"))
212            .addIntegerOption(option => option.setName('days').setDescription("The days old messages to delete of these users").setMinValue(0).setMaxValue(7)),
213    
214      new SlashCommandBuilder().setName('kick').setDescription('Kick a member')      new SlashCommandBuilder().setName('kick').setDescription('Kick a member')
215          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
216          .addStringOption(option => option.setName('reason').setDescription("The reason for kicking this user")),          .addStringOption(option => option.setName('reason').setDescription("The reason for kicking this user")),
217    
218      new SlashCommandBuilder().setName('bean').setDescription('Bean a member')      new SlashCommandBuilder().setName('shot').setDescription('Give a shot to a member')
219          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
220          .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")),
221    
222      new SlashCommandBuilder().setName('warn').setDescription('Warn a member')      new SlashCommandBuilder().setName('warn').setDescription('Warn a member')
223          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
224          .addStringOption(option => option.setName('reason').setDescription("The reason for warning this user")),          .addStringOption(option => option.setName('reason').setDescription("The reason for warning this user")),
225    
226      new SlashCommandBuilder().setName('note').setDescription('Take a note for a member')      new SlashCommandBuilder().setName('note').setDescription('Take a note for a user')
227          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true))
228          .addStringOption(option => option.setName('note').setDescription("The note content").setRequired(true)),          .addStringOption(option => option.setName('note').setDescription("The note content").setRequired(true)),
229    
230      new SlashCommandBuilder().setName('mute').setDescription('Mute a member')      new SlashCommandBuilder().setName('mute').setDescription('Mute a member')
231          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true))
232          .addStringOption(option => option.setName('reason').setDescription("The reason for muting this user"))          .addStringOption(option => option.setName('reason').setDescription("The reason for muting this user"))
233          .addStringOption(option => option.setName('time').setDescription("Mute duration")),          .addStringOption(option => option.setName('time').setDescription("Mute duration"))
234            .addBooleanOption(option => option.setName('hardmute').setDescription("Specify if the system should take out all roles of the user during the mute")),
235    
236      new SlashCommandBuilder().setName('unmute').setDescription('Unmute a member')      new SlashCommandBuilder().setName('unmute').setDescription('Unmute a member')
237          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),
# Line 166  const commands = [ Line 239  const commands = [
239      new SlashCommandBuilder().setName('unban').setDescription('Unban a user')      new SlashCommandBuilder().setName('unban').setDescription('Unban a user')
240          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
241    
242      new SlashCommandBuilder().setName('warndel').setDescription('Delete a warning')      new SlashCommandBuilder().setName('warning').setDescription('Clear, remove or view warnings')
243          .addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)),          .addSubcommand(subcmd => {
244                return subcmd.setName('view').setDescription('View information about a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true));
245      new SlashCommandBuilder().setName('warning').setDescription('Get information about a warning')          })
246          .addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)),          .addSubcommand(subcmd => {
247                return subcmd.setName('remove').setDescription('Remove a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true));
248            })
249            .addSubcommand(subcmd => {
250                return subcmd.setName('list').setDescription('List warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true));
251            })
252            .addSubcommand(subcmd => {
253                return subcmd.setName('clear').setDescription('Clear all warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true));
254            }),
255    
256      new SlashCommandBuilder().setName('noteget').setDescription('Get information about a note')      new SlashCommandBuilder().setName('noteget').setDescription('Get information about a note')
257          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),
# Line 178  const commands = [ Line 259  const commands = [
259      new SlashCommandBuilder().setName('notedel').setDescription('Delete a note')      new SlashCommandBuilder().setName('notedel').setDescription('Delete a note')
260          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),          .addNumberOption(option => option.setName('id').setDescription("The note ID").setRequired(true)),
261    
     new SlashCommandBuilder().setName('warnings').setDescription('Fetch all warnings')  
         .addUserOption(option => option.setName('member').setDescription("Show warnings for only this member")),  
   
262      new SlashCommandBuilder().setName('notes').setDescription('Fetch all notes for a user')      new SlashCommandBuilder().setName('notes').setDescription('Fetch all notes for a user')
263          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
264    
265      new SlashCommandBuilder().setName('history').setDescription('Fetch all moderation history for a user')      new SlashCommandBuilder().setName('history').setDescription('Fetch all moderation history for a user')
266          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)),
267    
268      new SlashCommandBuilder().setName('clear').setDescription('Clear all messages in the current channel for a user')      new SlashCommandBuilder().setName('clear').setDescription('Clear messages in bulk')
269          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('user').setDescription("The user"))
270            .addIntegerOption(option => option.setName('count').setDescription("The amount of messages to delete").setMaxValue(400).setMinValue(0))
271            .addChannelOption(option => option.setName('channel').setDescription("The channel where the messages will be deleted")),
272    
273      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')
274          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))
# Line 198  const commands = [ Line 278  const commands = [
278          .addRoleOption(option => option.setName('role').setDescription("Lock channel for the given role. Default is @everyone"))          .addRoleOption(option => option.setName('role').setDescription("Lock channel for the given role. Default is @everyone"))
279          .addChannelOption(option => option.setName('channel').setDescription("The channel that will be locked. Default is the current channel")),          .addChannelOption(option => option.setName('channel').setDescription("The channel that will be locked. Default is the current channel")),
280    
281        new SlashCommandBuilder().setName('setchperms').setDescription('Set permissions for channels')
282            .addChannelOption(option => option.setName('channel').setDescription("The channel that (or its children) will be updated").setRequired(true))
283            .addRoleOption(option => option.setName('role').setDescription("Lock channel for the given role.").setRequired(true))
284            .addStringOption(option => option.setName('permission').setDescription("The permission codename").setRequired(true).setAutocomplete(true))
285            .addStringOption(option => option.setName('value').setDescription("The permission value").addChoices(...[
286                {
287                    name: 'Allow',
288                    value: 'true'
289                },
290                {
291                    name: 'Deny',
292                    value: 'false',
293                },
294                {
295                    name: 'Default',
296                    value: 'null',
297                }
298            ]).setRequired(true)),
299    
300      new SlashCommandBuilder().setName('lockall').setDescription('Lock multiple channels')      new SlashCommandBuilder().setName('lockall').setDescription('Lock multiple channels')
301            .addStringOption(option => option.setName('channels').setDescription("The channels, must be separated by spaces"))
302          .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"))
303          .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`")),
304    
305      new SlashCommandBuilder().setName('unlockall').setDescription('Unlock multiple channels')      new SlashCommandBuilder().setName('unlockall').setDescription('Unlock multiple channels')
306            .addStringOption(option => option.setName('channels').setDescription("The channels, must be separated by spaces"))
307          .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"))
308          .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`"))
309          .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 215  const commands = [ Line 316  const commands = [
316      new SlashCommandBuilder().setName('send').setDescription('Send a DM to a user')      new SlashCommandBuilder().setName('send').setDescription('Send a DM to a user')
317          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))          .addStringOption(option => option.setName('content').setDescription("The message content").setRequired(true))
318          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),          .addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)),
319    
320    
321        new SlashCommandBuilder().setName('appeal').setDescription('Send us a messages about a punishment appeal')
322  ].map(command => command.toJSON());  ].map(command => command.toJSON());
323    
324    let contextMenuCommands = [
325        new ContextMenuCommandBuilder().setName('Moderation History').setType(ApplicationCommandType.User),
326        new ContextMenuCommandBuilder().setName('Ban').setType(ApplicationCommandType.User),
327        new ContextMenuCommandBuilder().setName('Shot').setType(ApplicationCommandType.User),
328        new ContextMenuCommandBuilder().setName('Kick').setType(ApplicationCommandType.User),
329    ].map(command => command.toJSON());
330    
331    commands = commands.concat(contextMenuCommands);
332    
333    if (process.argv.includes('--clear')) {
334        commands = [];
335        contextMenuCommands = [];
336    }
337    
338  const rest = new REST({ version: '9' }).setToken(TOKEN);  const rest = new REST({ version: '9' }).setToken(TOKEN);
339    
 rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands })  
     .then(() => console.log('Successfully registered application commands.'))  
     .catch(console.error);  
340    rest.put(Routes[process.argv.includes('--guild') ? 'applicationGuildCommands' : 'applicationCommands'](CLIENT_ID, GUILD_ID), { body: commands })
341        .then(() => console.log('Successfully registered application ' + (process.argv.includes('--guild') ? 'guild ' : '') + 'commands.'))
342        .catch(console.error);

Legend:
Removed from v.60  
changed lines
  Added in v.248

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26