mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
fix(bots/discord): check token before connecting to bot api
This commit is contained in:
@@ -3,19 +3,6 @@ import { getMissingEnvironmentVariables } from '@revanced/bot-shared'
|
||||
import { api, discord, logger } from './context'
|
||||
import { listAllFilesRecursive, pathJoinCurrentDir } from './utils/fs'
|
||||
|
||||
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) {
|
||||
@@ -23,4 +10,14 @@ if (missingEnvs.length) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
await discordClient.login()
|
||||
for (const event of listAllFilesRecursive(pathJoinCurrentDir(import.meta.url, 'events', 'api'))) {
|
||||
await import(event)
|
||||
}
|
||||
|
||||
await api.client.connect()
|
||||
|
||||
for (const event of listAllFilesRecursive(pathJoinCurrentDir(import.meta.url, 'events', 'discord'))) {
|
||||
await import(event)
|
||||
}
|
||||
|
||||
await discord.client.login()
|
||||
|
||||
Reference in New Issue
Block a user