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