-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
updateInteractions.ts
44 lines (37 loc) · 1.08 KB
/
updateInteractions.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
import _ from "lodash";
import { REST } from "@discordjs/rest";
import { Routes } from "discord-api-types/v9";
import { getLogger, token } from "./utils.js";
export const modules = [
"card",
"hangman",
"standard",
// 'store',
"cr",
"ipg",
"mtr",
"jar",
];
const rest = new REST({ version: "9" }).setToken(token);
const log = getLogger("bot");
const interactions: any = [];
modules.forEach(async (moduleName, index) => {
const module = await import("./modules/" + moduleName + ".js");
const moduleObject = new module.default();
if ("getInteractions" in moduleObject) {
_.forEach(moduleObject.getInteractions(), (value: any, key: any) => {
interactions.push(value.parser.toJSON());
});
}
});
try {
log.info("Finding bot ID");
const identity: any = await rest.get(Routes.user());
log.info("Started refreshing application (/) commands.");
const updateResult = await rest.put(Routes.applicationCommands(identity.id), {
body: interactions,
});
log.info("Successfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}