1 |
#!/bin/node |
#!/bin/node |
2 |
|
|
3 |
|
/** |
4 |
|
* This file is part of SudoBot. |
5 |
|
* |
6 |
|
* Copyright (C) 2021-2022 OSN Inc. |
7 |
|
* |
8 |
|
* SudoBot is free software; you can redistribute it and/or modify it |
9 |
|
* under the terms of the GNU Affero General Public License as published by |
10 |
|
* the Free Software Foundation, either version 3 of the License, or |
11 |
|
* (at your option) any later version. |
12 |
|
* |
13 |
|
* SudoBot is distributed in the hope that it will be useful, but |
14 |
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
* GNU Affero General Public License for more details. |
17 |
|
* |
18 |
|
* You should have received a copy of the GNU Affero General Public License |
19 |
|
* along with SudoBot. If not, see <https://www.gnu.org/licenses/>. |
20 |
|
*/ |
21 |
|
|
22 |
const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('@discordjs/builders'); |
const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('@discordjs/builders'); |
23 |
const { REST } = require('@discordjs/rest'); |
const { REST } = require('@discordjs/rest'); |
24 |
const { Routes } = require('discord-api-types/v9'); |
const { Routes } = require('discord-api-types/v9'); |
25 |
const { config } = require('dotenv'); |
const { config } = require('dotenv'); |
26 |
const { existsSync } = require('fs'); |
const { existsSync } = require('fs'); |
|
const { Permissions, ApplicationCommand } = require('discord.js'); |
|
27 |
const path = require('path'); |
const path = require('path'); |
28 |
const { ActivityType, ApplicationCommandType } = require('discord-api-types/v10'); |
const { ApplicationCommandType } = require('discord-api-types/v10'); |
29 |
|
|
30 |
if (existsSync(path.join(__dirname, '.env'))) { |
if (existsSync(path.join(__dirname, '.env'))) { |
31 |
config(); |
config(); |
41 |
new SlashCommandBuilder().setName('help').setDescription('A short documentation about the commands') |
new SlashCommandBuilder().setName('help').setDescription('A short documentation about the commands') |
42 |
.addStringOption(option => option.setName('command').setDescription("The command")), |
.addStringOption(option => option.setName('command').setDescription("The command")), |
43 |
new SlashCommandBuilder().setName('about').setDescription('Show information about the bot'), |
new SlashCommandBuilder().setName('about').setDescription('Show information about the bot'), |
44 |
|
new SlashCommandBuilder().setName('eval').setDescription('Execute raw code in the runtime environment') |
45 |
|
.addStringOption(option => option.setName('code').setDescription('The code to be executed').setRequired(true)), |
46 |
new SlashCommandBuilder().setName('system').setDescription('Show the system status'), |
new SlashCommandBuilder().setName('system').setDescription('Show the system status'), |
47 |
new SlashCommandBuilder().setName('restart').setDescription('Restart the system'), |
new SlashCommandBuilder().setName('restart').setDescription('Restart the system'), |
48 |
new SlashCommandBuilder().setName('setstatus').setDescription('Set status for the bot system') |
new SlashCommandBuilder().setName('setstatus').setDescription('Set status for the bot system') |
80 |
} |
} |
81 |
])), |
])), |
82 |
new SlashCommandBuilder().setName('config').setDescription('View/change the system settings for this server') |
new SlashCommandBuilder().setName('config').setDescription('View/change the system settings for this server') |
83 |
.addStringOption(option => option.setName('key').setDescription('The setting key (e.g. spam_filter.enabled)').setRequired(true)) |
.addStringOption(option => option.setName('key').setDescription('The setting key (e.g. spam_filter.enabled)').setRequired(true).setAutocomplete(true)) |
84 |
.addStringOption(option => option.setName('value').setDescription('New value for the setting')), |
.addStringOption(option => option.setName('value').setDescription('New value for the setting')), |
85 |
|
|
86 |
// INFORMATION |
// INFORMATION |
87 |
new SlashCommandBuilder().setName('stats').setDescription('Show the server statistics'), |
new SlashCommandBuilder().setName('stats').setDescription('Show the server statistics'), |
88 |
|
new SlashCommandBuilder().setName('lookup').setDescription('Lookup something') |
89 |
|
.addSubcommand(subcommand => subcommand.setName("user").setDescription("User lookup") |
90 |
|
.addUserOption(option => option.setName("user").setDescription("The user to search").setRequired(true)) |
91 |
|
) |
92 |
|
.addSubcommand(subcommand => subcommand.setName("guild").setDescription("Server/Guild lookup") |
93 |
|
.addStringOption(option => option.setName("guild_id").setDescription("The ID of the server/guild to lookup").setRequired(true)) |
94 |
|
) |
95 |
|
.addSubcommand(subcommand => subcommand.setName("avatar").setDescription("Avatar lookup using Google Image Search") |
96 |
|
.addUserOption(option => option.setName("user").setDescription("The user to lookup").setRequired(true)) |
97 |
|
), |
98 |
|
|
99 |
new SlashCommandBuilder().setName('profile').setDescription('Show someone\'s profile') |
new SlashCommandBuilder().setName('profile').setDescription('Show someone\'s profile') |
100 |
.addUserOption(option => option.setName('user').setDescription('The user')), |
.addUserOption(option => option.setName('user').setDescription('The user')), |
101 |
new SlashCommandBuilder().setName('avatar').setDescription('Show someone\'s avatar') |
new SlashCommandBuilder().setName('avatar').setDescription('Show someone\'s avatar') |
117 |
subcommand |
subcommand |
118 |
.setName('view') |
.setName('view') |
119 |
.setDescription('Get information/stats about a ballot') |
.setDescription('Get information/stats about a ballot') |
120 |
.addIntegerOption(option => option.setName('id').setDescription('The ballot ID'))), |
.addStringOption(option => option.setName('id').setDescription('The ballot ID'))), |
121 |
|
|
122 |
new SlashCommandBuilder().setName('embed').setDescription('Make an embed') |
new SlashCommandBuilder().setName('embed').setDescription('Make an embed') |
123 |
.addSubcommand(subcmd => |
.addSubcommand(subcmd => |
154 |
) |
) |
155 |
.addSubcommand(subcmd => |
.addSubcommand(subcmd => |
156 |
subcmd.setName("build").setDescription("Build an embed from schema") |
subcmd.setName("build").setDescription("Build an embed from schema") |
157 |
.addStringOption(option => option.setName('schema').setDescription('The embed schema')) |
.addStringOption(option => option.setName('json_schema').setDescription('The embed JSON schema')) |
158 |
), |
), |
159 |
|
|
160 |
new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'), |
new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'), |
239 |
new SlashCommandBuilder().setName('afk').setDescription('Set your AFK status') |
new SlashCommandBuilder().setName('afk').setDescription('Set your AFK status') |
240 |
.addStringOption(option => option.setName('reason').setDescription("The reason for going AFK")), |
.addStringOption(option => option.setName('reason').setDescription("The reason for going AFK")), |
241 |
|
|
242 |
|
new SlashCommandBuilder().setName('hash').setDescription('Generate hash for a string (text) data') |
243 |
|
.addStringOption(option => option.setName('content').setDescription("The content to be hashed").setRequired(true)) |
244 |
|
.addStringOption(option => |
245 |
|
option |
246 |
|
.setName('algorithm') |
247 |
|
.setDescription("Hash algorithm") |
248 |
|
.setChoices( |
249 |
|
{ |
250 |
|
name: 'SHA1', |
251 |
|
value: 'sha1' |
252 |
|
}, |
253 |
|
{ |
254 |
|
name: 'SHA256', |
255 |
|
value: 'sha256' |
256 |
|
}, |
257 |
|
{ |
258 |
|
name: 'SHA512', |
259 |
|
value: 'sha512' |
260 |
|
}, |
261 |
|
{ |
262 |
|
name: 'MD5', |
263 |
|
value: 'md5' |
264 |
|
}, |
265 |
|
) |
266 |
|
) |
267 |
|
.addStringOption(option => |
268 |
|
option |
269 |
|
.setName('digest') |
270 |
|
.setDescription("Digest mode") |
271 |
|
.setChoices( |
272 |
|
{ |
273 |
|
name: 'HEX', |
274 |
|
value: 'hex' |
275 |
|
}, |
276 |
|
{ |
277 |
|
name: 'Base64', |
278 |
|
value: 'base64' |
279 |
|
}, |
280 |
|
{ |
281 |
|
name: 'Base64 URL', |
282 |
|
value: 'base64url' |
283 |
|
}, |
284 |
|
) |
285 |
|
), |
286 |
|
|
287 |
new SlashCommandBuilder().setName('announce').setDescription('Announce something') |
new SlashCommandBuilder().setName('announce').setDescription('Announce something') |
288 |
.addStringOption(option => option.setName('content').setDescription("The announcemnt message content")), |
.addStringOption(option => option.setName('content').setDescription("The announcemnt message content")), |
289 |
|
|
317 |
|
|
318 |
new SlashCommandBuilder().setName('shot').setDescription('Give a shot to a member') |
new SlashCommandBuilder().setName('shot').setDescription('Give a shot to a member') |
319 |
.addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)) |
.addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)) |
320 |
.addStringOption(option => option.setName('reason').setDescription("The reason for giving shot to this user")), |
.addStringOption(option => option.setName('reason').setDescription("The reason for giving shot to this user")) |
321 |
|
.addBooleanOption(option => option.setName('anonymous').setDescription("Prevents sending your name as the 'Doctor' of the shot")), |
322 |
|
|
323 |
new SlashCommandBuilder().setName('warn').setDescription('Warn a member') |
new SlashCommandBuilder().setName('warn').setDescription('Warn a member') |
324 |
.addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)) |
.addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)) |
342 |
|
|
343 |
new SlashCommandBuilder().setName('warning').setDescription('Clear, remove or view warnings') |
new SlashCommandBuilder().setName('warning').setDescription('Clear, remove or view warnings') |
344 |
.addSubcommand(subcmd => { |
.addSubcommand(subcmd => { |
345 |
return subcmd.setName('view').setDescription('View information about a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)); |
return subcmd.setName('view').setDescription('View information about a warning').addStringOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)); |
346 |
}) |
}) |
347 |
.addSubcommand(subcmd => { |
.addSubcommand(subcmd => { |
348 |
return subcmd.setName('remove').setDescription('Remove a warning').addNumberOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)); |
return subcmd.setName('remove').setDescription('Remove a warning').addStringOption(option => option.setName('id').setDescription("The warning ID").setRequired(true)); |
349 |
}) |
}) |
350 |
.addSubcommand(subcmd => { |
.addSubcommand(subcmd => { |
351 |
return subcmd.setName('list').setDescription('List warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)); |
return subcmd.setName('list').setDescription('List warnings for a user').addUserOption(option => option.setName('user').setDescription("The user").setRequired(true)); |