forked from sunnniee/Buno
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ts
73 lines (60 loc) · 2.72 KB
/
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
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
66
67
68
69
70
71
72
73
import { Client, Collection, GatewayIntentBits } from "discord.js";
import { configDotenv } from "dotenv";
import { readdirSync } from "fs";
import { buttonFile } from "./typings/button.js";
import { commandFile } from "./typings/command.js";
import { eventFile } from "./typings/event.js";
import { modalFile } from "./typings/modal.js";
import { stringSelectFile } from "./typings/stringSelect.js";
import initI18n from "./utils/i18n/initI18n.js";
configDotenv();
Error.stackTraceLimit = Infinity;
initI18n();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
client.games = [];
const events = readdirSync(import.meta.dirname + "/events");
events.forEach(async (name: string) => {
if (!name.endsWith(".js") && !name.endsWith(".ts")) return;
const { e } = await import("file://" + import.meta.dirname + "/events/" + name) as eventFile;
const propername = name.split(".")[0];
client.on(propername, (...args) => e(client, ...args));
});
client.commands = new Collection();
const commands = readdirSync(import.meta.dirname + "/commands");
commands.forEach(async (name: string) => {
if (!name.endsWith(".js") && !name.endsWith(".ts")) return;
const { c } = await import("file://" + import.meta.dirname + "/commands/" + name) as commandFile;
const propername = name.split(".")[0];
client.commands.set(propername, c);
});
client.buttons = new Collection();
const buttons = readdirSync(import.meta.dirname + "/interactions/buttons/");
buttons.forEach(async (name: string) => {
if (!name.endsWith(".js") && !name.endsWith(".ts")) return;
const { b } = await import("file://" + import.meta.dirname + "/interactions/buttons/" + name) as buttonFile;
client.buttons.set(b.name, b);
});
client.stringSelects = new Collection();
const stringSelects = readdirSync(import.meta.dirname + "/interactions/stringSelects/");
stringSelects.forEach(async (name: string) => {
if (!name.endsWith(".js") && !name.endsWith(".ts")) return;
const { s } = await import("file://" + import.meta.dirname + "/interactions/stringSelects/" + name) as stringSelectFile;
client.stringSelects.set(s.name, s);
});
client.modals = new Collection();
const modals = readdirSync(import.meta.dirname + "/interactions/modals/");
modals.forEach(async (name: string) => {
if (!name.endsWith(".js") && !name.endsWith(".ts")) return;
const { m } = await import("file://" + import.meta.dirname + "/interactions/modals/" + name) as modalFile;
client.modals.set(m.name, m);
});
client.login(process.env.TOKEN);
client.on("error", console.error);
process.on("unhandledRejection", console.error);