mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-30 06:31:02 +00:00
feat(bots/discord)!: read commit description
FEATURES: - Updated documentation - Improved configuration format - Allow filter overriding for each response config (closes #29) - Improved commands directory structure - Improved slash command reload script - New commands - New command exception handling
This commit is contained in:
45
bots/discord/src/commands/development/exception-test.ts
Normal file
45
bots/discord/src/commands/development/exception-test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { SlashCommandBuilder } from 'discord.js'
|
||||
|
||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||
import type { Command } from '..'
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('exception-test')
|
||||
.setDescription('throw up pls')
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('type')
|
||||
.setDescription('The type of exception to throw')
|
||||
.addChoices({
|
||||
name: 'generic error',
|
||||
value: 'Generic',
|
||||
})
|
||||
.addChoices({
|
||||
name: 'invalid argument',
|
||||
value: 'InvalidArgument',
|
||||
})
|
||||
.addChoices({
|
||||
name: 'invalid channel',
|
||||
value: 'InvalidChannel',
|
||||
})
|
||||
.addChoices({
|
||||
name: 'invalid user',
|
||||
value: 'InvalidUser',
|
||||
})
|
||||
.addChoices({
|
||||
name: 'invalid duration',
|
||||
value: 'InvalidDuration',
|
||||
})
|
||||
.setRequired(true),
|
||||
)
|
||||
.setDMPermission(true)
|
||||
.toJSON(),
|
||||
|
||||
global: true,
|
||||
|
||||
async execute(_, interaction) {
|
||||
const type = interaction.options.getString('type', true)
|
||||
throw new CommandError(CommandErrorType[type as keyof typeof CommandErrorType], '[INTENTIONAL BOT DESIGN]')
|
||||
},
|
||||
} satisfies Command
|
||||
29
bots/discord/src/commands/development/stop.ts
Normal file
29
bots/discord/src/commands/development/stop.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { SlashCommandBuilder } from 'discord.js'
|
||||
|
||||
import type { Command } from '..'
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder().setName('stop').setDescription('Stops the bot').setDMPermission(true).toJSON(),
|
||||
|
||||
ownerOnly: true,
|
||||
global: true,
|
||||
|
||||
async execute({ api, logger }, interaction) {
|
||||
api.isStopping = true
|
||||
|
||||
logger.fatal('Stopping bot...')
|
||||
await interaction.reply({
|
||||
content: 'Stopping... (I will go offline once done)',
|
||||
ephemeral: true,
|
||||
})
|
||||
|
||||
api.client.disconnect()
|
||||
logger.warn('Disconnected from API')
|
||||
|
||||
await interaction.client.destroy()
|
||||
logger.warn('Disconnected from Discord API')
|
||||
|
||||
logger.info(`Bot stopped, requested by ${interaction.user.id}`)
|
||||
process.exit(0)
|
||||
},
|
||||
} satisfies Command
|
||||
Reference in New Issue
Block a user