Begin migrating away from stupid "Oh no, an error occurred!"

This commit is contained in:
Dragon Fire
2024-03-29 23:57:49 -04:00
parent 067545b818
commit 0b807767d1
130 changed files with 1692 additions and 2190 deletions
+5 -9
View File
@@ -40,14 +40,10 @@ module.exports = class GoogleDoodleCommand extends Command {
const now = new Date();
if (latest) month = now.getMonth() + 1;
if (!year) year = now.getFullYear();
try {
const { body } = await request.get(`https://www.google.com/doodles/json/${year}/${month}`);
if (!body.length) return msg.say('Could not find any results.');
const data = body[latest ? 0 : Math.floor(Math.random() * body.length)];
const runDate = moment.utc(data.run_date_array.join('-')).format('MMMM Do, YYYY');
return msg.say(`${runDate}: ${data.share_text}`, { files: [`https:${data.url}`] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
const { body } = await request.get(`https://www.google.com/doodles/json/${year}/${month}`);
if (!body.length) return msg.say('Could not find any results.');
const data = body[latest ? 0 : Math.floor(Math.random() * body.length)];
const runDate = moment.utc(data.run_date_array.join('-')).format('MMMM Do, YYYY');
return msg.say(`${runDate}: ${data.share_text}`, { files: [`https:${data.url}`] });
}
};