-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
44 lines (34 loc) · 1.15 KB
/
bot.js
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
import interactions from "./util/interactions.js";
import { Client, GatewayIntentBits } from "discord.js";
import { readConfig } from "./util/general.js";
export default class ClassBot {
#client = new Client({ intents: [GatewayIntentBits.Guilds] });
async initBot() {
const { token } = await readConfig();
this.#client.once(`ready`, () => {
console.log(`i am ${this.#client.user.tag}`);
});
this.#client.on(`interactionCreate`, async interaction => {
if (!interaction.isChatInputCommand()) return;
if (!interactions[interaction.commandName]) {
await interaction.reply(`its missing`);
return;
}
await interactions[interaction.commandName](interaction);
});
await this.#client.login(token);
}
async sendSuccessMessage(last, current, courseName, channelId, users) {
if (users === undefined || users === null) {
// me if not there
users = [`206476533135704064`];
}
const channel = await this.#client.channels.fetch(channelId);
const userTags = users.map(u => `<@${u}>`).join(` `);
await channel.send(
`${userTags} Class \`${courseName}\` was \`${
last ? last : `N/A`
}\`, now is \`${current}\``
);
}
}