-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
38 lines (33 loc) · 1003 Bytes
/
index.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
import * as Discord from "discord.js";
import CommandManager from "./commands";
const client = new Discord.Client();
const GENERAL_CHANNEL_ID = "439847766454173697";
let generalChannel: Discord.TextChannel;
let commandManager: CommandManager;
client.once("ready", () => {
commandManager = new CommandManager(
client.user!.id,
process.env.CUSTOM_COMMANDS_FILEPATH ?? "./commands.json"
);
client.channels
.fetch(GENERAL_CHANNEL_ID)
.then(chan => {
if (chan.type === "text") {
generalChannel = chan as Discord.TextChannel;
generalChannel.send("🤖 COMPUTRON HAS BEEN UPDATED 🤖");
}
})
.catch(err => console.error(err));
});
client.on("message", msg => {
if (msg.partial) {
return;
}
// TODO: we should have a custom type gate for this
const finalMsg = msg as Discord.Message;
commandManager.parseMessage(finalMsg);
});
client.once("disconnect", () => {
generalChannel.send("🤖 I WAS JUST LEARNING TO LOVE 🤖");
});
client.login(process.env.DISCORD_TOKEN);