feat(bots/discord): framework changes and new features

- 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
This commit is contained in:
PalmDevs
2024-07-30 21:05:12 +07:00
parent a848a9c896
commit 646ec8da87
36 changed files with 1153 additions and 616 deletions

View File

@@ -6,19 +6,19 @@ import { createLogger } from '@revanced/bot-shared'
import { Client as DiscordClient, Partials } from 'discord.js'
import { drizzle } from 'drizzle-orm/bun-sqlite'
// Export config first, as commands require them
// Export some things first, as commands require them
import config from '../config.js'
export { config }
import * as commands from './commands'
import * as schemas from './database/schemas'
import type { Command } from './commands/types'
export const logger = createLogger({
level: config.logLevel === 'none' ? Number.MAX_SAFE_INTEGER : config.logLevel,
})
import * as commands from './commands'
import * as schemas from './database/schemas'
import type { default as Command, CommandOptionsOptions } from './classes/Command'
export const api = {
client: new APIClient({
api: {
@@ -81,8 +81,8 @@ export const discord = {
},
partials: [Partials.Message, Partials.Reaction],
}),
commands: Object.fromEntries(Object.values<Command>(commands).map(cmd => [cmd.data.name, cmd])) as Record<
commands: Object.fromEntries(Object.values(commands).map(cmd => [cmd.name, cmd])) as Record<
string,
Command
Command<boolean, CommandOptionsOptions | undefined, boolean>
>,
} as const