mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
Finish removing "Oh no, an error occurred"
This commit is contained in:
@@ -21,17 +21,13 @@ module.exports = class BirdCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://shibe.online/api/birds')
|
||||
.query({
|
||||
count: 1,
|
||||
urls: true,
|
||||
httpsUrls: true
|
||||
});
|
||||
return msg.say({ files: [body[0]] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request
|
||||
.get('https://shibe.online/api/birds')
|
||||
.query({
|
||||
count: 1,
|
||||
urls: true,
|
||||
httpsUrls: true
|
||||
});
|
||||
return msg.say({ files: [body[0]] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,25 +22,21 @@ module.exports = class BunnyCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.bunnies.io/v2/loop/random/')
|
||||
.query({ media: 'gif,png' });
|
||||
let fileToSend;
|
||||
let fileType = 'gif';
|
||||
const gif = await request.get(body.media.gif);
|
||||
if (Buffer.byteLength(gif.body) > 8e+6) {
|
||||
const poster = await request.get(body.media.poster);
|
||||
fileToSend = poster.body;
|
||||
fileType = 'png';
|
||||
} else {
|
||||
fileToSend = gif.body;
|
||||
}
|
||||
return msg.say(facts[Math.floor(Math.random() * facts.length)], {
|
||||
files: [{ attachment: fileToSend, name: `${body.id}.${fileType}` }]
|
||||
});
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
const { body } = await request
|
||||
.get('https://api.bunnies.io/v2/loop/random/')
|
||||
.query({ media: 'gif,png' });
|
||||
let fileToSend;
|
||||
let fileType = 'gif';
|
||||
const gif = await request.get(body.media.gif);
|
||||
if (Buffer.byteLength(gif.body) > 8e+6) {
|
||||
const poster = await request.get(body.media.poster);
|
||||
fileToSend = poster.body;
|
||||
fileType = 'png';
|
||||
} else {
|
||||
fileToSend = gif.body;
|
||||
}
|
||||
return msg.say(facts[Math.floor(Math.random() * facts.length)], {
|
||||
files: [{ attachment: fileToSend, name: `${body.id}.${fileType}` }]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,14 +24,10 @@ module.exports = class CatCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.thecatapi.com/v1/images/search')
|
||||
.query({ limit: 1 })
|
||||
.set({ 'x-api-key': THECATAPI_KEY });
|
||||
return msg.say(facts[Math.floor(Math.random() * facts.length)], { files: [body[0].url] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request
|
||||
.get('https://api.thecatapi.com/v1/images/search')
|
||||
.query({ limit: 1 })
|
||||
.set({ 'x-api-key': THECATAPI_KEY });
|
||||
return msg.say(facts[Math.floor(Math.random() * facts.length)], { files: [body[0].url] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,14 +24,10 @@ module.exports = class DogCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.thedogapi.com/v1/images/search')
|
||||
.query({ limit: 1 })
|
||||
.set({ 'x-api-key': THEDOGAPI_KEY });
|
||||
return msg.say(facts[Math.floor(Math.random() * facts.length)], { files: [body[0].url] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request
|
||||
.get('https://api.thedogapi.com/v1/images/search')
|
||||
.query({ limit: 1 })
|
||||
.set({ 'x-api-key': THEDOGAPI_KEY });
|
||||
return msg.say(facts[Math.floor(Math.random() * facts.length)], { files: [body[0].url] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,11 +22,7 @@ module.exports = class DuckCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request.get('https://random-d.uk/api/v1/random');
|
||||
return msg.say({ files: [body.url] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request.get('https://random-d.uk/api/v1/random');
|
||||
return msg.say({ files: [body.url] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,11 +20,7 @@ module.exports = class FoxCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request.get('https://randomfox.ca/floof/');
|
||||
return msg.say({ files: [body.image] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request.get('https://randomfox.ca/floof/');
|
||||
return msg.say({ files: [body.image] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,11 +21,7 @@ module.exports = class GooseCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request.get('https://nekos.life/api/v2/img/goose');
|
||||
return msg.say({ files: [body.url] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request.get('https://nekos.life/api/v2/img/goose');
|
||||
return msg.say({ files: [body.url] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,13 +21,9 @@ module.exports = class InspirationCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await request
|
||||
.get('https://inspirobot.me/api')
|
||||
.query({ generate: true });
|
||||
return msg.say({ files: [text] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { text } = await request
|
||||
.get('https://inspirobot.me/api')
|
||||
.query({ generate: true });
|
||||
return msg.say({ files: [text] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,15 +22,11 @@ module.exports = class LightNovelCoverCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await request.get('https://salty-salty-studios.com/shiz/lncovers.php');
|
||||
const $ = cheerio.load(text);
|
||||
const cover = $('img').first();
|
||||
return msg.say(cover.attr('alt'), {
|
||||
files: [`https://salty-salty-studios.com/shiz/${cover.attr('src')}`]
|
||||
});
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { text } = await request.get('https://salty-salty-studios.com/shiz/lncovers.php');
|
||||
const $ = cheerio.load(text);
|
||||
const cover = $('img').first();
|
||||
return msg.say(cover.attr('alt'), {
|
||||
files: [`https://salty-salty-studios.com/shiz/${cover.attr('src')}`]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,11 +20,7 @@ module.exports = class LizardCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request.get('https://nekos.life/api/v2/img/lizard');
|
||||
return msg.say({ files: [body.url] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request.get('https://nekos.life/api/v2/img/lizard');
|
||||
return msg.say({ files: [body.url] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,11 +42,7 @@ module.exports = class LoremPicsumCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { width, height, seed }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://picsum.photos/${seed ? `seed/${seed}/` : ''}${width}/${height}`);
|
||||
return msg.say({ files: [{ attachment: body, name: `${width}x${height}.jpg` }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request.get(`https://picsum.photos/${seed ? `seed/${seed}/` : ''}${width}/${height}`);
|
||||
return msg.say({ files: [{ attachment: body, name: `${width}x${height}.jpg` }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,17 +21,13 @@ module.exports = class ShibaCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://shibe.online/api/shibes')
|
||||
.query({
|
||||
count: 1,
|
||||
urls: true,
|
||||
httpsUrls: true
|
||||
});
|
||||
return msg.say({ files: [body[0]] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request
|
||||
.get('https://shibe.online/api/shibes')
|
||||
.query({
|
||||
count: 1,
|
||||
urls: true,
|
||||
httpsUrls: true
|
||||
});
|
||||
return msg.say({ files: [body[0]] });
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user