mirror of
https://github.com/Mestima/luna.git
synced 2025-05-05 21:50:15 +00:00
cat & fox api request timeout set 1s, answer and log on bad request
This commit is contained in:
parent
4e27150999
commit
b2b1f5c09b
@ -1,4 +1,7 @@
|
||||
import axios from 'axios';
|
||||
import chalk from 'chalk';
|
||||
|
||||
axios.defaults.timeout = 1000;
|
||||
|
||||
const cat = async () => {
|
||||
return await axios.get('https://aws.random.cat/meow')
|
||||
@ -6,7 +9,7 @@ const cat = async () => {
|
||||
return res.data.file;
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
console.log(`${chalk.red('Error:')} the Cat API is unavailable`);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
import axios from 'axios';
|
||||
import chalk from 'chalk';
|
||||
|
||||
axios.defaults.timeout = 1000;
|
||||
|
||||
const fox = async () => {
|
||||
return await axios.get('https://randomfox.ca/floof/')
|
||||
@ -6,7 +9,7 @@ const fox = async () => {
|
||||
return res.data.image;
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
console.log(`${chalk.red('Error:')} the Fox API is unavailable`);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
@ -8,6 +8,12 @@ export default {
|
||||
await api.get('cat')()
|
||||
.then(async (res) => {
|
||||
await interaction.reply(res);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Sorry, the Cat service is unavailable right now')
|
||||
.setColor(0xFF0000);
|
||||
await interaction.reply({ embeds: [ embed ] });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
@ -8,6 +8,12 @@ export default {
|
||||
await api.get('fox')()
|
||||
.then(async (res) => {
|
||||
await interaction.reply(res);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Sorry, the Fox service is unavailable right now')
|
||||
.setColor(0xFF0000);
|
||||
await interaction.reply({ embeds: [ embed ] });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user