mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-28 13:41:02 +00:00
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:
@@ -7,17 +7,27 @@ export const listAllFilesRecursive = (dir: string): string[] =>
|
||||
.filter(x => x.isFile())
|
||||
.map(x => join(x.parentPath, x.name).replaceAll(pathSep, posixPathSep))
|
||||
|
||||
export const generateCommandsIndex = (dirPath: string) => generateIndexes(dirPath, x => !x.endsWith('types.ts'))
|
||||
export const generateCommandsIndex = (dirPath: string) =>
|
||||
generateIndexes(dirPath, (x, i) => `export { default as C${i} } from './${x}'`)
|
||||
|
||||
export const generateEventsIndex = (dirPath: string) => generateIndexes(dirPath)
|
||||
|
||||
const generateIndexes = async (dirPath: string, pathFilter?: (path: string) => boolean) => {
|
||||
const generateIndexes = async (
|
||||
dirPath: string,
|
||||
customMap?: (path: string, index: number) => string,
|
||||
pathFilter?: (path: string) => boolean,
|
||||
) => {
|
||||
const files = listAllFilesRecursive(dirPath)
|
||||
.filter(x => (x.endsWith('.ts') && !x.endsWith('index.ts') && pathFilter ? pathFilter(x) : true))
|
||||
.filter(x => x.endsWith('.ts') && !x.endsWith('index.ts') && (pathFilter ? pathFilter(x) : true))
|
||||
.map(x => relative(dirPath, x).replaceAll(pathSep, posixPathSep))
|
||||
|
||||
writeFileSync(
|
||||
join(dirPath, 'index.ts'),
|
||||
`// AUTO-GENERATED BY A SCRIPT, DON'T TOUCH\n\n${files.map(c => `import './${c.split('.').at(-2)}'`).join('\n')}`,
|
||||
`// AUTO-GENERATED BY A SCRIPT, DON'T TOUCH\n\n${files
|
||||
.map((c, i) => {
|
||||
const path = c.split('.').at(-2)!
|
||||
return customMap ? customMap(path, i) : `import './${path}'`
|
||||
})
|
||||
.join('\n')}`,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user