-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.ts
63 lines (52 loc) · 1.32 KB
/
mod.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { BOT_ID, BOT_TOKEN } from "./config.ts";
import {
ActivityTypes,
createBot,
enableCachePlugin,
enableCacheSweepers,
fastFileLoader,
GatewayIntents,
startBot,
} from "./deps.ts";
import { events } from "./src/events/mod.ts";
import { updateCommands } from "./src/utils/helpers.ts";
import { logger } from "./src/utils/logger.ts";
const log = logger({ name: "Main" });
log.info("Starting Bot, this might take a while...");
const paths = ["./src/events", "./src/commands"];
export const start = async (sweep = false) => {
await fastFileLoader(paths).catch((err) => {
log.fatal(`Unable to Import ${paths}`);
log.fatal(err);
Deno.exit(1);
});
log.info("Loaded all events and commands");
const bot = enableCachePlugin(
createBot({
token: BOT_TOKEN,
botId: BOT_ID,
intents: GatewayIntents.Guilds,
events,
}),
);
if (sweep) enableCacheSweepers(bot);
bot.gateway.manager.createShardOptions.makePresence = (shardId: number) => {
return {
shardId: shardId,
status: "online",
activities: [
{
name: "josh.evie.dev",
type: ActivityTypes.Watching,
createdAt: Date.now(),
},
],
};
};
await startBot(bot);
await updateCommands(bot);
return bot;
};
if (import.meta.main) {
await start(true);
}