add some error handling to startup in case of api breakage
This commit is contained in:
parent
ba7a050220
commit
3d7b026f4c
1 changed files with 15 additions and 6 deletions
21
src/index.js
21
src/index.js
|
@ -149,11 +149,15 @@ bot.once("ready", async () => {
|
|||
logger.info("hf:main", "Connected to Discord.");
|
||||
logger.info("hf:main", `Logged in as: ${formatUsername(bot.user)} (${bot.user.id})`);
|
||||
|
||||
const channel = await bot.getDMChannel(config.owner_id);
|
||||
if (channel) {
|
||||
channel.createMessage({
|
||||
content: "<:ms_tick:503341995348066313> Loaded HiddenPhox.",
|
||||
});
|
||||
try {
|
||||
const channel = await bot.getDMChannel(config.owner_id);
|
||||
if (channel) {
|
||||
channel.createMessage({
|
||||
content: "<:ms_tick:503341995348066313> Loaded HiddenPhox.",
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error("hf:main", `Failed to send startup message, API probably broken currently.\n${err}`);
|
||||
}
|
||||
bot.on("ready", () => {
|
||||
logger.info("hf:main", "Reconnected to Discord.");
|
||||
|
@ -170,6 +174,7 @@ bot.once("ready", async () => {
|
|||
}
|
||||
|
||||
// stupid hack
|
||||
// FIXME: make send optional, check if it is send
|
||||
const send = options.shift();
|
||||
options.push(send);
|
||||
|
||||
|
@ -198,7 +203,11 @@ bot.once("ready", async () => {
|
|||
commands.push(formattedCommand);
|
||||
}
|
||||
|
||||
await bot.requestHandler.request("PUT", APIEndpoints.COMMANDS(bot.application.id), true, commands);
|
||||
try {
|
||||
await bot.requestHandler.request("PUT", APIEndpoints.COMMANDS(bot.application.id), true, commands);
|
||||
} catch (err) {
|
||||
logger.error("hf:main", `Failed to update interaction commands, API probably broken currently.\n${err}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue