Skip to content

Commit 48cc1af

Browse files
committed
added try catch
1 parent df6cddb commit 48cc1af

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

src/libs/loadCommands.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,29 @@ export async function loadCommands(
5050

5151
const rest = new REST().setToken(token);
5252

53-
if (guildId) {
54-
logger.info(`Loading Server (${chalk.grey(guildId)}) commands...`);
55-
await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
56-
body: [],
57-
});
53+
try {
54+
if (guildId) {
55+
logger.info(`Loading Server (${chalk.grey(guildId)}) commands...`);
56+
await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
57+
body: [],
58+
});
5859

59-
await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
60-
body: commandData,
61-
});
62-
logger.info("Completed!");
63-
} else {
64-
logger.info("Loading Global commands...");
65-
await rest.put(Routes.applicationCommands(clientId), {
66-
body: [],
67-
});
60+
await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
61+
body: commandData,
62+
});
63+
logger.info("Completed!");
64+
} else {
65+
logger.info("Loading Global commands...");
66+
await rest.put(Routes.applicationCommands(clientId), {
67+
body: [],
68+
});
6869

69-
await rest.put(Routes.applicationCommands(clientId), {
70-
body: commandData,
71-
});
72-
logger.info("Completed");
70+
await rest.put(Routes.applicationCommands(clientId), {
71+
body: commandData,
72+
});
73+
logger.info("Completed");
74+
}
75+
} catch (err) {
76+
logger.fatal("An error occured while loading commands", err)
7377
}
7478
}

0 commit comments

Comments
 (0)