mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-18 00:33:59 +00:00
- Migrated to a new command framework which looks better and works better - Fixed commands not being bundled correctly - Added message (prefix) commands with argument validation - Added a new CommandErrorType, for invalid arguments - `/eval` is now a bit safer - Corrected colors for the coinflip embed - `/stop` now works even when the bot is not connected to the API
34 lines
946 B
TypeScript
34 lines
946 B
TypeScript
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,
|
|
InvalidArgument,
|
|
InvalidUser,
|
|
InvalidChannel,
|
|
InvalidDuration,
|
|
}
|
|
|
|
const ErrorTitleMap: Record<CommandErrorType, string> = {
|
|
[CommandErrorType.Generic]: 'An exception was thrown',
|
|
[CommandErrorType.MissingArgument]: 'Missing argument',
|
|
[CommandErrorType.InvalidArgument]: 'Invalid argument',
|
|
[CommandErrorType.InvalidUser]: 'Invalid user',
|
|
[CommandErrorType.InvalidChannel]: 'Invalid channel',
|
|
[CommandErrorType.InvalidDuration]: 'Invalid duration',
|
|
}
|