Finish removing "Oh no, an error occurred"

This commit is contained in:
Dragon Fire
2024-03-30 11:59:42 -04:00
parent f6b59c2d46
commit a135cac031
119 changed files with 3418 additions and 4116 deletions
+8 -12
View File
@@ -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]] });
}
};
+15 -19
View File
@@ -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}` }]
});
}
};
+5 -9
View File
@@ -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] });
}
};
+5 -9
View File
@@ -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] });
}
};
+2 -6
View File
@@ -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] });
}
};
+2 -6
View File
@@ -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] });
}
};
+2 -6
View File
@@ -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] });
}
};
+4 -8
View File
@@ -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] });
}
};
+6 -10
View File
@@ -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')}`]
});
}
};
+2 -6
View File
@@ -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] });
}
};
+2 -6
View File
@@ -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` }] });
}
};
+8 -12
View File
@@ -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]] });
}
};