mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 14:00:22 +02:00
Antidepressant or Tolkien? Command
This commit is contained in:
@@ -24,9 +24,9 @@ module.exports = class AiFoodCommand extends Command {
|
||||
try {
|
||||
const { text } = await request.get('https://thissnackdoesnotexist.com/');
|
||||
const $ = cheerio.load(text);
|
||||
const img = $('div[class="Absolute-Center"]').first().attr('style').match(/background-image:url\((.+)\);/i)[1];
|
||||
const img = $('div[class="Absolute-Center"]').first().attr('style').match(/background-image:url\((.+)\);/i);
|
||||
const name = $('h1[class="snack-description"]').first().text();
|
||||
return msg.say(`AI-Generated Food: ${name}`, { files: [{ attachment: img, name: 'ai-food.jpg' }] });
|
||||
return msg.say(`AI-Generated Food: ${name}`, img ? { files: [{ attachment: img, name: 'ai-food.jpg' }] } : {});
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user