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
|
@ -149,12 +149,16 @@ bot.once("ready", async () => {
|
||||||
logger.info("hf:main", "Connected to Discord.");
|
logger.info("hf:main", "Connected to Discord.");
|
||||||
logger.info("hf:main", `Logged in as: ${formatUsername(bot.user)} (${bot.user.id})`);
|
logger.info("hf:main", `Logged in as: ${formatUsername(bot.user)} (${bot.user.id})`);
|
||||||
|
|
||||||
|
try {
|
||||||
const channel = await bot.getDMChannel(config.owner_id);
|
const channel = await bot.getDMChannel(config.owner_id);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel.createMessage({
|
channel.createMessage({
|
||||||
content: "<:ms_tick:503341995348066313> Loaded HiddenPhox.",
|
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", () => {
|
bot.on("ready", () => {
|
||||||
logger.info("hf:main", "Reconnected to Discord.");
|
logger.info("hf:main", "Reconnected to Discord.");
|
||||||
});
|
});
|
||||||
|
@ -170,6 +174,7 @@ bot.once("ready", async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// stupid hack
|
// stupid hack
|
||||||
|
// FIXME: make send optional, check if it is send
|
||||||
const send = options.shift();
|
const send = options.shift();
|
||||||
options.push(send);
|
options.push(send);
|
||||||
|
|
||||||
|
@ -198,7 +203,11 @@ bot.once("ready", async () => {
|
||||||
commands.push(formattedCommand);
|
commands.push(formattedCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
await bot.requestHandler.request("PUT", APIEndpoints.COMMANDS(bot.application.id), true, commands);
|
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