-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbot.ts
37 lines (32 loc) · 1.06 KB
/
bot.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Bot, createBot, startBot } from "./deps.ts"
import { log } from "./log.ts"
import { StableJourneyBotOptions } from "./types/botOptions.ts"
import { refreshCommands } from "./utils.ts"
export class StableJourneyBot {
private readonly options: StableJourneyBotOptions
private readonly bot: Bot
constructor(options: StableJourneyBotOptions) {
const { DISCORD_TOKEN } = options
this.options = options
this.bot = createBot({
token: DISCORD_TOKEN,
intents: undefined,
})
}
private setup = async () => {
try {
await refreshCommands(this.bot, this.options)
} catch (err) {
log.error("Error occurred when setting up bot:", err)
log.error("Please check your config file or server status and try again!")
Deno.exit(1)
}
this.bot.events.ready = () => {
log.success("Successfully connected to gateway")
}
}
start = async () => {
await this.setup()
await startBot(this.bot)
}
}