mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 13:56:43 +02:00
Remove more commands
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = class AnimeFigureCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'anime-figure',
|
||||
aliases: ['my-figure-collection', 'mfc', 'figure'],
|
||||
group: 'search',
|
||||
memberName: 'anime-figure',
|
||||
description: 'Searches MyFigureCollection for your query.',
|
||||
credit: [
|
||||
{
|
||||
name: 'MyFigureCollection.net',
|
||||
url: 'https://myfigurecollection.net/',
|
||||
reason: 'Figure Data'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What figure would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const location = await this.search(query);
|
||||
if (!location) return msg.say('Could not find any results.');
|
||||
return msg.say(location);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query) {
|
||||
const { text } = await request
|
||||
.get('https://myfigurecollection.net/browse.v4.php')
|
||||
.query({ keywords: query });
|
||||
const $ = cheerio.load(text);
|
||||
const location = $('span[class="item-icon"]').first().children().first().attr('href');
|
||||
if (!location) return null;
|
||||
return `https://myfigurecollection.net${location}`;
|
||||
}
|
||||
};
|
||||
@@ -1,61 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { shorten, formatNumber } = require('../../util/Util');
|
||||
const { GOOGLE_KEY } = process.env;
|
||||
|
||||
module.exports = class BookCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'book',
|
||||
aliases: ['google-book', 'google-books'],
|
||||
group: 'search',
|
||||
memberName: 'book',
|
||||
description: 'Searches Google Books for a book.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Google',
|
||||
url: 'https://www.google.com/',
|
||||
reason: 'Books API',
|
||||
reasonURL: 'https://developers.google.com/books/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What book would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://www.googleapis.com/books/v1/volumes')
|
||||
.query({
|
||||
apiKey: GOOGLE_KEY,
|
||||
q: query,
|
||||
maxResults: 1,
|
||||
printType: 'books'
|
||||
});
|
||||
if (!body.items) return msg.say('Could not find any results.');
|
||||
const data = body.items[0].volumeInfo;
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x4285F4)
|
||||
.setTitle(data.title)
|
||||
.setURL(data.previewLink)
|
||||
.setAuthor('Google Books', 'https://i.imgur.com/N3oHABo.png', 'https://books.google.com/')
|
||||
.setDescription(data.description ? shorten(data.description) : 'No description available.')
|
||||
.setThumbnail(data.imageLinks ? data.imageLinks.thumbnail : null)
|
||||
.addField('❯ Authors', data.authors && data.authors.length ? data.authors.join(', ') : '???')
|
||||
.addField('❯ Publish Date', data.publishedDate || '???', true)
|
||||
.addField('❯ Page Count', data.pageCount ? formatNumber(data.pageCount) : '???', true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,68 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { CLEARBIT_KEY } = process.env;
|
||||
const dragonFireAliases = ['dragonfire535', 'dragon fire', 'dragonfire'];
|
||||
|
||||
module.exports = class CompanyCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'company',
|
||||
aliases: ['clearbit', 'logo', 'company-logo'],
|
||||
group: 'search',
|
||||
memberName: 'company',
|
||||
description: 'Responds with the name and logo of a company.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Clearbit',
|
||||
url: 'https://clearbit.com/',
|
||||
reason: 'Autocomplete API',
|
||||
reasonURL: 'https://dashboard.clearbit.com/docs#autocomplete-api'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What company would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const data = await this.fetchCompany(query);
|
||||
if (!data) return msg.say('Could not find any results.');
|
||||
if (!msg.channel.nsfw && this.client.adultSiteList.includes(data.domain)) {
|
||||
return msg.reply('This site is NSFW.');
|
||||
}
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(data.name)
|
||||
.setImage(data.logo)
|
||||
.setFooter(data.dragonFire ? 'Logo by MissPeahen' : 'Logos provided by Clearbit')
|
||||
.setURL(data.domain ? `https://${data.domain}` : null)
|
||||
.setColor(0x00AE86);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async fetchCompany(query) {
|
||||
if (dragonFireAliases.includes(query.toLowerCase())) {
|
||||
return {
|
||||
name: 'Dragon Fire',
|
||||
logo: 'https://i.imgur.com/tHxWaoA.png',
|
||||
domain: null,
|
||||
dragonFire: true
|
||||
};
|
||||
}
|
||||
const { body } = await request
|
||||
.get(`https://autocomplete.clearbit.com/v1/companies/suggest`)
|
||||
.query({ query })
|
||||
.set({ Authorization: `Bearer ${CLEARBIT_KEY}` });
|
||||
if (!body.length) return null;
|
||||
return body[0];
|
||||
}
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
|
||||
module.exports = class CountryCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'country',
|
||||
group: 'search',
|
||||
memberName: 'country',
|
||||
description: 'Responds with information on a country.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Rest Countries',
|
||||
url: 'https://restcountries.eu/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What country would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://restcountries.eu/rest/v2/name/${encodeURIComponent(query)}`);
|
||||
const data = body.find(country => {
|
||||
const search = query.toLowerCase();
|
||||
return country.name.toLowerCase() === search
|
||||
|| country.altSpellings.some(alt => alt.toLowerCase() === search)
|
||||
|| country.alpha2Code.toLowerCase() === search
|
||||
|| country.alpha3Code.toLowerCase() === search
|
||||
|| country.nativeName.toLowerCase() === search;
|
||||
}) || body[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x00AE86)
|
||||
.setTitle(data.name)
|
||||
.setThumbnail(`https://www.countryflags.io/${data.alpha2Code}/flat/64.png`)
|
||||
.addField('❯ Population', formatNumber(data.population), true)
|
||||
.addField('❯ Capital', data.capital || 'None', true)
|
||||
.addField('❯ Currency', data.currencies[0].symbol, true)
|
||||
.addField('❯ Location', data.subregion || data.region, true)
|
||||
.addField('❯ Demonym', data.demonym || 'None', true)
|
||||
.addField('❯ Native Name', data.nativeName, true)
|
||||
.addField('❯ Area', `${formatNumber(data.area)}km`, true)
|
||||
.addField('❯ Languages', data.languages.map(lang => lang.name).join('/'));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,49 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class DanbooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'danbooru',
|
||||
aliases: ['booru'],
|
||||
group: 'search',
|
||||
memberName: 'danbooru',
|
||||
description: 'Responds with an image from Danbooru, with optional query.',
|
||||
nsfw: true,
|
||||
credit: [
|
||||
{
|
||||
name: 'Danbooru',
|
||||
url: 'https://danbooru.donmai.us/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What image would you like to search for?',
|
||||
type: 'string',
|
||||
default: '',
|
||||
validate: query => {
|
||||
if (!query.includes(' ')) return true;
|
||||
return 'Invalid query, please only search for one tag at a time.';
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://danbooru.donmai.us/posts.json')
|
||||
.query({
|
||||
tags: `${query} order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length || !body[0].file_url) return msg.say('Could not find any results.');
|
||||
return msg.say(body[0].file_url);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,61 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class DerpibooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'derpibooru',
|
||||
aliases: ['derpi'],
|
||||
group: 'search',
|
||||
memberName: 'derpibooru',
|
||||
description: 'Responds with an image from Derpibooru.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Hasbro',
|
||||
url: 'https://shop.hasbro.com/en-us',
|
||||
reason: 'Original "My Little Pony: Friendship is Magic" Show',
|
||||
reasonURL: 'https://mylittlepony.hasbro.com/en-us'
|
||||
},
|
||||
{
|
||||
name: 'Derpibooru',
|
||||
url: 'https://derpibooru.org/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.derpibooru.org/pages/api'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What image would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const url = await this.search(query, msg.channel.nsfw || false);
|
||||
if (!url) return msg.say('Could not find any results.');
|
||||
if (url === 'nsfw') return msg.say('The image I found was NSFW, and this isn\'t the channel for that.');
|
||||
return msg.say(url);
|
||||
} catch (err) {
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query, nsfw) {
|
||||
const { body } = await request
|
||||
.get('https://derpibooru.org/api/v1/json/search')
|
||||
.query({
|
||||
q: query,
|
||||
per_page: 1,
|
||||
sf: 'random'
|
||||
});
|
||||
if (!body || !body.images || !body.images.length) return null;
|
||||
const image = body.images[0];
|
||||
if (!image.tags.includes('safe') && !nsfw) return 'nsfw';
|
||||
return image.representations.full;
|
||||
}
|
||||
};
|
||||
@@ -1,68 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { decode: decodeHTML } = require('html-entities');
|
||||
|
||||
module.exports = class EsrbCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'esrb',
|
||||
aliases: ['game-rating'],
|
||||
group: 'search',
|
||||
memberName: 'esrb',
|
||||
description: 'Searches ESRB for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'ESRB',
|
||||
url: 'https://www.esrb.org/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What game would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const data = await this.search(query);
|
||||
if (!data) return msg.say('Could not find any results.');
|
||||
const ratingFile = path.join(__dirname, '..', '..', 'assets', 'images', 'esrb', `${data.rating}.png`);
|
||||
const embed = new MessageEmbed()
|
||||
.attachFiles([{ attachment: ratingFile, name: 'rating.png' }])
|
||||
.setColor(0x1C8CDE)
|
||||
.setTitle(`${decodeHTML(data.title)} by ${decodeHTML(data.company)}`)
|
||||
.setDescription(data.descriptors || 'No Descriptors')
|
||||
.setAuthor('ESRB', 'https://i.imgur.com/29U6Bax.jpg', 'https://www.esrb.org/')
|
||||
.setThumbnail('attachment://rating.png')
|
||||
.setURL(`https://www.esrb.org/ratings/${data.certificate}/`);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query) {
|
||||
const { text } = await request
|
||||
.post('https://www.esrb.org/wp-admin/admin-ajax.php')
|
||||
.attach({
|
||||
action: 'search_rating',
|
||||
'args[searchKeyword]': query,
|
||||
'args[searchType]': 'All',
|
||||
'args[pg]': 1,
|
||||
'args[platform][]': 'All Platforms',
|
||||
'args[rating][]': 'E,E10+,T,M,AO',
|
||||
'args[descriptor]': 'All Content'
|
||||
});
|
||||
const body = JSON.parse(text);
|
||||
if (!body.games.length) return null;
|
||||
return body.games.find(game => game.title.toLowerCase() === query.toLowerCase()) || body.games[0];
|
||||
}
|
||||
};
|
||||
@@ -1,59 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { isImageNSFW } = require('../../util/Util');
|
||||
const { FLICKR_KEY } = process.env;
|
||||
|
||||
module.exports = class FlickrCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'flickr',
|
||||
group: 'search',
|
||||
memberName: 'flickr',
|
||||
description: 'Searches Flickr for your query.',
|
||||
throttling: {
|
||||
usages: 2,
|
||||
duration: 30
|
||||
},
|
||||
credit: [
|
||||
{
|
||||
name: 'Flickr',
|
||||
url: 'https://www.flickr.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.flickr.com/services/api/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What photo would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.flickr.com/services/rest/')
|
||||
.query({
|
||||
api_key: FLICKR_KEY,
|
||||
format: 'json',
|
||||
method: 'flickr.photos.search',
|
||||
text: query,
|
||||
nojsoncallback: true
|
||||
});
|
||||
if (!body.photos.photo.length) return msg.say('Could not find any results.');
|
||||
const data = body.photos.photo[Math.floor(Math.random() * body.photos.photo.length)];
|
||||
const url = `https://farm${data.farm}.staticflickr.com/${data.server}/${data.id}_${data.secret}.jpg`;
|
||||
if (!msg.channel.nsfw) {
|
||||
const { body: imageBody } = await request.get(url);
|
||||
const aiDetect = await isImageNSFW(this.client.nsfwModel, imageBody);
|
||||
if (aiDetect) return msg.reply('Found an NSFW image. Sorry, please try again.');
|
||||
}
|
||||
return msg.say(url);
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,78 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
const { URLSearchParams, URL } = require('url');
|
||||
|
||||
module.exports = class GoogleCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'google',
|
||||
aliases: ['search'],
|
||||
group: 'search',
|
||||
memberName: 'google',
|
||||
description: 'Searches Google for your query.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Google',
|
||||
url: 'https://www.google.com/',
|
||||
reason: 'Search'
|
||||
},
|
||||
{
|
||||
name: 'LMGTFY',
|
||||
url: 'https://lmgtfy.com/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string',
|
||||
validate: query => {
|
||||
if (encodeURIComponent(query).length < 1950) return true;
|
||||
return 'Invalid query, your query is too long.';
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
let hrefs;
|
||||
try {
|
||||
hrefs = await this.search(query, msg.channel.nsfw || false);
|
||||
} catch {
|
||||
hrefs = [{ href: `http://lmgtfy.com/?iie=1&q=${encodeURIComponent(query)}`, title: 'LMGTFY' }];
|
||||
}
|
||||
if (!hrefs) return msg.say('Could not find any results.');
|
||||
return msg.say(hrefs.map(href => `${href.title}\n<${href.href}>`).join('\n\n'));
|
||||
}
|
||||
|
||||
async search(query, nsfw) {
|
||||
const { text } = await request
|
||||
.get('https://www.google.com/search')
|
||||
.query({
|
||||
safe: nsfw ? 'images' : 'active',
|
||||
pws: 0,
|
||||
filter: 0,
|
||||
q: query
|
||||
})
|
||||
.set({ 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1' });
|
||||
const $ = cheerio.load(text);
|
||||
const links = [];
|
||||
$('body').find('h3').each((i, h3) => {
|
||||
if ($(h3).parent()) {
|
||||
const href = $(h3).parent().attr('href');
|
||||
if (href) {
|
||||
const params = new URLSearchParams(href);
|
||||
const url = new URL(params.get('url'));
|
||||
if (nsfw || !this.client.adultSiteList.includes(url.host)) {
|
||||
links.push({ href: url.href, title: $(h3).text() });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!links.length) return null;
|
||||
return links.slice(0, 3);
|
||||
}
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class HttpDogCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'http-dog',
|
||||
group: 'search',
|
||||
memberName: 'http-dog',
|
||||
description: 'Responds with a dog for an HTTP status code.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'HTTP Status Dogs',
|
||||
url: 'https://httpstatusdogs.com/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'code',
|
||||
prompt: 'What code do you want to get the dog of?',
|
||||
type: 'integer'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { code }) {
|
||||
try {
|
||||
const { body, headers } = await request.get(`https://httpstatusdogs.com/img/${code}.jpg`);
|
||||
if (headers['content-type'].includes('text/html')) return msg.say('Could not find any results.');
|
||||
return msg.say({ files: [{ attachment: body, name: `${code}.jpg` }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,39 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class HttpDuckCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'http-duck',
|
||||
group: 'search',
|
||||
memberName: 'http-duck',
|
||||
description: 'Responds with a duck for an HTTP status code.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Random-d.uk',
|
||||
url: 'https://random-d.uk/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://random-d.uk/http'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'code',
|
||||
prompt: 'What code do you want to get the duck of?',
|
||||
type: 'integer'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { code }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://random-d.uk/api/http/${code}.jpg`);
|
||||
return msg.say({ files: [{ attachment: body, name: `${code}.jpg` }] });
|
||||
} catch (err) {
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const moment = require('moment');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { shorten, formatNumber } = require('../../util/Util');
|
||||
|
||||
module.exports = class KickstarterCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'kickstarter',
|
||||
group: 'search',
|
||||
memberName: 'kickstarter',
|
||||
description: 'Searches Kickstarter for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Kickstarter',
|
||||
url: 'https://www.kickstarter.com/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What project would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://www.kickstarter.com/projects/search.json')
|
||||
.query({
|
||||
search: '',
|
||||
term: query
|
||||
});
|
||||
if (!body.projects.length) return msg.say('Could not find any results.');
|
||||
const data = body.projects[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x14E06E)
|
||||
.setTitle(data.name)
|
||||
.setURL(data.urls.web.project)
|
||||
.setAuthor('Kickstarter', 'https://i.imgur.com/EHDlH5t.png', 'https://www.kickstarter.com/')
|
||||
.setDescription(shorten(data.blurb))
|
||||
.setThumbnail(data.photo ? data.photo.full : null)
|
||||
.addField('❯ Goal', `$${formatNumber(data.goal)}`, true)
|
||||
.addField('❯ Pledged', `$${formatNumber(data.pledged)}`, true)
|
||||
.addField('❯ Backers', formatNumber(data.backers_count), true)
|
||||
.addField('❯ Creator', data.creator.name, true)
|
||||
.addField('❯ Creation Date', moment.utc(data.created_at * 1000).format('MM/DD/YYYY h:mm A'), true)
|
||||
.addField('❯ Deadline', moment.utc(data.deadline * 1000).format('MM/DD/YYYY h:mm A'), true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,98 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const buttons = ['Q', 'W', 'E', 'R'];
|
||||
|
||||
module.exports = class LeagueOfLegendsCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'league-of-legends',
|
||||
aliases: ['league-of-legends-champion', 'league-of-legends-champ', 'league-champ', 'lol-champ'],
|
||||
group: 'search',
|
||||
memberName: 'league-of-legends',
|
||||
description: 'Responds with information on a League of Legends champion.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Riot Games',
|
||||
url: 'https://www.riotgames.com/en',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://developer.riotgames.com/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'champion',
|
||||
prompt: 'What champion would you like to get information on?',
|
||||
type: 'string',
|
||||
parse: champion => champion.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.version = null;
|
||||
this.champions = null;
|
||||
}
|
||||
|
||||
async run(msg, { champion }) {
|
||||
if (champion === 'satan') champion = 'teemo';
|
||||
try {
|
||||
if (!this.version) await this.fetchVersion();
|
||||
const data = await this.fetchChampion(champion);
|
||||
if (!data) return msg.say('Could not find any results.');
|
||||
const tips = [].concat(data.allytips, data.enemytips);
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x002366)
|
||||
.setAuthor('League of Legends', 'https://i.imgur.com/2JL4Rko.png', 'https://leagueoflegends.com/')
|
||||
.setTitle(`${data.name} ${data.title}`)
|
||||
.setDescription(data.blurb)
|
||||
.setThumbnail(`https://ddragon.leagueoflegends.com/cdn/${this.version}/img/champion/${data.image.full}`)
|
||||
.addField('❯ Attack', data.info.attack, true)
|
||||
.addField('❯ Defense', data.info.defense, true)
|
||||
.addField('❯ Magic', data.info.magic, true)
|
||||
.addField('❯ Difficulty', data.info.difficulty, true)
|
||||
.addField('❯ HP', `${data.stats.hp} (${data.stats.hpperlevel}/level)`, true)
|
||||
.addField('❯ HP Regen', `${data.stats.hpregen} (${data.stats.hpregenperlevel}/level)`, true)
|
||||
.addField('❯ MP', `${data.stats.mp} (${data.stats.mpperlevel}/level)`, true)
|
||||
.addField('❯ MP Regen', `${data.stats.mpregen} (${data.stats.mpregenperlevel}/level)`, true)
|
||||
.addField('❯ Resource', data.partype, true)
|
||||
.addField('❯ Armor', `${data.stats.armor} (${data.stats.armorperlevel}/level)`, true)
|
||||
.addField('❯ Attack Damage', `${data.stats.attackdamage} (${data.stats.attackdamageperlevel}/level)`, true)
|
||||
.addField('❯ Attack Range', data.stats.attackrange, true)
|
||||
.addField('❯ Attack Speed', `${data.stats.attackspeed} (${data.stats.attackspeedperlevel}/level)`, true)
|
||||
.addField('❯ Crit', `${data.stats.crit} (${data.stats.critperlevel}/level)`, true)
|
||||
.addField('❯ Move Speed', data.stats.movespeed, true)
|
||||
.addField('❯ Spell Block', `${data.stats.spellblock} (${data.stats.spellblockperlevel}/level)`, true)
|
||||
.addField('❯ Passive', data.passive.name, true)
|
||||
.addField('❯ Spells', 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!`);
|
||||
}
|
||||
}
|
||||
|
||||
async fetchVersion() {
|
||||
const { body } = await request.get('https://ddragon.leagueoflegends.com/api/versions.json');
|
||||
[this.version] = body;
|
||||
setTimeout(() => { this.version = null; }, 3.6e+6);
|
||||
return body;
|
||||
}
|
||||
|
||||
async fetchChampions() {
|
||||
if (this.champions && this.champions.version === this.version) return this.champions;
|
||||
const { body } = await request
|
||||
.get(`https://ddragon.leagueoflegends.com/cdn/${this.version}/data/en_US/champion.json`);
|
||||
this.champions = body;
|
||||
return body;
|
||||
}
|
||||
|
||||
async fetchChampion(champion) {
|
||||
const champions = await this.fetchChampions();
|
||||
const name = Object.keys(champions.data).find(key => key.toLowerCase() === champion);
|
||||
if (!name) return null;
|
||||
const { id } = champions.data[name];
|
||||
const { body } = await request
|
||||
.get(`https://ddragon.leagueoflegends.com/cdn/${this.version}/data/en_US/champion/${id}.json`);
|
||||
return body.data[id];
|
||||
}
|
||||
};
|
||||
@@ -1,62 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { shorten } = require('../../util/Util');
|
||||
// eslint-disable-next-line max-len
|
||||
const top = '<!-- Usage of azlyrics.com content by any third-party lyrics provider is prohibited by our licensing agreement. Sorry about that. -->';
|
||||
const bottom = '<!-- MxM banner -->';
|
||||
const lyricRegex = new RegExp(`${top}(.+)${bottom}`, 'si');
|
||||
|
||||
module.exports = class LyricsCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'lyrics',
|
||||
aliases: ['az-lyrics'],
|
||||
group: 'search',
|
||||
memberName: 'lyrics',
|
||||
description: 'Responds with lyrics to a song.',
|
||||
credit: [
|
||||
{
|
||||
name: 'AZLyrics',
|
||||
url: 'https://www.azlyrics.com/',
|
||||
reason: 'Lyrics Data'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'artist',
|
||||
prompt: 'What artist would you like to get the lyrics of?',
|
||||
type: 'string',
|
||||
parse: artist => artist.replace(/[^A-Za-z0-9]+|^(the )/gi, '').toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'song',
|
||||
prompt: 'What song would you like to get the lyrics of?',
|
||||
type: 'string',
|
||||
parse: song => song.replace(/[^A-Za-z0-9]+/g, '').toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { artist, song }) {
|
||||
try {
|
||||
const lyrics = await this.getLyrics(artist, song);
|
||||
const url = `https://www.azlyrics.com/lyrics/${artist}/${song}.html`;
|
||||
return msg.say(`${shorten(lyrics, 1750)}\n\n**Read the Rest:** ${url}`);
|
||||
} catch (err) {
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
|
||||
async getLyrics(artist, song) {
|
||||
const { text } = await request.get(`https://www.azlyrics.com/lyrics/${artist}/${song}.html`);
|
||||
const lyrics = text.match(lyricRegex)[1];
|
||||
return lyrics
|
||||
.replaceAll('<br>', '')
|
||||
.replace(/<\/?div>/g, '')
|
||||
.replace(/<\/?i>/g, '*')
|
||||
.replace(/<\/?b>/g, '**')
|
||||
.trim();
|
||||
}
|
||||
};
|
||||
@@ -1,48 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class MalBadgesCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'mal-badges',
|
||||
aliases: ['my-anime-list-badges', 'mal-badge', 'my-anime-list-badge'],
|
||||
group: 'search',
|
||||
memberName: 'mal-badges',
|
||||
description: 'Responds with a MyAnimeList user\'s mal-badges badge.',
|
||||
credit: [
|
||||
{
|
||||
name: 'mal-badges',
|
||||
url: 'http://www.mal-badges.net/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'What user would you like to get the badge of?',
|
||||
type: 'string',
|
||||
parse: user => encodeURIComponent(user)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
try {
|
||||
const { body } = await request.get(`http://www.mal-badges.net/users/${user}/badge`);
|
||||
const embed = new MessageEmbed()
|
||||
.attachFiles([{ attachment: body, name: 'badge.png' }])
|
||||
.setTitle(user)
|
||||
.setImage('attachment://badge.png')
|
||||
.setURL(`http://www.mal-badges.net/users/${user}`)
|
||||
.setColor(0x00ADB5);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 404 || err.status === 500) {
|
||||
return msg.say(`Could not find any results. Try updating at <http://www.mal-badges.net/users/${user}>.`);
|
||||
}
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { GOOGLE_KEY } = process.env;
|
||||
|
||||
module.exports = class MapCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'map',
|
||||
aliases: ['google-maps', 'google-map'],
|
||||
group: 'search',
|
||||
memberName: 'map',
|
||||
description: 'Responds with a map of a specific location.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Google',
|
||||
url: 'https://www.google.com/',
|
||||
reason: 'Maps Static API',
|
||||
reasonURL: 'https://developers.google.com/maps/documentation/maps-static/intro'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'zoom',
|
||||
label: 'zoom level',
|
||||
prompt: 'What would you like the zoom level to be? Must be a number from 1-20.',
|
||||
type: 'integer',
|
||||
min: 1,
|
||||
max: 20
|
||||
},
|
||||
{
|
||||
key: 'location',
|
||||
prompt: 'What location would you like to get a map of?',
|
||||
type: 'string',
|
||||
validate: location => {
|
||||
if (encodeURIComponent(location).length < 1950) return true;
|
||||
return 'Invalid location, your location is too long.';
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { zoom, location }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://maps.googleapis.com/maps/api/staticmap')
|
||||
.query({
|
||||
center: location,
|
||||
zoom,
|
||||
size: '500x500',
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,75 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class MayoClinicCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'mayo-clinic',
|
||||
aliases: ['disease'],
|
||||
group: 'search',
|
||||
memberName: 'mayo-clinic',
|
||||
description: 'Searches Mayo Clinic for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Mayo Clinic',
|
||||
url: 'https://www.mayoclinic.org/',
|
||||
reason: 'Disease Data'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What disease would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const location = await this.search(query);
|
||||
if (!location) return msg.say('Could not find any results.');
|
||||
const data = await this.fetchDisease(location);
|
||||
if (typeof data === 'string') return msg.say(`I found a match, but it's not a disease: ${data}`);
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x0044B3)
|
||||
.setAuthor('Mayo Clinic', 'https://i.imgur.com/9zdulOS.jpg', 'https://www.mayoclinic.org/')
|
||||
.setTitle(data.name)
|
||||
.setDescription(shorten(data.description || 'No description available.'))
|
||||
.setURL(data.url);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query) {
|
||||
const { text } = await request
|
||||
.get('https://www.mayoclinic.org/search/search-results')
|
||||
.query({ q: query });
|
||||
const $ = cheerio.load(text);
|
||||
const location = $('ol.navlist').find('li.noimg').first().children().find('a').attr('href');
|
||||
if (!location) return null;
|
||||
return location;
|
||||
}
|
||||
|
||||
async fetchDisease(location) {
|
||||
const { text } = await request.get(location);
|
||||
const $ = cheerio.load(text);
|
||||
const header = $('h2').first();
|
||||
if (header.text() === 'Overview') {
|
||||
const caption = $('p[class="caption"]').first().next().text().trim();
|
||||
return {
|
||||
name: $('h1').first().text().trim(),
|
||||
url: location,
|
||||
description: caption || header.next().text().trim()
|
||||
};
|
||||
}
|
||||
return location;
|
||||
}
|
||||
};
|
||||
@@ -1,107 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const moment = require('moment');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
const classStats = require('../../assets/json/paladins');
|
||||
const { FLANKER_EMOJI_ID, DAMAGE_EMOJI_ID, FRONT_LINE_EMOJI_ID, SUPPORT_EMOJI_ID } = process.env;
|
||||
|
||||
module.exports = class PaladinsCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'paladins',
|
||||
aliases: ['paladins-guru'],
|
||||
group: 'search',
|
||||
memberName: 'paladins',
|
||||
description: 'Responds with information on a Paladins player.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Evil Mojo Games',
|
||||
url: 'https://www.evilmojogames.com/',
|
||||
reason: 'Original "Paladins" Game',
|
||||
reasonURL: 'https://www.paladins.com/'
|
||||
},
|
||||
{
|
||||
name: 'PaladinsGuru',
|
||||
url: 'https://paladins.guru/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'player',
|
||||
prompt: 'What player would you like to get information on?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.champions = null;
|
||||
}
|
||||
|
||||
async run(msg, { player }) {
|
||||
try {
|
||||
const search = await this.search(player);
|
||||
if (!search) return msg.say('Could not find any results.');
|
||||
const data = await this.fetchPlayer(search.id);
|
||||
if (!this.champions) await this.fetchChampions();
|
||||
const champions = data.champions.map(champ => {
|
||||
const champData = this.champions[champ.id];
|
||||
const classStat = classStats[champData.class];
|
||||
const emoji = this.classEmoji(champData.class);
|
||||
return `${emoji} ${champData.name} (${formatNumber(champ[classStat.id] || 0)} ${classStat.display})`;
|
||||
});
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x1E9BAD)
|
||||
.setAuthor('Paladins Guru', 'https://i.imgur.com/iIAdriK.png', 'https://paladins.guru/')
|
||||
.setTitle('View Profile on Paladins Guru')
|
||||
.setURL(`https://paladins.guru/profile/${data.player.id}`)
|
||||
.addField('❯ Name', data.player.name, true)
|
||||
.addField('❯ ID', data.player.id, true)
|
||||
.addField('❯ Level', data.player.level, true)
|
||||
.addField('❯ Last Seen', moment.utc(data.player.seen).format('MM/DD/YYYY h:mm A'), true)
|
||||
.addField('❯ Region', data.player.region, true)
|
||||
.addField('❯ Team', data.player.team || 'Free Agent', true)
|
||||
.addField('❯ Top 5 Champions', champions.slice(0, 5).join('\n'));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query) {
|
||||
const { body } = await request
|
||||
.get('https://api.paladins.guru/v3/search')
|
||||
.query({
|
||||
term: query,
|
||||
type: 'Player'
|
||||
});
|
||||
if (!body.length) return null;
|
||||
return body[0];
|
||||
}
|
||||
|
||||
async fetchPlayer(id) {
|
||||
const { body } = await request.get(`https://api.paladins.guru/v3/profiles/${id}/summary`);
|
||||
return body;
|
||||
}
|
||||
|
||||
async fetchChampions() {
|
||||
if (this.champions) return this.champions;
|
||||
const { body } = await request.get('https://api.paladins.guru/v3/champions/');
|
||||
this.champions = body;
|
||||
setTimeout(() => { this.champions = null; }, 3.6e+6);
|
||||
return body;
|
||||
}
|
||||
|
||||
classEmoji(className) {
|
||||
let emojiID;
|
||||
switch (className) {
|
||||
case 'Flanker': emojiID = FLANKER_EMOJI_ID; break;
|
||||
case 'Support': emojiID = SUPPORT_EMOJI_ID; break;
|
||||
case 'Damage': emojiID = DAMAGE_EMOJI_ID; break;
|
||||
case 'Front Line': emojiID = FRONT_LINE_EMOJI_ID; break;
|
||||
}
|
||||
return `<:${className.replaceAll(' ', '')}:${emojiID}>`;
|
||||
}
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { html } = require('common-tags');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class PoemCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'poem',
|
||||
aliases: ['poetry'],
|
||||
group: 'search',
|
||||
memberName: 'poem',
|
||||
description: 'Searches for poems by a specific author.',
|
||||
credit: [
|
||||
{
|
||||
name: 'PoetryDB',
|
||||
url: 'https://poetrydb.org/index.html',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://github.com/thundercomb/poetrydb/blob/master/README.md'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'author',
|
||||
prompt: 'What author would you like to get a poem from?',
|
||||
type: 'string',
|
||||
parse: author => encodeURIComponent(author)
|
||||
},
|
||||
{
|
||||
key: 'title',
|
||||
prompt: 'What is the title of the poem you want to get?',
|
||||
type: 'string',
|
||||
parse: title => encodeURIComponent(title)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { author, title }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://poetrydb.org/author,title/${author};${title}`);
|
||||
if (body.status === 404) return msg.say('Could not find any results.');
|
||||
const data = body[0];
|
||||
return msg.say(html`
|
||||
**${data.title}** by **${data.author}**
|
||||
${shorten(data.lines.join('\n'), 1750)}
|
||||
`);
|
||||
} catch (err) {
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,49 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = class PornhubCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'pornhub',
|
||||
group: 'search',
|
||||
memberName: 'pornhub',
|
||||
description: 'Searches Pornhub for your query.',
|
||||
nsfw: true,
|
||||
credit: [
|
||||
{
|
||||
name: 'Pornhub',
|
||||
url: 'https://www.pornhub.com/',
|
||||
reason: 'Video Data'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What video would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const url = await this.search(query);
|
||||
if (!url) return msg.say('Could not find any results.');
|
||||
return msg.say(url);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query) {
|
||||
const { text } = await request
|
||||
.get(`https://www.pornhub.com/video/search`)
|
||||
.query({ search: query });
|
||||
if (text.includes('<div class="noResultsWrapper">')) return null;
|
||||
const $ = cheerio.load(text);
|
||||
const video = $('li[class="pcVideoListItem js-pop videoblock videoBox"]').eq(5);
|
||||
return `https://www.pornhub.com/view_video.php?viewkey=${video.attr('data-video-vkey')}`;
|
||||
}
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class RecipeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'recipe',
|
||||
aliases: ['recipe-puppy'],
|
||||
group: 'search',
|
||||
memberName: 'recipe',
|
||||
description: 'Searches for recipes based on your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Recipe Puppy',
|
||||
url: 'http://www.recipepuppy.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'http://www.recipepuppy.com/about/api/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What recipe would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const body = await this.fetchRecipe(query);
|
||||
if (!body.results.length) return msg.say('Could not find any results.');
|
||||
const recipe = body.results[Math.floor(Math.random() * body.results.length)];
|
||||
const embed = new MessageEmbed()
|
||||
.setAuthor('Recipe Puppy', 'https://i.imgur.com/lT94snh.png', 'http://www.recipepuppy.com/')
|
||||
.setColor(0xC20000)
|
||||
.setURL(recipe.href)
|
||||
.setTitle(recipe.title)
|
||||
.setDescription(`**Ingredients:** ${recipe.ingredients}`)
|
||||
.setThumbnail(recipe.thumbnail);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async fetchRecipe(query) {
|
||||
try {
|
||||
const { text } = await request
|
||||
.get('http://www.recipepuppy.com/api/')
|
||||
.query({ q: query });
|
||||
return JSON.parse(text);
|
||||
} catch (err) {
|
||||
return JSON.parse(err.text.split('<!DOCTYPE html')[0]);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,81 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class RightStufCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'right-stuf',
|
||||
aliases: ['right-stuf-anime'],
|
||||
group: 'search',
|
||||
memberName: 'right-stuf',
|
||||
description: 'Searches Right Stuf Anime for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Right Stuf Anime',
|
||||
url: 'https://www.rightstufanime.com/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What product would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://www.rightstufanime.com/api/items')
|
||||
.query({
|
||||
country: 'US',
|
||||
currency: 'USD',
|
||||
fieldset: 'search',
|
||||
include: '',
|
||||
language: 'en',
|
||||
limit: 1,
|
||||
pricelevel: 2,
|
||||
q: query,
|
||||
sort: 'relevance:asc',
|
||||
custitem_rs_adult: Boolean(msg.channel.nsfw)
|
||||
});
|
||||
if (!body.items.length) return msg.say('Could not find any results.');
|
||||
const data = body.items[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xEE3F3C)
|
||||
.setTitle(data.storedisplayname)
|
||||
.setURL(`https://www.rightstufanime.com/${data.urlcomponent}`)
|
||||
.setAuthor('Right Stuf', 'https://i.imgur.com/CTB8Imp.jpg', 'https://www.rightstufanime.com/')
|
||||
.setDescription(shorten(data.storedescription))
|
||||
.setThumbnail(this.getImageURL(data))
|
||||
.addField('❯ Price', stripIndents`
|
||||
Retail Price: ${data.pricelevel1_formatted}
|
||||
Non-Member Price: ${data.pricelevel5_formatted}
|
||||
Member Price: ${data.pricelevel3_formatted}
|
||||
`);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
getImageURL(item) {
|
||||
let found = null;
|
||||
let current = item.itemimages_detail;
|
||||
while (!found) {
|
||||
if (current.primary) found = current.primary.url;
|
||||
if (current.urls) found = current.urls[0].url;
|
||||
const key = Object.keys(current)[0];
|
||||
if (!key) break;
|
||||
current = current[key];
|
||||
}
|
||||
return found;
|
||||
}
|
||||
};
|
||||
@@ -1,74 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const UserAgent = require('user-agents');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class RottenTomatoesCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'rotten-tomatoes',
|
||||
aliases: ['tomato-meter', 'r-tomatoes'],
|
||||
group: 'search',
|
||||
memberName: 'rotten-tomatoes',
|
||||
description: 'Searches Rotten Tomatoes for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Rotten Tomatoes',
|
||||
url: 'https://www.rottentomatoes.com/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What movie would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const id = await this.search(query);
|
||||
if (!id) return msg.say('Could not find any results.');
|
||||
const data = await this.fetchMovie(id);
|
||||
const criticScore = data.ratingSummary.allCritics;
|
||||
const audienceScore = data.ratingSummary.audience;
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xFFEC02)
|
||||
.setTitle(`${data.title} (${data.year})`)
|
||||
.setURL(`https://www.rottentomatoes.com${data.url}`)
|
||||
.setAuthor('Rotten Tomatoes', 'https://i.imgur.com/Sru8mZ3.jpg', 'https://www.rottentomatoes.com/')
|
||||
.setDescription(shorten(data.ratingSummary.consensus))
|
||||
.setThumbnail(data.posters.original)
|
||||
.addField('❯ Critic Score', criticScore.meterValue ? `${criticScore.meterValue}%` : '???', true)
|
||||
.addField('❯ Audience Score', audienceScore.meterScore ? `${audienceScore.meterScore}%` : '???', true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query) {
|
||||
const { body } = await request
|
||||
.get('https://www.rottentomatoes.com/api/private/v2.0/search/')
|
||||
.query({
|
||||
limit: 10,
|
||||
q: query
|
||||
})
|
||||
.set({ 'User-Agent': new UserAgent().toString() });
|
||||
if (!body.movies.length) return null;
|
||||
const find = body.movies.find(m => m.name.toLowerCase() === query.toLowerCase()) || body.movies[0];
|
||||
return find.url.replace('/m/', '');
|
||||
}
|
||||
|
||||
async fetchMovie(id) {
|
||||
const { text } = await request
|
||||
.get(`https://www.rottentomatoes.com/api/private/v1.0/movies/${id}`)
|
||||
.set({ 'User-Agent': new UserAgent().toString() });
|
||||
return JSON.parse(text);
|
||||
}
|
||||
};
|
||||
@@ -1,49 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class SafebooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'safebooru',
|
||||
group: 'search',
|
||||
memberName: 'safebooru',
|
||||
description: 'Responds with an image from Safebooru, with optional query.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Safebooru',
|
||||
url: 'https://safebooru.org/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What image would you like to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { text } = await request
|
||||
.get('https://safebooru.org/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
s: 'post',
|
||||
q: 'index',
|
||||
json: 1,
|
||||
tags: query,
|
||||
limit: 200
|
||||
});
|
||||
if (!text) return msg.say('Could not find any results.');
|
||||
const body = JSON.parse(text);
|
||||
const data = body[Math.floor(Math.random() * body.length)];
|
||||
return msg.say(`https://safebooru.org/images/${data.directory}/${data.image}`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,54 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class SakugabooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'sakugabooru',
|
||||
aliases: ['sakuga'],
|
||||
group: 'search',
|
||||
memberName: 'sakugabooru',
|
||||
description: 'Responds with an image from Sakugabooru, with optional query.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Sakugabooru',
|
||||
url: 'https://www.sakugabooru.com/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://www.sakugabooru.com/post.json')
|
||||
.query({
|
||||
tags: query,
|
||||
limit: 100
|
||||
});
|
||||
if (!body.length) return msg.say('Could not find any results.');
|
||||
const posts = body.filter(post => {
|
||||
if (!msg.channel.nsfw && (post.rating === 'e' || post.rating === 'q')) return false;
|
||||
return post.file_url;
|
||||
});
|
||||
if (!posts.length) return msg.say('Could not find any results.');
|
||||
const post = posts[Math.floor(Math.random() * posts.length)];
|
||||
return msg.say(stripIndents`
|
||||
${post.tags}
|
||||
${post.file_url}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,94 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
const { ALPHA_VANTAGE_KEY } = process.env;
|
||||
|
||||
module.exports = class StocksCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'stocks',
|
||||
aliases: ['stock', 'alpha-vantage'],
|
||||
group: 'search',
|
||||
memberName: 'stocks',
|
||||
description: 'Responds with the current stocks for a company.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Alpha Vantage',
|
||||
url: 'https://www.alphavantage.co/',
|
||||
reason: 'API'
|
||||
},
|
||||
{
|
||||
name: 'Yahoo',
|
||||
url: 'https://www.yahoo.com/',
|
||||
reason: 'Finance API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What company would you like to get the stocks of?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const company = await this.search(query);
|
||||
if (!company) return msg.say('Could not find any results.');
|
||||
const stocks = await this.fetchStocks(company.symbol);
|
||||
if (!stocks) return msg.say('Could not find any results.');
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(`Stocks for ${company.name} (${stocks.symbol.toUpperCase()})`)
|
||||
.setColor(0x9797FF)
|
||||
.setFooter('Last Updated')
|
||||
.setTimestamp(stocks.lastRefresh)
|
||||
.addField('❯ Open', `$${formatNumber(stocks.open)}`, true)
|
||||
.addField('❯ Close', `$${formatNumber(stocks.close)}`, true)
|
||||
.addField('❯ Volume', formatNumber(stocks.volume), true)
|
||||
.addField('❯ High', `$${formatNumber(stocks.high)}`, true)
|
||||
.addField('❯ Low', `$${formatNumber(stocks.low)}`, true)
|
||||
.addField('\u200B', '\u200B', true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query) {
|
||||
const { body } = await request
|
||||
.get('http://d.yimg.com/autoc.finance.yahoo.com/autoc')
|
||||
.query({
|
||||
query,
|
||||
region: 1,
|
||||
lang: 'en'
|
||||
});
|
||||
if (!body.ResultSet.Result.length) return null;
|
||||
return body.ResultSet.Result[0];
|
||||
}
|
||||
|
||||
async fetchStocks(symbol) {
|
||||
const { body } = await request
|
||||
.get('https://www.alphavantage.co/query')
|
||||
.query({
|
||||
function: 'TIME_SERIES_INTRADAY',
|
||||
symbol,
|
||||
interval: '1min',
|
||||
apikey: ALPHA_VANTAGE_KEY
|
||||
});
|
||||
if (body['Error Message'] || !body['Time Series (1min)']) return null;
|
||||
const data = Object.values(body['Time Series (1min)'])[0];
|
||||
return {
|
||||
symbol,
|
||||
open: data['1. open'],
|
||||
high: data['2. high'],
|
||||
low: data['3. low'],
|
||||
close: data['4. close'],
|
||||
volume: data['5. volume'],
|
||||
lastRefresh: new Date(body['Meta Data']['3. Last Refreshed'])
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -1,73 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
|
||||
module.exports = class StrainCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'strain',
|
||||
aliases: ['weed', 'marijuana', 'cannabis', 'leafly', 'marijuana-strain', 'weed-strain', 'cannabis-strain'],
|
||||
group: 'search',
|
||||
memberName: 'strain',
|
||||
description: 'Responds with information on a cannabis strain.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Leafly',
|
||||
url: 'https://www.leafly.com/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What strain would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const strain = await this.search(query);
|
||||
if (!strain) return msg.say('Could not find any results.');
|
||||
const effects = Object.values(strain.effects).sort((a, b) => b.score - a.score).slice(0, 3);
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x017C6A)
|
||||
.setAuthor('Leafly', 'https://i.imgur.com/KQ0ABhI.png', 'https://www.leafly.com/')
|
||||
.setTitle(strain.name)
|
||||
.setThumbnail(strain.nugImage || null)
|
||||
.setDescription(strain.shortDescriptionPlain || 'No description.')
|
||||
.setURL(`https://www.leafly.com/strains/${strain.slug}`)
|
||||
.setFooter(strain.subtitle || 'No alternative names.')
|
||||
.addField('❯ Effects', effects.map(effect => effect.name).join(', '))
|
||||
.addField('❯ Phenotype', strain.phenotype, true)
|
||||
.addField('❯ Rating', `${formatNumber(strain.averageRating)} ⭐`, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async search(query) {
|
||||
const { text } = await request
|
||||
.get('https://www.leafly.com/search')
|
||||
.query({
|
||||
q: query,
|
||||
searchCategory: 'strain'
|
||||
});
|
||||
const $ = cheerio.load(text);
|
||||
const data = JSON.parse($('script[id="__NEXT_DATA__"]')[0].children[0].data)
|
||||
.props
|
||||
.initialProps
|
||||
.pageProps
|
||||
.componentProps
|
||||
.searchProps
|
||||
.strain;
|
||||
if (!data.length) return null;
|
||||
return data[0];
|
||||
}
|
||||
};
|
||||
@@ -1,47 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { TENOR_KEY } = process.env;
|
||||
|
||||
module.exports = class TenorCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'tenor',
|
||||
group: 'search',
|
||||
memberName: 'tenor',
|
||||
description: 'Searches Tenor for your query.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Tenor',
|
||||
url: 'https://tenor.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://tenor.com/gifapi/documentation'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What GIF would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.tenor.com/v1/search')
|
||||
.query({
|
||||
q: query,
|
||||
key: TENOR_KEY,
|
||||
limit: 50,
|
||||
contentfilter: msg.channel.nsfw ? 'off' : 'high',
|
||||
media_filter: 'minimal'
|
||||
});
|
||||
if (!body.results.length) return msg.say('Could not find any results.');
|
||||
return msg.say(body.results[Math.floor(Math.random() * body.results.length)].media[0].gif.url);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,54 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
const { TUMBLR_KEY } = process.env;
|
||||
|
||||
module.exports = class TumblrCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'tumblr',
|
||||
group: 'search',
|
||||
memberName: 'tumblr',
|
||||
description: 'Responds with information on a Tumblr blog.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Tumblr',
|
||||
url: 'https://www.tumblr.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.tumblr.com/docs/en/api/v2'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'blog',
|
||||
prompt: 'What blog would you like to get information on?',
|
||||
type: 'string',
|
||||
parse: blog => encodeURIComponent(blog)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { blog }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://api.tumblr.com/v2/blog/${blog}/info`)
|
||||
.query({ api_key: TUMBLR_KEY });
|
||||
const data = body.response.blog;
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x395976)
|
||||
.setAuthor('Tumblr', 'https://i.imgur.com/ouD9TUY.png', 'https://www.tumblr.com/')
|
||||
.setThumbnail(`https://api.tumblr.com/v2/blog/${blog}/avatar/512`)
|
||||
.setURL(data.url)
|
||||
.setTitle(data.title)
|
||||
.addField('❯ Posts', formatNumber(data.total_posts), true)
|
||||
.addField('❯ A.M.A.?', data.ask ? 'Yes' : 'No', true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,83 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const moment = require('moment');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { TWITCH_ID, TWITCH_SECRET } = process.env;
|
||||
|
||||
module.exports = class TwitchCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'twitch',
|
||||
group: 'search',
|
||||
memberName: 'twitch',
|
||||
description: 'Responds with information on a Twitch user.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Twitch',
|
||||
url: 'https://www.twitch.tv/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://dev.twitch.tv/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'What user would you like to get information on?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.token = null;
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
try {
|
||||
if (!this.token) await this.fetchToken();
|
||||
const { body } = await request
|
||||
.get('https://api.twitch.tv/helix/search/channels')
|
||||
.set({
|
||||
Authorization: `Bearer ${this.token}`,
|
||||
'client-id': TWITCH_ID
|
||||
})
|
||||
.query({
|
||||
query: user,
|
||||
first: 1
|
||||
});
|
||||
if (!body.data.length) return msg.say('Could not find any results.');
|
||||
const data = body.data[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x9147FF)
|
||||
.setAuthor('Twitch', 'https://i.imgur.com/6l1pPMI.jpg', 'https://www.twitch.tv/')
|
||||
.setThumbnail(data.thumbnail_url || null)
|
||||
.setURL(`https://twitch.tv/${data.broadcaster_login}`)
|
||||
.setTitle(data.display_name)
|
||||
.setDescription(data.is_live ? data.title : 'Not live')
|
||||
.setFooter(data.id)
|
||||
.addField('❯ Live?', data.is_live ? 'Yes' : 'No', true)
|
||||
.addField('❯ Start Date', data.is_live
|
||||
? moment.utc(new Date(data.started_at)).format('MM/DD/YYYY h:mm A')
|
||||
: '???', true)
|
||||
.addField('❯ Game', data.is_live ? data.game_name : '???', true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 401) await this.fetchToken();
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
|
||||
async fetchToken() {
|
||||
const { body } = await request
|
||||
.post('https://id.twitch.tv/oauth2/token')
|
||||
.query({
|
||||
client_id: TWITCH_ID,
|
||||
client_secret: TWITCH_SECRET,
|
||||
grant_type: 'client_credentials'
|
||||
});
|
||||
this.token = body.access_token;
|
||||
setTimeout(() => { this.token = null; }, body.expires_in);
|
||||
return body;
|
||||
}
|
||||
};
|
||||
@@ -1,86 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const moment = require('moment');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { formatNumber, base64, embedURL } = require('../../util/Util');
|
||||
const { TWITTER_KEY, TWITTER_SECRET } = process.env;
|
||||
const retweetRegex = /^RT @([a-zA-Z0-9_]{1,15}):/;
|
||||
|
||||
module.exports = class TwitterCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'twitter',
|
||||
group: 'search',
|
||||
memberName: 'twitter',
|
||||
description: 'Responds with information on a Twitter user.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Twitter',
|
||||
url: 'https://twitter.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://developer.twitter.com/en/docs.html'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'What user would you like to get information on?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.token = null;
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
try {
|
||||
if (!this.token) await this.fetchToken();
|
||||
const { body } = await request
|
||||
.get('https://api.twitter.com/1.1/users/show.json')
|
||||
.set({ Authorization: `Bearer ${this.token}` })
|
||||
.query({ screen_name: user });
|
||||
let latest = body.status;
|
||||
if (latest) {
|
||||
const statusUser = body.status.retweeted_status ? body.status.text.match(retweetRegex)[1] : body.screen_name;
|
||||
const statusID = body.status.retweeted_status ? body.status.retweeted_status.id_str : body.status.id_str;
|
||||
latest = embedURL(body.status.text, `https://twitter.com/${statusUser}/status/${statusID}`);
|
||||
} else {
|
||||
latest = body.protected ? '🔒 Protected' : 'No tweets found.';
|
||||
}
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x55ADEE)
|
||||
.setAuthor('Twitter', 'https://i.imgur.com/QnfcO7y.png', 'https://twitter.com/')
|
||||
.setThumbnail(body.profile_image_url_https.replace('_normal', ''))
|
||||
.setURL(`https://twitter.com/${body.screen_name}`)
|
||||
.setTitle(`${body.name} (@${body.screen_name})`)
|
||||
.setDescription(body.description)
|
||||
.addField('❯ Tweets', formatNumber(body.statuses_count), true)
|
||||
.addField('❯ Followers', formatNumber(body.followers_count), true)
|
||||
.addField('❯ Following', formatNumber(body.friends_count), true)
|
||||
.addField('❯ Protected?', body.protected ? 'Yes' : 'No', true)
|
||||
.addField('❯ Verified?', body.verified ? 'Yes' : 'No', true)
|
||||
.addField('❯ Creation Date', moment.utc(new Date(body.created_at)).format('MM/DD/YYYY h:mm A'), true)
|
||||
.addField('❯ Latest Tweet', latest);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 401) await this.fetchToken();
|
||||
if (err.status === 403) return msg.say('This user is either private or suspended.');
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
|
||||
async fetchToken() {
|
||||
const { body } = await request
|
||||
.post('https://api.twitter.com/oauth2/token')
|
||||
.set({
|
||||
Authorization: `Basic ${base64(`${TWITTER_KEY}:${TWITTER_SECRET}`)}`,
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
})
|
||||
.send('grant_type=client_credentials');
|
||||
this.token = body.access_token;
|
||||
return body;
|
||||
}
|
||||
};
|
||||
@@ -1,62 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const moment = require('moment');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class VocadbCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'vocadb',
|
||||
aliases: ['vocaloid'],
|
||||
group: 'search',
|
||||
memberName: 'vocadb',
|
||||
description: 'Searches VocaDB for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'VocaDB',
|
||||
url: 'https://vocadb.net/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://vocadb.net/swagger/ui/index'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What song would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('http://vocadb.net/api/songs')
|
||||
.query({
|
||||
query,
|
||||
maxResults: 1,
|
||||
sort: 'FavoritedTimes',
|
||||
preferAccurateMatches: true,
|
||||
nameMatchMode: 'Words',
|
||||
fields: 'ThumbUrl,Lyrics'
|
||||
});
|
||||
if (!body.items.length) return msg.say('Could not find any results.');
|
||||
const data = body.items[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x86D2D0)
|
||||
.setAuthor('VocaDB', 'https://i.imgur.com/6QwraDT.jpg', 'http://vocadb.net/')
|
||||
.setTitle(data.name)
|
||||
.setURL(`http://vocadb.net/S/${data.id}`)
|
||||
.setDescription(data.lyrics.length ? shorten(data.lyrics[0].value) : 'No lyrics available.')
|
||||
.setThumbnail(data.thumbUrl)
|
||||
.addField('❯ Artist', data.artistString)
|
||||
.addField('❯ Publish Date', moment.utc(data.publishDate).format('MM/DD/YYYY'), true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,63 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const moment = require('moment');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { shorten, formatNumber } = require('../../util/Util');
|
||||
const { WATTPAD_KEY } = process.env;
|
||||
|
||||
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'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Wattpad',
|
||||
url: 'https://www.wattpad.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.wattpad.com/developer/docs/api'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What book would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.wattpad.com/v4/stories')
|
||||
.query({
|
||||
query,
|
||||
limit: 1
|
||||
})
|
||||
.set({ Authorization: `Basic ${WATTPAD_KEY}` });
|
||||
if (!body.stories.length) return msg.say('Could not find any results.');
|
||||
const data = body.stories[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xF89C34)
|
||||
.setAuthor('Wattpad', 'https://i.imgur.com/lFTXnlz.png', 'https://www.wattpad.com/')
|
||||
.setURL(data.url)
|
||||
.setTitle(data.title)
|
||||
.setDescription(shorten(data.description))
|
||||
.setThumbnail(data.cover)
|
||||
.addField('❯ Creation Date', moment.utc(data.createDate).format('MM/DD/YYYY h:mm A'), true)
|
||||
.addField('❯ Author', data.user.name, true)
|
||||
.addField('❯ Chapters', formatNumber(data.numParts), true)
|
||||
.addField('❯ Reads', formatNumber(data.readCount), true)
|
||||
.addField('❯ Votes', formatNumber(data.voteCount), true)
|
||||
.addField('❯ Comments', formatNumber(data.commentCount), true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -52,7 +52,7 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
.setDescription(data.type === 'Normal Monster' ? `_${shorten(data.desc)}_` : shorten(data.desc))
|
||||
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/AJNBflD.png', 'http://www.yugioh-card.com/')
|
||||
.setThumbnail(data.card_images[0].image_url)
|
||||
.setFooter(data.id)
|
||||
.setFooter(data.id.toString())
|
||||
.addField('❯ Type', data.type, true)
|
||||
.addField(data.type.includes('Monster') ? '❯ Race' : '❯ Spell Type', data.race, true);
|
||||
if (data.type.includes('Monster')) {
|
||||
|
||||
Reference in New Issue
Block a user