This commit is contained in:
Elizabeth
2017-07-12 19:33:31 -05:00
parent c80caedffe
commit afe98a18a4
181 changed files with 22 additions and 1 deletions
-56
View File
@@ -1,56 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { cleanXML } = require('../../structures/Util');
const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js'));
const { animelistLogin } = require('../../config');
module.exports = class AnimeCommand extends Command {
constructor(client) {
super(client, {
name: 'anime',
group: 'search',
memberName: 'anime',
description: 'Searches My Anime List for your query, getting anime results.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What anime would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
try {
const { text } = await snekfetch
.get(`https://${animelistLogin}@myanimelist.net/api/anime/search.xml`)
.query({ q: query });
const { anime } = await xml.parseStringAsync(text);
const synopsis = cleanXML(anime.entry[0].synopsis[0].substr(0, 2000));
const embed = new MessageEmbed()
.setColor(0x2D54A2)
.setAuthor('My Anime List', 'https://i.imgur.com/R4bmNFz.png')
.setURL(`https://myanimelist.net/anime/${anime.entry[0].id[0]}`)
.setThumbnail(anime.entry[0].image[0])
.setTitle(`${anime.entry[0].title[0]} (English: ${anime.entry[0].english[0] || 'N/A'})`)
.setDescription(synopsis)
.addField(' Type',
`${anime.entry[0].type[0]} - ${anime.entry[0].status[0]}`, true)
.addField(' Episodes',
anime.entry[0].episodes[0], true)
.addField(' Start Date',
anime.entry[0].start_date[0], true)
.addField(' End Date',
anime.entry[0].end_date[0], true);
return msg.embed(embed);
} catch (err) {
if (err.message === 'Parse Error') return msg.say('No Results.');
else throw err;
}
}
};
-48
View File
@@ -1,48 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { dbotsKey } = require('../../config');
module.exports = class BotSearchCommand extends Command {
constructor(client) {
super(client, {
name: 'bot-info',
group: 'search',
memberName: 'bot-info',
description: 'Searches Discord Bots for info on a bot.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'bot',
prompt: 'Which bot do you want to get information for?',
type: 'user'
}
]
});
}
async run(msg, args) {
const { bot } = args;
try {
const { body } = await snekfetch
.get(`https://bots.discord.pw/api/bots/${bot.id}`)
.set({ Authorization: dbotsKey });
const embed = new MessageEmbed()
.setColor(0x9797FF)
.setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg')
.setTitle(body.name)
.setURL(`https://bots.discord.pw/bots/${bot.id}`)
.setDescription(body.description)
.addField(' Library',
body.library, true)
.addField(' Invite',
`[Here](${body.invite_url})`, true)
.addField(' Prefix',
body.prefix, true);
return msg.embed(embed);
} catch (err) {
if (err.message === '404 Not Found') return msg.say('Bot Not Found.');
else throw err;
}
}
};
-46
View File
@@ -1,46 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class BulbapediaCommand extends Command {
constructor(client) {
super(client, {
name: 'bulbapedia',
aliases: ['bulbagarden'],
group: 'search',
memberName: 'bulbapedia',
description: 'Searches Bulbapedia for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('http://bulbapedia.bulbagarden.net/w/api.php')
.query({
action: 'query',
prop: 'extracts',
format: 'json',
titles: query,
exintro: '',
explaintext: '',
redirects: '',
formatversion: 2
});
if (body.query.pages[0].missing) return msg.say('No Results.');
const embed = new MessageEmbed()
.setColor(0x3E7614)
.setTitle(body.query.pages[0].title)
.setAuthor('Bulbapedia', 'https://i.imgur.com/09eYo5T.png')
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
return msg.embed(embed);
}
};
-38
View File
@@ -1,38 +0,0 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
module.exports = class DanbooruCommand extends Command {
constructor(client) {
super(client, {
name: 'danbooru',
group: 'search',
memberName: 'danbooru',
description: 'Searches Danbooru with optional query.',
nsfw: true,
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string',
default: ''
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('https://danbooru.donmai.us/posts.json')
.query({
tags: `${query ? `${query} ` : ''}order:random`,
limit: 1
});
if (!body.length || !body[0].file_url) return msg.say('No Results');
return msg.say(stripIndents`
${query ? `Result for ${query}:` : 'Random Image:'}
https://danbooru.donmai.us${body[0].file_url}
`);
}
};
-42
View File
@@ -1,42 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { wordnikKey } = require('../../config');
module.exports = class DefineCommand extends Command {
constructor(client) {
super(client, {
name: 'define',
group: 'search',
memberName: 'define',
description: 'Defines a word.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What would you like to define?',
type: 'string',
parse: (query) => encodeURIComponent(query)
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions`)
.query({
limit: 1,
includeRelated: false,
useCanonical: false,
api_key: wordnikKey
});
if (!body.length) return msg.say('No Results.');
const embed = new MessageEmbed()
.setColor(0x9797FF)
.setTitle(body[0].word)
.setDescription(body[0].text);
return msg.embed(embed);
}
};
-36
View File
@@ -1,36 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
module.exports = class DiscrimCommand extends Command {
constructor(client) {
super(client, {
name: 'discrim',
aliases: ['discriminator', 'search-discrim'],
group: 'search',
memberName: 'discrim',
description: 'Searches for other users with a certain discriminator.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'discrim',
prompt: 'Which discriminator would you like to search for?',
type: 'string',
default: '',
validate: (discrim) => {
if (/[0-9]+$/g.test(discrim) && discrim.length === 4) return true;
else return 'Invalid Discriminator.';
}
}
]
});
}
run(msg, args) {
const discrim = args.discrim || msg.author.discriminator;
const users = this.client.users.filter((user) => user.discriminator === discrim).map((user) => user.username);
const embed = new MessageEmbed()
.setTitle(`${users.length} Users with the discriminator: ${discrim}`)
.setDescription(users.join(', '));
return msg.embed(embed);
}
};
-83
View File
@@ -1,83 +0,0 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class ForecastCommand extends Command {
constructor(client) {
super(client, {
name: 'forecast',
group: 'search',
memberName: 'forecast',
description: 'Responds with the seven-day forecast for a specified location.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What location would you like to get the forecast for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('https://query.yahooapis.com/v1/public/yql')
.query({
q: `select * from weather.forecast where u='f' AND woeid in (select woeid from geo.places(1) where text="${query}")`, // eslint-disable-line max-len
format: 'json'
});
if (!body.query.count) return msg.say('Location Not Found.');
const forecasts = body.query.results.channel.item.forecast;
const embed = new MessageEmbed()
.setColor(0x0000FF)
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
.setURL(body.query.results.channel.link)
.setTimestamp()
.addField(` ${forecasts[0].day} - ${forecasts[0].date}`,
stripIndents`
**High:** ${forecasts[0].high}°F
**Low:** ${forecasts[0].low}°F
**Condition:** ${forecasts[0].text}
`)
.addField(` ${forecasts[1].day} - ${forecasts[1].date}`,
stripIndents`
**High:** ${forecasts[1].high}°F
**Low:** ${forecasts[1].low}°F
**Condition:** ${forecasts[1].text}
`)
.addField(` ${forecasts[2].day} - ${forecasts[2].date}`,
stripIndents`
**High:** ${forecasts[2].high}°F
**Low:** ${forecasts[2].low}°F
**Condition:** ${forecasts[2].text}
`)
.addField(` ${forecasts[3].day} - ${forecasts[3].date}`,
stripIndents`
**High:** ${forecasts[3].high}°F
**Low:** ${forecasts[3].low}°F
**Condition:** ${forecasts[3].text}
`)
.addField(` ${forecasts[4].day} - ${forecasts[4].date}`,
stripIndents`
**High:** ${forecasts[4].high}°F
**Low:** ${forecasts[4].low}°F
**Condition:** ${forecasts[4].text}
`)
.addField(` ${forecasts[5].day} - ${forecasts[5].date}`,
stripIndents`
**High:** ${forecasts[5].high}°F
**Low:** ${forecasts[5].low}°F
**Condition:** ${forecasts[5].text}
`)
.addField(` ${forecasts[6].day} - ${forecasts[6].date}`,
stripIndents`
**High:** ${forecasts[6].high}°F
**Low:** ${forecasts[6].low}°F
**Condition:** ${forecasts[6].text}
`);
return msg.embed(embed);
}
};
-43
View File
@@ -1,43 +0,0 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js'));
module.exports = class GelbooruCommand extends Command {
constructor(client) {
super(client, {
name: 'gelbooru',
group: 'search',
memberName: 'gelbooru',
description: 'Searches Gelbooru for your query.',
nsfw: true,
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { text } = await snekfetch
.get('https://gelbooru.com/index.php')
.query({
page: 'dapi',
s: 'post',
q: 'index',
tags: query,
limit: 1
});
const { posts } = await xml.parseStringAsync(text);
if (posts.$.count === '0') return msg.say('No Results.');
return msg.say(stripIndents`
Result for ${query}:
https:${posts.post[0].$.file_url}
`);
}
};
-35
View File
@@ -1,35 +0,0 @@
const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
const { giphyKey } = require('../../config');
module.exports = class GiphyCommand extends Command {
constructor(client) {
super(client, {
name: 'giphy',
group: 'search',
memberName: 'giphy',
description: 'Searches Giphy for your query.',
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('http://api.giphy.com/v1/gifs/search')
.query({
q: query,
api_key: giphyKey,
rating: msg.channel.nsfw ? 'r' : 'pg'
});
if (!body.data.length) return msg.say('No Results.');
const random = Math.floor(Math.random() * body.data.length);
return msg.say(body.data[random].images.original.url);
}
};
-38
View File
@@ -1,38 +0,0 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
module.exports = class KonachanCommand extends Command {
constructor(client) {
super(client, {
name: 'konachan',
group: 'search',
memberName: 'konachan',
description: 'Searches Konachan with optional query.',
nsfw: true,
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string',
default: ''
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('https://konachan.net/post.json')
.query({
tags: `${query ? `${query} ` : ''}order:random`,
limit: 1
});
if (!body.length) return msg.say('No Results.');
return msg.say(stripIndents`
${query ? `Result for ${query}:` : 'Random Image:'}
https:${body[0].file_url}
`);
}
};
-56
View File
@@ -1,56 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { cleanXML } = require('../../structures/Util');
const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js'));
const { animelistLogin } = require('../../config');
module.exports = class MangaCommand extends Command {
constructor(client) {
super(client, {
name: 'manga',
group: 'search',
memberName: 'manga',
description: 'Searches My Anime List for your query, getting manga results.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What manga would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
try {
const { text } = await snekfetch
.get(`https://${animelistLogin}@myanimelist.net/api/manga/search.xml`)
.query({ q: query });
const { manga } = await xml.parseStringAsync(text);
const synopsis = cleanXML(manga.entry[0].synopsis[0].substr(0, 2000));
const embed = new MessageEmbed()
.setColor(0x2D54A2)
.setAuthor('My Anime List', 'https://i.imgur.com/R4bmNFz.png')
.setURL(`https://myanimelist.net/manga/${manga.entry[0].id[0]}`)
.setThumbnail(manga.entry[0].image[0])
.setTitle(`${manga.entry[0].title[0]} (English: ${manga.entry[0].english[0] || 'N/A'})`)
.setDescription(synopsis)
.addField(' Type',
`${manga.entry[0].type[0]} - ${manga.entry[0].status[0]}`, true)
.addField(' Volumes / Chapters',
`${manga.entry[0].volumes[0]} / ${manga.entry[0].chapters[0]}`, true)
.addField(' Start Date',
manga.entry[0].start_date[0], true)
.addField(' End Date',
manga.entry[0].end_date[0], true);
return msg.embed(embed);
} catch (err) {
if (err.message === 'Parse Error') return msg.say('No Results.');
else throw err;
}
}
};
-45
View File
@@ -1,45 +0,0 @@
const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
const { googleKey } = require('../../config');
module.exports = class MapCommand extends Command {
constructor(client) {
super(client, {
name: 'map',
group: 'search',
memberName: 'map',
description: 'Responds with a map based upon your query.',
clientPermissions: ['ATTACH_FILES'],
args: [
{
key: 'zoom',
label: 'zoom level',
prompt: 'What would you like the zoom level for the map to be? Limit 1-20.',
type: 'integer',
validate: (zoom) => {
if (zoom < 21 && zoom > 0) return true;
else return 'Please enter a zoom value from 1-20';
}
},
{
key: 'query',
prompt: 'What location you like to get a map image for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { zoom, query } = args;
const { body } = await snekfetch
.get('https://maps.googleapis.com/maps/api/staticmap')
.query({
center: query,
zoom,
size: '500x500',
key: googleKey
});
return msg.say({ files: [{ attachment: body, name: 'map.png' }] });
}
};
-36
View File
@@ -1,36 +0,0 @@
const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
const cheerio = require('cheerio');
module.exports = class NeopetCommand extends Command {
constructor(client) {
super(client, {
name: 'neopet',
group: 'search',
memberName: 'neopet',
description: 'Searches for Neopets with the username of your query.',
args: [
{
key: 'query',
prompt: 'What pet would you like to get the image of?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { text } = await snekfetch
.get('http://www.sunnyneo.com/petimagefinder.php')
.query({
name: query,
size: 5,
mood: 1
});
const $ = cheerio.load(text);
const link = $('textarea').first().text();
if (!link.includes('cp')) return msg.say('Invalid Pet Name.');
return msg.say(link);
}
};
-64
View File
@@ -1,64 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { osuKey } = require('../../config');
module.exports = class OsuCommand extends Command {
constructor(client) {
super(client, {
name: 'osu',
group: 'search',
memberName: 'osu',
description: 'Searches osu! usernames for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What osu username would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('https://osu.ppy.sh/api/get_user')
.query({
k: osuKey,
u: query,
type: 'string'
});
if (!body.length) return msg.say('No Results.');
const embed = new MessageEmbed()
.setColor(0xFF66AA)
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
.setURL('https://osu.ppy.sh/')
.addField(' Username',
body[0].username, true)
.addField(' ID',
body[0].user_id, true)
.addField(' Level',
body[0].level, true)
.addField(' Accuracy',
body[0].accuracy, true)
.addField(' Rank',
body[0].pp_rank, true)
.addField(' Play Count',
body[0].playcount, true)
.addField(' Country',
body[0].country, true)
.addField(' Ranked Score',
body[0].ranked_score, true)
.addField(' Total Score',
body[0].total_score, true)
.addField(' SS',
body[0].count_rank_ss, true)
.addField(' S',
body[0].count_rank_s, true)
.addField(' A',
body[0].count_rank_a, true);
return msg.embed(embed);
}
};
-43
View File
@@ -1,43 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class RecipeCommand extends Command {
constructor(client) {
super(client, {
name: 'recipe',
group: 'search',
memberName: 'recipe',
description: 'Searches for recipes that include your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
try {
const { query } = args;
const { text } = await snekfetch
.get('http://www.recipepuppy.com/api/')
.query({ q: query });
const body = JSON.parse(text);
if (!body.results.length) return msg.say('No Results.');
const recipe = body.results[Math.floor(Math.random() * body.results.length)];
const embed = new MessageEmbed()
.setColor(0xC20000)
.setURL(recipe.href)
.setTitle(recipe.title)
.setDescription(`**Ingredients:** ${recipe.ingredients}`)
.setThumbnail(recipe.thumbnail);
return msg.embed(embed);
} catch (err) {
return msg.say('No Results.');
}
}
};
-43
View File
@@ -1,43 +0,0 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js'));
module.exports = class Rule34Command extends Command {
constructor(client) {
super(client, {
name: 'rule34',
group: 'search',
memberName: 'rule34',
description: 'Searches Rule34 for your query.',
nsfw: true,
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { text } = await snekfetch
.get('https://rule34.xxx/index.php')
.query({
page: 'dapi',
s: 'post',
q: 'index',
tags: query,
limit: 1
});
const { posts } = await xml.parseStringAsync(text);
if (posts.$.count === '0') return msg.say('No Results.');
return msg.say(stripIndents`
Result for ${query}:
https:${posts.post[0].$.file_url}
`);
}
};
-51
View File
@@ -1,51 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { soundcloudKey } = require('../../config');
module.exports = class SoundCloudCommand extends Command {
constructor(client) {
super(client, {
name: 'soundcloud',
group: 'search',
memberName: 'soundcloud',
description: 'Searches SoundCloud for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What do you want to search SoundCloud for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('https://api.soundcloud.com/tracks')
.query({
q: query,
client_id: soundcloudKey
});
if (!body.length) return msg.say('No Results.');
const embed = new MessageEmbed()
.setColor(0xF15A22)
.setAuthor('SoundCloud', 'https://i.imgur.com/lFIz7RU.png')
.setTitle(body[0].title)
.setURL(body[0].permalink_url)
.setThumbnail(body[0].artwork_url)
.addField(' Artist',
body[0].user.username)
.addField(' Download Count',
body[0].download_count, true)
.addField(' Comment Count',
body[0].comment_count, true)
.addField(' Playback Count',
body[0].playback_count, true)
.addField(' Favorited Count',
body[0].favoritings_count, true);
return msg.embed(embed);
}
};
-39
View File
@@ -1,39 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class UrbanCommand extends Command {
constructor(client) {
super(client, {
name: 'urban',
group: 'search',
memberName: 'urban',
description: 'Searches Urban Dictionary for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What would you like to define?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('http://api.urbandictionary.com/v0/define')
.query({ term: query });
if (!body.list.length) return msg.say('No Results.');
const embed = new MessageEmbed()
.setColor(0x32A8F0)
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
.setURL(body.list[0].permalink)
.setTitle(body.list[0].word)
.setDescription(body.list[0].definition.substr(0, 2000))
.addField(' Example',
body.list[0].example.substr(0, 1024) || 'None');
return msg.embed(embed);
}
};
-56
View File
@@ -1,56 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const moment = require('moment');
const { wattpadKey } = require('../../config');
module.exports = class WattpadCommand extends Command {
constructor(client) {
super(client, {
name: 'wattpad',
group: 'search',
memberName: 'wattpad',
description: 'Searches Wattpad for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What book would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('https://api.wattpad.com:443/v4/stories')
.query({
query,
limit: 1
})
.set({ Authorization: `Basic ${wattpadKey}` });
if (!body.stories.length) return msg.say('No Results.');
const embed = new MessageEmbed()
.setColor(0xF89C34)
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
.setURL(body.stories[0].url)
.setTitle(body.stories[0].title)
.setDescription(body.stories[0].description.substr(0, 2000))
.setThumbnail(body.stories[0].cover)
.addField(' Created On',
moment(body.stories[0].createDate).format('MMMM Do YYYY'), true)
.addField(' Author',
body.stories[0].user, true)
.addField(' Parts',
body.stories[0].numParts, true)
.addField(' Reads',
body.stories[0].readCount, true)
.addField(' Votes',
body.stories[0].voteCount, true)
.addField(' Comments',
body.stories[0].commentCount, true);
return msg.embed(embed);
}
};
-63
View File
@@ -1,63 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class WeatherCommand extends Command {
constructor(client) {
super(client, {
name: 'weather',
group: 'search',
memberName: 'weather',
description: 'Responds with weather information for a specified location.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What location would you like to get the current weather for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('https://query.yahooapis.com/v1/public/yql')
.query({
q: `select * from weather.forecast where u='f' AND woeid in (select woeid from geo.places(1) where text="${query}")`, // eslint-disable-line max-len
format: 'json'
});
if (!body.query.count) return msg.say('Location Not Found.');
const embed = new MessageEmbed()
.setColor(0x0000FF)
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
.setURL(body.query.results.channel.link)
.setTimestamp()
.addField(' City',
body.query.results.channel.location.city, true)
.addField(' Country',
body.query.results.channel.location.country, true)
.addField(' Region',
body.query.results.channel.location.region, true)
.addField(' Condition',
body.query.results.channel.item.condition.text, true)
.addField(' Temperature',
`${body.query.results.channel.item.condition.temp}°F`, true)
.addField(' Humidity',
body.query.results.channel.atmosphere.humidity, true)
.addField(' Pressure',
body.query.results.channel.atmosphere.pressure, true)
.addField(' Rising',
body.query.results.channel.atmosphere.rising, true)
.addField(' Visibility',
body.query.results.channel.atmosphere.visibility, true)
.addField(' Wind Chill',
body.query.results.channel.wind.chill, true)
.addField(' Wind Direction',
body.query.results.channel.wind.direction, true)
.addField(' Wind Speed',
body.query.results.channel.wind.speed, true);
return msg.embed(embed);
}
};
-55
View File
@@ -1,55 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class WikiaCommand extends Command {
constructor(client) {
super(client, {
name: 'wikia',
aliases: ['fandom'],
group: 'search',
memberName: 'wikia',
description: 'Searches a specified Wikia wiki for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'wiki',
prompt: 'What is the subdomain of the wikia you want to search?',
type: 'string'
},
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { wiki, query } = args;
try {
const search = await snekfetch
.get(`http://${wiki}.wikia.com/api/v1/Search/List/`)
.query({
query,
limit: 1,
namespaces: 0
});
const id = search.body.items[0].id;
const { body } = await snekfetch
.get(`http://${wiki}.wikia.com/api/v1/Articles/AsSimpleJson/`)
.query({ id });
const embed = new MessageEmbed()
.setColor(0x002D54)
.setTitle(body.sections[0].title)
.setURL(search.body.items[0].url)
.setAuthor('Wikia', 'https://i.imgur.com/WzXWJka.png')
.setDescription(body.sections[0].content.map((i) => i.text).join('\n\n').substr(0, 2000))
.setThumbnail(body.sections[0].images[0] ? body.sections[0].images[0].src : null);
return msg.embed(embed);
} catch (err) {
return msg.say('No Results or Invalid Wiki.');
}
}
};
-45
View File
@@ -1,45 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class WikipediaCommand extends Command {
constructor(client) {
super(client, {
name: 'wikipedia',
group: 'search',
memberName: 'wikipedia',
description: 'Searches Wikipedia for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('https://en.wikipedia.org/w/api.php')
.query({
action: 'query',
prop: 'extracts',
format: 'json',
titles: query,
exintro: '',
explaintext: '',
redirects: '',
formatversion: 2
});
if (body.query.pages[0].missing) return msg.say('No Results.');
const embed = new MessageEmbed()
.setColor(0xE7E7E7)
.setTitle(body.query.pages[0].title)
.setAuthor('Wikipedia', 'https://i.imgur.com/a4eeEhh.png')
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
return msg.embed(embed);
}
};
-60
View File
@@ -1,60 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class XKCDCommand extends Command {
constructor(client) {
super(client, {
name: 'xkcd',
aliases: ['kcd'],
group: 'search',
memberName: 'xkcd',
description: 'Gets an XKCD Comic, optionally opting for today\'s or a specific number.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'type',
prompt: 'Please enter either a specific comic number, today, or random.',
type: 'string',
default: 'random',
parse: (type) => type.toLowerCase()
}
]
});
}
async run(msg, args) {
const { type } = args;
const current = await snekfetch
.get('https://xkcd.com/info.0.json');
if (type === 'today') {
const embed = new MessageEmbed()
.setTitle(`${current.body.num} - ${current.body.title}`)
.setURL(`https://xkcd.com/${current.body.num}`)
.setImage(current.body.img)
.setFooter(current.body.alt);
return msg.embed(embed);
} else if (type === 'random') {
const random = Math.floor(Math.random() * current.body.num) + 1;
const { body } = await snekfetch
.get(`https://xkcd.com/${random}/info.0.json`);
const embed = new MessageEmbed()
.setTitle(`${body.num} - ${body.title}`)
.setURL(`https://xkcd.com/${body.num}`)
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
} else {
const choice = parseInt(type, 10);
if (isNaN(choice) || current.body.num < choice || choice < 1) return msg.say('Invalid Number.');
const { body } = await snekfetch
.get(`https://xkcd.com/${choice}/info.0.json`);
const embed = new MessageEmbed()
.setTitle(`${body.num} - ${body.title}`)
.setURL(`https://xkcd.com/${body.num}`)
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
}
}
};
-45
View File
@@ -1,45 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { googleKey } = require('../../config');
module.exports = class YouTubeCommand extends Command {
constructor(client) {
super(client, {
name: 'youtube',
group: 'search',
memberName: 'youtube',
description: 'Searches YouTube for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get('https://www.googleapis.com/youtube/v3/search')
.query({
part: 'snippet',
type: 'video',
maxResults: 1,
q: query,
key: googleKey
});
if (!body.items.length) return msg.say('No Results.');
const embed = new MessageEmbed()
.setColor(0xDD2825)
.setTitle(body.items[0].snippet.title)
.setDescription(body.items[0].snippet.description)
.setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`, 'https://i.imgur.com/hkUafwu.png')
.setURL(`https://www.youtube.com/watch?v=${body.items[0].id.videoId}`)
.setThumbnail(body.items[0].snippet.thumbnails.default.url);
return msg.embed(embed);
}
};
-51
View File
@@ -1,51 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class YuGiOhCommand extends Command {
constructor(client) {
super(client, {
name: 'yu-gi-oh',
group: 'search',
memberName: 'yu-gi-oh',
description: 'Responds with info on a Yu-Gi-Oh! card.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What card would you like to get data for?',
type: 'string',
parse: (text) => encodeURIComponent(text)
}
]
});
}
async run(msg, args) {
const { query } = args;
const { body } = await snekfetch
.get(`http://yugiohprices.com/api/card_data/${query}`);
if (body.status === 'fail') return msg.say('No Results.');
const embed = new MessageEmbed()
.setColor(0xBE5F1F)
.setTitle(body.data.name)
.setDescription(body.data.text)
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
.addField(' Card Type',
body.data.card_type, true);
if (body.data.card_type === 'monster') {
embed
.addField(' Type',
body.data.type, true)
.addField(' Attribute',
body.data.family, true)
.addField(' ATK',
body.data.atk, true)
.addField(' DEF',
body.data.def, true)
.addField(' Level',
body.data.level, true);
}
return msg.embed(embed);
}
};