mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-15 08:22:37 +02:00
Updates
This commit is contained in:
@@ -10,7 +10,7 @@ module.exports = class BotInfoCommand extends Command {
|
||||
aliases: ['discord-bots', 'dbots'],
|
||||
group: 'search',
|
||||
memberName: 'bot-info',
|
||||
description: 'Searches Discord Bots for information on a bot.',
|
||||
description: 'Responds with information on a specific Discord bot.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ module.exports = class BulbapediaCommand extends Command {
|
||||
.setTitle(data.title)
|
||||
.setAuthor('Bulbapedia', 'https://i.imgur.com/ePpoeFA.png')
|
||||
.setThumbnail(data.thumbnail ? data.thumbnail.source : null)
|
||||
.setURL(`https://bulbapedia.bulbagarden.net/wiki/${encodeURIComponent(query.replace(/\)/g, '%29'))}`)
|
||||
.setURL(`https://bulbapedia.bulbagarden.net/wiki/${encodeURIComponent(query).replace(/\)/g, '%29')}`)
|
||||
.setDescription(shorten(data.extract.replace(/\n/g, '\n\n')));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
|
||||
@@ -13,19 +13,19 @@ module.exports = class DictionaryCommand extends Command {
|
||||
description: 'Defines a word.',
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
key: 'word',
|
||||
prompt: 'What word would you like to look up?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
parse: word => encodeURIComponent(word)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
async run(msg, { word }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.wordnik.com/v4/word.json/${query}/definitions`)
|
||||
.get(`http://api.wordnik.com/v4/word.json/${word}/definitions`)
|
||||
.query({
|
||||
limit: 1,
|
||||
includeRelated: false,
|
||||
|
||||
@@ -11,7 +11,7 @@ module.exports = class GitHubCommand extends Command {
|
||||
aliases: ['github-repository', 'github-repo', 'git-repo'],
|
||||
group: 'search',
|
||||
memberName: 'github',
|
||||
description: 'Searches GitHub for information on a repository.',
|
||||
description: 'Responds with information on a GitHub repository.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports = class GoogleAutofillCommand extends Command {
|
||||
aliases: ['google-autocomplete', 'autofill', 'autocomplete'],
|
||||
group: 'search',
|
||||
memberName: 'google-autofill',
|
||||
description: 'Gets a list of Google Autofill results for a particular query.',
|
||||
description: 'Responds with a list of the Google Autofill results for a particular query.',
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
|
||||
@@ -12,7 +12,7 @@ module.exports = class JishoCommand extends Command {
|
||||
description: 'Defines a word, but with Japanese.',
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
key: 'word',
|
||||
prompt: 'What word would you like to look up?',
|
||||
type: 'string'
|
||||
}
|
||||
@@ -20,11 +20,11 @@ module.exports = class JishoCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
async run(msg, { word }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://jisho.org/api/v1/search/words')
|
||||
.query({ keyword: query });
|
||||
.query({ keyword: word });
|
||||
if (!body.data.length) return msg.say('Could not find any results.');
|
||||
const data = body.data[0];
|
||||
return msg.say(stripIndents`
|
||||
|
||||
@@ -8,10 +8,10 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'league-of-legends-champion',
|
||||
aliases: ['lol-champion', 'champion', 'league-of-legends-champ', 'lol-champ', 'champ'],
|
||||
aliases: ['lol-champion', 'league-of-legends-champ', 'lol-champ'],
|
||||
group: 'search',
|
||||
memberName: 'league-of-legends-champion',
|
||||
description: 'Gets information on a League of Legends champion.',
|
||||
description: 'Responds with information on a League of Legends champion.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
@@ -79,9 +79,9 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command {
|
||||
.addField('❯ Spell Block',
|
||||
`${data.stats.spellblock} (${data.stats.spellblockperlevel}/level)`, true)
|
||||
.addField('❯ Passive',
|
||||
data.passive.name)
|
||||
data.passive.name, true)
|
||||
.addField('❯ Spells',
|
||||
data.spells.map((spell, i) => `${spell.name} (${buttons[i]})`).join('\n'));
|
||||
data.spells.map((spell, i) => `${spell.name} (${buttons[i]})`).join('\n'), true);
|
||||
return msg.say(`Tip: ${tips[Math.floor(Math.random() * tips.length)]}`, { embed });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = class MapCommand extends Command {
|
||||
aliases: ['google-maps', 'google-map'],
|
||||
group: 'search',
|
||||
memberName: 'map',
|
||||
description: 'Responds with a map based upon your query.',
|
||||
description: 'Responds with a map of a specific location.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
@@ -21,7 +21,7 @@ module.exports = class MapCommand extends Command {
|
||||
max: 20
|
||||
},
|
||||
{
|
||||
key: 'query',
|
||||
key: 'location',
|
||||
prompt: 'What location would you like to get a map of?',
|
||||
type: 'string'
|
||||
}
|
||||
@@ -29,17 +29,17 @@ module.exports = class MapCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { zoom, query }) {
|
||||
async run(msg, { zoom, location }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://maps.googleapis.com/maps/api/staticmap')
|
||||
.query({
|
||||
center: query,
|
||||
center: location,
|
||||
zoom,
|
||||
size: '500x500',
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
const url = `https://www.google.com/maps/search/${encodeURIComponent(query)}`;
|
||||
const url = `https://www.google.com/maps/search/${encodeURIComponent(location)}`;
|
||||
return msg.say(`<${url}>`, { files: [{ attachment: body, name: 'map.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = class NASACommand extends Command {
|
||||
aliases: ['nasa-image'],
|
||||
group: 'search',
|
||||
memberName: 'nasa',
|
||||
description: 'Responds with an image from NASA based upon your query.',
|
||||
description: 'Search NASA\'s image archive for your query.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
|
||||
@@ -8,10 +8,10 @@ module.exports = class NeopetCommand extends Command {
|
||||
aliases: ['neopet-image', 'neopet-image-finder'],
|
||||
group: 'search',
|
||||
memberName: 'neopet',
|
||||
description: 'Searches for Neopets with the username of your query.',
|
||||
description: 'Responds with the image of a specific Neopet.',
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
key: 'pet',
|
||||
prompt: 'What pet would you like to get an image of?',
|
||||
type: 'string'
|
||||
}
|
||||
@@ -19,12 +19,12 @@ module.exports = class NeopetCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
async run(msg, { pet }) {
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get('http://www.sunnyneo.com/petimagefinder.php')
|
||||
.query({
|
||||
name: query,
|
||||
name: pet,
|
||||
size: 5,
|
||||
mood: 1
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ module.exports = class NewYorkTimesCommand extends Command {
|
||||
aliases: ['ny-times', 'new-york-times-article', 'ny-times-article'],
|
||||
group: 'search',
|
||||
memberName: 'new-york-times',
|
||||
description: 'Responds with an article from the New York Times.',
|
||||
description: 'Searches the New York Times for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
|
||||
@@ -10,22 +10,23 @@ module.exports = class NPMCommand extends Command {
|
||||
aliases: ['npm-package'],
|
||||
group: 'search',
|
||||
memberName: 'npm',
|
||||
description: 'Gets information on an NPM package.',
|
||||
description: 'Responds with information on an NPM package.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
key: 'pkg',
|
||||
label: 'package',
|
||||
prompt: 'What package would you like to get information on?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query.replace(/ /g, '-'))
|
||||
parse: pkg => encodeURIComponent(pkg.replace(/ /g, '-'))
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
async run(msg, { pkg }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(`https://registry.npmjs.com/${query}`);
|
||||
const { body } = await snekfetch.get(`https://registry.npmjs.com/${pkg}`);
|
||||
const version = body.versions[body['dist-tags'].latest];
|
||||
const maintainers = trimArray(body.maintainers.map(user => user.name));
|
||||
const dependencies = version.dependencies ? trimArray(Object.keys(version.dependencies)) : null;
|
||||
@@ -33,7 +34,7 @@ module.exports = class NPMCommand extends Command {
|
||||
.setColor(0xCB0000)
|
||||
.setAuthor('NPM', 'https://i.imgur.com/ErKf5Y0.png')
|
||||
.setTitle(body.name)
|
||||
.setURL(`https://www.npmjs.com/package/${query}`)
|
||||
.setURL(`https://www.npmjs.com/package/${pkg}`)
|
||||
.setDescription(body.description || 'No description.')
|
||||
.addField('❯ Version',
|
||||
body['dist-tags'].latest, true)
|
||||
|
||||
@@ -10,11 +10,11 @@ module.exports = class OsuCommand extends Command {
|
||||
aliases: ['osu-user', 'osu-stats'],
|
||||
group: 'search',
|
||||
memberName: 'osu',
|
||||
description: 'Searches osu! usernames for your query.',
|
||||
description: 'Responds with information on an Osu! user.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
key: 'user',
|
||||
prompt: 'What user would you like to get information on?',
|
||||
type: 'string'
|
||||
}
|
||||
@@ -22,13 +22,13 @@ module.exports = class OsuCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
async run(msg, { user }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://osu.ppy.sh/api/get_user')
|
||||
.query({
|
||||
k: OSU_KEY,
|
||||
u: query,
|
||||
u: user,
|
||||
type: 'string'
|
||||
});
|
||||
if (!body.length) return msg.say('Could not find any results.');
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = class RecipeCommand extends Command {
|
||||
aliases: ['recipe-puppy'],
|
||||
group: 'search',
|
||||
memberName: 'recipe',
|
||||
description: 'Searches for recipes that include your query.',
|
||||
description: 'Searches for recipes based on your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class RedditCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'reddit',
|
||||
aliases: ['subreddit'],
|
||||
group: 'search',
|
||||
memberName: 'reddit',
|
||||
description: 'Gets a random recent post from a subreddit.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'subreddit',
|
||||
prompt: 'What subreddit would you like to get a post from?',
|
||||
type: 'string',
|
||||
parse: subreddit => encodeURIComponent(subreddit)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { subreddit }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`https://www.reddit.com/r/${subreddit}/new.json`)
|
||||
.query({ sort: 'new' });
|
||||
const allowed = msg.channel.nsfw ? body.data.children : body.data.children.filter(post => !post.data.over_18);
|
||||
if (!allowed.length) return msg.say('Could not find any results.');
|
||||
const post = allowed[Math.floor(Math.random() * allowed.length)].data;
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xFF4500)
|
||||
.setAuthor('Reddit', 'https://i.imgur.com/DSBOK0P.png')
|
||||
.setURL(`https://www.reddit.com${post.permalink}`)
|
||||
.setTitle(post.title)
|
||||
.addField('❯ Upvotes',
|
||||
post.ups, true)
|
||||
.addField('❯ Downvotes',
|
||||
post.downs, true)
|
||||
.addField('❯ Score',
|
||||
post.score, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 403) return msg.say('This subreddit is private.');
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -10,12 +10,12 @@ module.exports = class StocksCommand extends Command {
|
||||
aliases: ['stock', 'alpha-vantage'],
|
||||
group: 'search',
|
||||
memberName: 'stocks',
|
||||
description: 'Get the current stocks for a symbol.',
|
||||
description: 'Responds with the current stocks for a specific symbol.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'symbol',
|
||||
prompt: 'What symbol would you like to get the stocks for?',
|
||||
prompt: 'What symbol would you like to get the stocks of?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -10,22 +10,22 @@ module.exports = class ThesaurusCommand extends Command {
|
||||
aliases: ['synonym', 'antonym', 'wordnik-thesaurus'],
|
||||
group: 'search',
|
||||
memberName: 'thesaurus',
|
||||
description: 'Gets the synonyms and antonyms of a word.',
|
||||
description: 'Responds with the synonyms and antonyms of a word.',
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
key: 'word',
|
||||
prompt: 'What word would you like to look up?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
parse: word => encodeURIComponent(word)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
async run(msg, { word }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.wordnik.com/v4/word.json/${query}/relatedWords`)
|
||||
.get(`http://api.wordnik.com/v4/word.json/${word}/relatedWords`)
|
||||
.query({
|
||||
relationshipTypes: 'synonym,antonym',
|
||||
limitPerRelationshipType: 5,
|
||||
@@ -35,7 +35,7 @@ module.exports = class ThesaurusCommand extends Command {
|
||||
const synonyms = body.find(words => words.relationshipType === 'synonym');
|
||||
const antonyms = body.find(words => words.relationshipType === 'antonym');
|
||||
return msg.say(stripIndents`
|
||||
**${query}**
|
||||
**${word}**
|
||||
__Synonyms:__ ${synonyms ? synonyms.words.join(', ') : '???'}
|
||||
__Antonyms:__ ${antonyms ? antonyms.words.join(', ') : '???'}
|
||||
`);
|
||||
|
||||
@@ -10,12 +10,12 @@ module.exports = class TumblrCommand extends Command {
|
||||
aliases: ['tumblr-blog'],
|
||||
group: 'search',
|
||||
memberName: 'tumblr',
|
||||
description: 'Searches Tumblr for information on a blog.',
|
||||
description: 'Responds with information on a Tumblr blog.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'blog',
|
||||
prompt: 'What is the url of the blog you would like to get information on?',
|
||||
prompt: 'What blog would you like to get information on?',
|
||||
type: 'string',
|
||||
parse: blog => encodeURIComponent(blog)
|
||||
}
|
||||
|
||||
@@ -10,23 +10,23 @@ module.exports = class UrbanDictionaryCommand extends Command {
|
||||
aliases: ['urban', 'define-urban'],
|
||||
group: 'search',
|
||||
memberName: 'urban-dictionary',
|
||||
description: 'Searches Urban Dictionary for your query.',
|
||||
description: 'Defines a word, but with Urban Dictionary.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to define?',
|
||||
key: 'word',
|
||||
prompt: 'What word would you like to look up?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
async run(msg, { word }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.urbandictionary.com/v0/define')
|
||||
.query({ term: query });
|
||||
.query({ term: word });
|
||||
if (!body.list.length) return msg.say('Could not find any results.');
|
||||
const data = body.list[Math.floor(Math.random() * body.list.length)];
|
||||
const embed = new MessageEmbed()
|
||||
|
||||
@@ -10,11 +10,11 @@ module.exports = class WeatherCommand extends Command {
|
||||
aliases: ['open-weather-map'],
|
||||
group: 'search',
|
||||
memberName: 'weather',
|
||||
description: 'Responds with weather information for a specified location.',
|
||||
description: 'Responds with weather information for a specific location.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
key: 'location',
|
||||
prompt: 'What location would you like to get the weather of?',
|
||||
type: 'string'
|
||||
}
|
||||
@@ -22,12 +22,12 @@ module.exports = class WeatherCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
async run(msg, { location }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.openweathermap.org/data/2.5/weather')
|
||||
.query({
|
||||
q: query,
|
||||
q: location,
|
||||
units: 'metric',
|
||||
appid: OWM_KEY
|
||||
});
|
||||
|
||||
@@ -21,30 +21,24 @@ module.exports = class What3WordsCommand extends Command {
|
||||
max: 20
|
||||
},
|
||||
{
|
||||
key: 'word1',
|
||||
prompt: 'What is the first word you would like to use?',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
key: 'word2',
|
||||
prompt: 'What is the second word you would like to use?',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
key: 'word3',
|
||||
prompt: 'What is the third word you would like to use?',
|
||||
type: 'string'
|
||||
key: 'location',
|
||||
prompt: 'What location would you like to get a map of? Use three nouns, like "cat.dog.parrot".',
|
||||
type: 'string',
|
||||
validate: location => {
|
||||
if (location.split('.').length === 3) return true;
|
||||
return 'Invalid location, please enter a valid location, like "cat.dog.parrot".';
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { zoom, word1, word2, word3 }) {
|
||||
async run(msg, { zoom, location }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://api.what3words.com/v2/forward')
|
||||
.query({
|
||||
addr: `${word1}.${word2}.${word3}`,
|
||||
addr: location,
|
||||
key: W3W_KEY
|
||||
});
|
||||
if (body.status.code === 300) return msg.say('Could not find any results.');
|
||||
|
||||
@@ -44,7 +44,7 @@ module.exports = class WikipediaCommand extends Command {
|
||||
.setTitle(data.title)
|
||||
.setAuthor('Wikipedia', 'https://i.imgur.com/Z7NJBK2.png')
|
||||
.setThumbnail(data.thumbnail ? data.thumbnail.source : null)
|
||||
.setURL(`https://en.wikipedia.org/wiki/${encodeURIComponent(query.replace(/\)/g, '%29'))}`)
|
||||
.setURL(`https://en.wikipedia.org/wiki/${encodeURIComponent(query).replace(/\)/g, '%29')}`)
|
||||
.setDescription(shorten(data.extract.replace(/\n/g, '\n\n')));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user