-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.ts
65 lines (50 loc) · 1.58 KB
/
client.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
64
65
import "dotenv/config";
import {
ActivityGroupLoader,
setConsoleEvent,
useActivityGroup,
} from "cocoa-discord-utils";
import { MessageCenter } from "cocoa-discord-utils/message";
import { SlashCenter } from "cocoa-discord-utils/slash";
import { CocoaOptions } from "cocoa-discord-utils/template";
import { Client } from "discord.js";
import chalk from "chalk";
import { loadProblems } from "../grader/problems";
import { CocoaMsg } from "./commands/message";
import { Cocoa } from "./commands/slash";
loadProblems();
const client = new Client(CocoaOptions);
const msgcenter = new MessageCenter(client, { mention: true });
msgcenter.addCog(CocoaMsg);
msgcenter.validateCommands();
const slashcenter = new SlashCenter(
client,
process.env.GUILD_IDS?.split(",") ?? []
);
slashcenter.addCog(Cocoa);
slashcenter.validateCommands();
const groupLoader = new ActivityGroupLoader("data/activities.json");
client.on("ready", (cli) => {
console.log(
chalk.cyan(`ココアお姉ちゃん 「${cli.user.tag}」 は準備完了です`)
);
slashcenter.syncCommands();
useActivityGroup(client, groupLoader);
});
client.login(process.env.DISCORD_TOKEN);
// * Console Zone
setConsoleEvent((cmd: string) => {
if (cmd.startsWith("logout")) {
client.destroy();
console.log(chalk.cyan("Logged out Successfully!"));
process.exit(0);
}
if (cmd.startsWith("reload")) {
loadProblems();
groupLoader.reload();
return;
}
console.log(
chalk.yellow(`[Console WARN] Unknown Command ${cmd.split(" ")[0]}`)
);
});