mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-20 09:43:59 +00:00
27 lines
920 B
TypeScript
27 lines
920 B
TypeScript
// import { listAllFilesRecursive, pathJoinCurrentDir } from '$utils/fs'
|
|
import { getMissingEnvironmentVariables } from '@revanced/bot-shared'
|
|
import { api, discord, logger } from './context'
|
|
import { listAllFilesRecursive, pathJoinCurrentDir } from './utils/fs' with { type: 'macro' }
|
|
|
|
for (const event of listAllFilesRecursive(pathJoinCurrentDir(import.meta.url, 'events', 'api'))) {
|
|
await import(event)
|
|
}
|
|
|
|
const { client: apiClient } = api
|
|
await apiClient.ws.connect()
|
|
|
|
for (const event of listAllFilesRecursive(pathJoinCurrentDir(import.meta.url, 'events', 'discord'))) {
|
|
await import(event)
|
|
}
|
|
|
|
const { client: discordClient } = discord
|
|
|
|
// Check if token exists
|
|
const missingEnvs = getMissingEnvironmentVariables(['DISCORD_TOKEN'])
|
|
if (missingEnvs.length) {
|
|
for (const env of missingEnvs) logger.fatal(`${env} is not defined in environment variables`)
|
|
process.exit(1)
|
|
}
|
|
|
|
await discordClient.login()
|