28 lines
611 B
TypeScript
28 lines
611 B
TypeScript
|
#!/usr/bin/env tsx
|
||
|
|
||
|
import { onShutdown } from "node-graceful-shutdown";
|
||
|
import { createBot } from "../index.js";
|
||
|
import { config } from "#root/config.js";
|
||
|
import { logger } from "#root/logger.js";
|
||
|
|
||
|
try {
|
||
|
const bot = createBot(config.BOT_TOKEN);
|
||
|
|
||
|
// Graceful shutdown
|
||
|
onShutdown(async () => {
|
||
|
logger.info("shutdown");
|
||
|
await bot.stop();
|
||
|
});
|
||
|
|
||
|
await bot.start({
|
||
|
onStart: ({ username }) =>
|
||
|
logger.info({
|
||
|
msg: "bot running...",
|
||
|
username,
|
||
|
}),
|
||
|
});
|
||
|
} catch (error) {
|
||
|
logger.error(error);
|
||
|
process.exit(1);
|
||
|
}
|