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:
PalmDevs
2024-04-02 19:34:45 +07:00
parent a9add9ea9a
commit 7e5f6481c5
21 changed files with 542 additions and 558 deletions

View 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',
}