mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-26 12:41:03 +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:
31
bots/discord/src/classes/CommandError.ts
Normal file
31
bots/discord/src/classes/CommandError.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { createErrorEmbed } from '$/utils/discord/embeds'
|
||||
|
||||
export default class CommandError extends Error {
|
||||
type: CommandErrorType
|
||||
|
||||
constructor(type: CommandErrorType, message?: string) {
|
||||
super(message)
|
||||
this.name = 'CommandError'
|
||||
this.type = type
|
||||
}
|
||||
|
||||
toEmbed() {
|
||||
return createErrorEmbed(ErrorTitleMap[this.type], this.message ?? '')
|
||||
}
|
||||
}
|
||||
|
||||
export enum CommandErrorType {
|
||||
Generic,
|
||||
MissingArgument,
|
||||
InvalidUser,
|
||||
InvalidChannel,
|
||||
InvalidDuration,
|
||||
}
|
||||
|
||||
const ErrorTitleMap: Record<CommandErrorType, string> = {
|
||||
[CommandErrorType.Generic]: 'An exception was thrown',
|
||||
[CommandErrorType.MissingArgument]: 'Missing argument',
|
||||
[CommandErrorType.InvalidUser]: 'Invalid user',
|
||||
[CommandErrorType.InvalidChannel]: 'Invalid channel',
|
||||
[CommandErrorType.InvalidDuration]: 'Invalid duration',
|
||||
}
|
||||
Reference in New Issue
Block a user