mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 06:42:51 +02:00
Lots of changes
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class CatCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'cat',
|
||||
aliases: ['neko', 'kitty'],
|
||||
group: 'random-res',
|
||||
memberName: 'cat',
|
||||
description: 'Responds with a random cat image.',
|
||||
clientPermissions: ['ATTACH_FILES']
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://random.cat/meow');
|
||||
return msg.say({ files: [body.file] });
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class DogCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'dog',
|
||||
aliases: ['puppy'],
|
||||
group: 'random-res',
|
||||
memberName: 'dog',
|
||||
description: 'Responds with a random dog image.',
|
||||
clientPermissions: ['ATTACH_FILES']
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://dog.ceo/api/breeds/image/random');
|
||||
return msg.say({ files: [body.message] });
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const nimbats = require('../../assets/json/fidget');
|
||||
|
||||
module.exports = class FidgetCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'fidget',
|
||||
aliases: ['nimbat'],
|
||||
group: 'random-res',
|
||||
memberName: 'fidget',
|
||||
description: 'Responds with a random image of Fidget.',
|
||||
clientPermissions: ['ATTACH_FILES']
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
return msg.say({ files: [nimbats[Math.floor(Math.random() * nimbats.length)]] });
|
||||
}
|
||||
};
|
||||
@@ -1,51 +0,0 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { NYTIMES_KEY } = process.env;
|
||||
|
||||
module.exports = class NewYorkTimesCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'new-york-times',
|
||||
aliases: ['ny-times', 'new-york-times-article', 'ny-times-article'],
|
||||
group: 'random-res',
|
||||
memberName: 'new-york-times',
|
||||
description: 'Responds with an article from the New York Times.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What article do you want to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const fetch = snekfetch
|
||||
.get('https://api.nytimes.com/svc/search/v2/articlesearch.json')
|
||||
.query({
|
||||
'api-key': NYTIMES_KEY,
|
||||
sort: 'newest'
|
||||
});
|
||||
if (query) fetch.query({ q: query });
|
||||
const { body } = await fetch;
|
||||
if (!body.response.docs.length) return msg.say('Could not find any results');
|
||||
const data = body.response.docs[Math.floor(Math.random() * body.response.docs.length)];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xF6F6F6)
|
||||
.setAuthor('New York Times', 'https://i.imgur.com/ZbuTWwO.png')
|
||||
.setURL(data.web_url)
|
||||
.setTitle(data.headline.main)
|
||||
.setDescription(data.snippet)
|
||||
.addField('❯ Publish Date',
|
||||
new Date(data.pub_date).toDateString(), true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const xiaos = require('../../assets/json/xiao');
|
||||
|
||||
module.exports = class XiaoCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'xiao',
|
||||
aliases: ['xiao-pai', 'iao'],
|
||||
group: 'random-res',
|
||||
memberName: 'xiao',
|
||||
description: 'Responds with a random image of Xiao Pai.',
|
||||
clientPermissions: ['ATTACH_FILES']
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
return msg.say({ files: [xiaos[Math.floor(Math.random() * xiaos.length)]] });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user