forked from embee/woomy
dont silently fail when API fetch fails
This commit is contained in:
parent
2481dacb91
commit
2564f742d4
11 changed files with 39 additions and 7 deletions
|
@ -5,6 +5,9 @@ exports.run = async (bot, message, args) => {
|
||||||
fetch('https://catfact.ninja/facts')
|
fetch('https://catfact.ninja/facts')
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => message.channel.send(`__**Did you know?**__\n${json.data[0].fact}`))
|
.then(json => message.channel.send(`__**Did you know?**__\n${json.data[0].fact}`))
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
});
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,10 @@ exports.run = async (bot, message, args) => {
|
||||||
try{
|
try{
|
||||||
fetch('https://dog-api.kinduff.com/api/facts')
|
fetch('https://dog-api.kinduff.com/api/facts')
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => message.channel.send(`__**Did you know?**__\n ${json.facts[0]}`));
|
.then(json => message.channel.send(`__**Did you know?**__\n ${json.facts[0]}`))
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
});
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,9 @@ exports.run = async (client, message) => {
|
||||||
.setURL('https://www.mezzacotta.net/garfield/?comic=' + json.data.number)
|
.setURL('https://www.mezzacotta.net/garfield/?comic=' + json.data.number)
|
||||||
.setImage(json.data.image.src);
|
.setImage(json.data.image.src);
|
||||||
message.channel.send(embed)
|
message.channel.send(embed)
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
});
|
});
|
||||||
message.channel.stopTyping();
|
message.channel.stopTyping();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -4,7 +4,10 @@ exports.run = async (client, message) => {
|
||||||
try {
|
try {
|
||||||
fetch('http://inspirobot.me/api?generate=true')
|
fetch('http://inspirobot.me/api?generate=true')
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(body => message.channel.send({files: [new Discord.MessageAttachment(body)]}));
|
.then(body => message.channel.send({files: [new Discord.MessageAttachment(body)]}))
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
});
|
||||||
message.channel.stopTyping();
|
message.channel.stopTyping();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`)
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`)
|
||||||
|
|
|
@ -4,7 +4,10 @@ exports.run = async (client, message, args) => {
|
||||||
try{
|
try{
|
||||||
fetch(`https://purrbot.site/api/img/sfw/kitsune/img/`)
|
fetch(`https://purrbot.site/api/img/sfw/kitsune/img/`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => message.channel.send(json.link));
|
.then(json => message.channel.send(json.link))
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
});
|
||||||
message.channel.stopTyping();
|
message.channel.stopTyping();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
|
|
@ -4,7 +4,10 @@ exports.run = async (client, message, args) => {
|
||||||
try{
|
try{
|
||||||
fetch(`https://purrbot.site/api/img/sfw/neko/img/`)
|
fetch(`https://purrbot.site/api/img/sfw/neko/img/`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => message.channel.send(json.link));
|
.then(json => message.channel.send(json.link))
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
});
|
||||||
message.channel.stopTyping();
|
message.channel.stopTyping();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
|
|
@ -4,7 +4,10 @@ exports.run = async (client, message, args) => {
|
||||||
try{
|
try{
|
||||||
fetch(`https://purrbot.site/api/img/sfw/neko/gif/`)
|
fetch(`https://purrbot.site/api/img/sfw/neko/gif/`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => message.channel.send(json.link));
|
.then(json => message.channel.send(json.link))
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
});
|
||||||
message.channel.stopTyping();
|
message.channel.stopTyping();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
|
|
@ -13,6 +13,8 @@ exports.run = (client, message) => {// eslint-disable-line no-unused-vars
|
||||||
method: 'post',
|
method: 'post',
|
||||||
body: JSON.stringify({ 'signal': 'restart' }),
|
body: JSON.stringify({ 'signal': 'restart' }),
|
||||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${client.config.server}` }
|
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${client.config.server}` }
|
||||||
|
}).catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ exports.run = (client, message) => {
|
||||||
fetch('http://mityurl.com/y/yKsQ/r', { redirect: 'follow' })
|
fetch('http://mityurl.com/y/yKsQ/r', { redirect: 'follow' })
|
||||||
.then(res => res)
|
.then(res => res)
|
||||||
.then(res => message.channel.send(`>:] ${res.url}`))
|
.then(res => message.channel.send(`>:] ${res.url}`))
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
});
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,10 @@ exports.run = async (client, message, args) => {
|
||||||
try{
|
try{
|
||||||
fetch(`https://purrbot.site/api/img/sfw/tail/gif/`)
|
fetch(`https://purrbot.site/api/img/sfw/tail/gif/`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => message.channel.send(json.link));
|
.then(json => message.channel.send(json.link))
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
});
|
||||||
message.channel.stopTyping();
|
message.channel.stopTyping();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
|
|
@ -9,7 +9,10 @@ exports.run = async (client, message, args) => {
|
||||||
try{
|
try{
|
||||||
fetch(`http://yoda-api.appspot.com/api/v1/yodish?text=${encodeURIComponent(speech.toLowerCase())}`)
|
fetch(`http://yoda-api.appspot.com/api/v1/yodish?text=${encodeURIComponent(speech.toLowerCase())}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => message.channel.send(json.yodish));
|
.then(json => message.channel.send(json.yodish))
|
||||||
|
.catch(err => {
|
||||||
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
});
|
||||||
message.channel.stopTyping();
|
message.channel.stopTyping();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`);
|
||||||
|
|
Loading…
Reference in a new issue