mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Use TheDogAPI
This commit is contained in:
@@ -39,6 +39,7 @@ GOV_KEY=
|
||||
SPOTIFY_KEY=
|
||||
SPOTIFY_SECRET=
|
||||
THECATAPI_KEY=
|
||||
THEDOGAPI_KEY=
|
||||
WEBSTER_KEY=
|
||||
XIAO_GITHUB_REPO_NAME=
|
||||
XIAO_GITHUB_REPO_USERNAME=
|
||||
|
||||
@@ -27,10 +27,7 @@ module.exports = class CatCommand extends Command {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.thecatapi.com/v1/images/search')
|
||||
.query({
|
||||
limit: 1,
|
||||
mime_types: 'jpg,png'
|
||||
})
|
||||
.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) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const facts = require('../../assets/json/dog-fact');
|
||||
const { THEDOGAPI_KEY } = process.env;
|
||||
|
||||
module.exports = class DogCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -13,10 +14,10 @@ module.exports = class DogCommand extends Command {
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Dog CEO',
|
||||
url: 'https://dog.ceo/',
|
||||
reason: 'Dog API',
|
||||
reasonURL: 'https://dog.ceo/dog-api/'
|
||||
name: 'TheDogAPI',
|
||||
url: 'https://thedogapi.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://docs.thedogapi.com/'
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -24,8 +25,11 @@ module.exports = class DogCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request.get('https://dog.ceo/api/breeds/image/random');
|
||||
return msg.say(facts[Math.floor(Math.random() * facts.length)], { files: [body.message] });
|
||||
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!`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user