Skip to content

Commit 05f70f7

Browse files
committed
whateevr
1 parent 8eaba5f commit 05f70f7

1 file changed

Lines changed: 34 additions & 32 deletions

File tree

src/index.ts

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,43 +67,45 @@ const commandFiles = fs
6767
.readdirSync(commandsPath)
6868
.filter((file) => file.endsWith(".js") || file.endsWith(".ts"));
6969

70-
for (const file of commandFiles) {
71-
const filePath = path.join(commandsPath, file);
72-
const command = (await import(pathToFileURL(filePath).href)).default;
73-
if (command != undefined && Object.keys(command).length !== 0) {
74-
client.commands.set(command.data.name, command);
75-
logger.startup(`Loaded command ${chalk.bold(file.replace(/\.[jt]s$/, ''))}`);
76-
} else {
77-
logger.warn(`Couldn't load command ${chalk.bold(file.replace(/\.[jt]s$/, ''))}`);
78-
}
79-
}
80-
8170
const eventsPath = path.join(__dirname, "events");
8271
const eventFiles = fs
8372
.readdirSync(eventsPath)
8473
.filter((file) => file.endsWith(".js") || file.endsWith(".ts"));
8574

86-
for (const file of eventFiles) {
87-
const filePath = path.join(eventsPath, file);
88-
const { once, name, execute } = (await import(pathToFileURL(filePath).href))
89-
.default;
90-
if (once) {
91-
client.once(name, (...args) => execute(client, ...args));
92-
} else {
93-
client.on(name, (...args) => execute(client, ...args));
75+
(async () => {
76+
for (const file of commandFiles) {
77+
const filePath = path.join(commandsPath, file);
78+
const command = (await import(pathToFileURL(filePath).href)).default;
79+
if (command != undefined && Object.keys(command).length !== 0) {
80+
client.commands!.set(command.data.name, command);
81+
logger.startup(`Loaded command ${chalk.bold(file.replace(/\.[jt]s$/, ''))}`);
82+
} else {
83+
logger.warn(`Couldn't load command ${chalk.bold(file.replace(/\.[jt]s$/, ''))}`);
84+
}
85+
}
86+
87+
for (const file of eventFiles) {
88+
const filePath = path.join(eventsPath, file);
89+
const { once, name, execute } = (await import(pathToFileURL(filePath).href))
90+
.default;
91+
if (once) {
92+
client.once(name, (...args) => execute(client, ...args));
93+
} else {
94+
client.on(name, (...args) => execute(client, ...args));
95+
}
96+
logger.startup(`Loaded event ${file.replace(/\.[jt]s$/, '')}`);
9497
}
95-
logger.startup(`Loaded event ${file.replace(/\.[jt]s$/, '')}`);
96-
}
9798

98-
await loadCommands(
99-
client,
100-
process.env.CLIENT_ID,
101-
process.env.BOT_TOKEN,
102-
process.env.GUILD_ID,
103-
);
99+
await loadCommands(
100+
client,
101+
process.env.CLIENT_ID,
102+
process.env.BOT_TOKEN,
103+
process.env.GUILD_ID,
104+
);
104105

105-
try {
106-
client.login(process.env.BOT_TOKEN);
107-
} catch (err) {
108-
console.log(err);
109-
}
106+
try {
107+
client.login(process.env.BOT_TOKEN);
108+
} catch (err) {
109+
console.log(err);
110+
}
111+
})()

0 commit comments

Comments
 (0)