IGDB Command, Minor changes

This commit is contained in:
Daniel Odendahl Jr
2017-12-12 04:06:26 +00:00
parent dd1a980ce9
commit 8bcbb3902c
13 changed files with 101 additions and 26 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class HoroscopeCommand extends Command {
const embed = new MessageEmbed()
.setColor(0x9797FF)
.setTitle(`Horoscope for ${body.sunsign}...`)
.setURL('https://new.theastrologer.com/horoscopes/')
.setURL(`https://new.theastrologer.com/${body.sunsign}/`)
.setTimestamp()
.setDescription(body.horoscope)
.addField(' Mood',
+1 -1
View File
@@ -31,7 +31,7 @@ module.exports = class EmojiInfoCommand extends Command {
emoji.id, true)
.addField(' Creation Date',
emoji.createdAt.toDateString(), true)
.addField(' External',
.addField(' External?',
emoji.managed ? 'Yes' : 'No', true);
return msg.embed(embed);
}
+2 -2
View File
@@ -35,9 +35,9 @@ module.exports = class RoleInfoCommand extends Command {
role.hexColor.toUpperCase(), true)
.addField(' Creation Date',
role.createdAt.toDateString(), true)
.addField(' Hoisted',
.addField(' Hoisted?',
role.hoist ? 'Yes' : 'No', true)
.addField(' Mentionable',
.addField(' Mentionable?',
role.mentionable ? 'Yes' : 'No', true)
.addField(' Permissions',
perms.map(perm => permissions[perm]).join(', ') || 'None');
+2 -2
View File
@@ -48,9 +48,9 @@ module.exports = class GitHubCommand extends Command {
body.open_issues, true)
.addField(' Language',
body.language || '???', true)
.addField(' Created',
.addField(' Creation Date',
new Date(body.created_at).toDateString(), true)
.addField(' Modified',
.addField(' Modification Date',
new Date(body.updated_at).toDateString(), true);
return msg.embed(embed);
} catch (err) {
+60
View File
@@ -0,0 +1,60 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
const { IGDB_KEY } = process.env;
const esrb = ['RP', 'EC', 'E', 'E10+', 'T', 'M', 'AO'];
const statuses = ['Released', '???', 'Alpha', 'Beta', 'Early Access', 'Offline', 'Cancelled'];
module.exports = class IGDBCommand extends Command {
constructor(client) {
super(client, {
name: 'igdb',
aliases: ['igdb-video-game', 'game', 'video-game', 'game'],
group: 'search',
memberName: 'igdb',
description: 'Searches IGDB for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What video game would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, { query }) {
try {
const { body } = await snekfetch
.get('https://api-2445582011268.apicast.io/games/')
.query({
search: query,
limit: 1,
fields: '*',
'filter[version_parent][not_exists]': 1
})
.set({ 'user-key': IGDB_KEY });
const data = body[0];
const embed = new MessageEmbed()
.setColor(0x01DF6B)
.setTitle(data.name)
.setURL(data.url)
.setAuthor('IGDB', 'https://i.imgur.com/LHLQEns.png')
.setDescription(data.summary ? shorten(data.summary) : 'No description available.')
.setThumbnail(data.cover ? data.cover.url : null)
.addField(' ESRB Rating',
data.esrb ? esrb[data.esrb.rating] : '???', true)
.addField(' Release Date',
data.first_release_date ? new Date(data.first_release_date * 1000).toDateString() : '???', true)
.addField(' Status',
data.status ? statuses[data.status] : '???', true)
.addField(' Score',
data.total_rating || '???', true);
return msg.embed(embed);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+5 -1
View File
@@ -46,7 +46,11 @@ module.exports = class KickstarterCommand extends Command {
.addField(' Backers',
data.backers_count, true)
.addField(' Creator',
data.creator.name, true);
data.creator.name, true)
.addField(' Creation Date',
new Date(data.created_at * 1000).toDateString(), true)
.addField(' Deadline',
new Date(data.deadline * 1000).toDateString(), true);
return msg.embed(embed);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
+22 -11
View File
@@ -24,21 +24,14 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command {
});
this.version = null;
this.client.setInterval(() => { this.version = null; }, 3600000);
}
async run(msg, { champion }) {
if (champion === 'satan') champion = 'teemo';
try {
if (!this.version) this.version = await this.fetchVersion();
const search = await snekfetch
.get(`https://ddragon.leagueoflegends.com/cdn/${this.version}/data/en_US/champion.json`);
const name = Object.keys(search.body.data).find(key => key.toLowerCase() === champion);
if (!name) return msg.say('Could not find any results.');
const { id } = search.body.data[name];
const { body } = await snekfetch
.get(`https://ddragon.leagueoflegends.com/cdn/${this.version}/data/en_US/champion/${id}.json`);
const data = body.data[id];
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)
@@ -92,6 +85,24 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command {
const { body } = await snekfetch
.get('https://na1.api.riotgames.com/lol/static-data/v3/versions')
.query({ api_key: RIOT_KEY });
return body[0];
[this.version] = body;
this.client.setInterval(() => { this.version = null; }, 3600000);
return body;
}
async fetchChampions() {
const { body } = await snekfetch
.get(`https://ddragon.leagueoflegends.com/cdn/${this.version}/data/en_US/champion.json`);
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 snekfetch
.get(`https://ddragon.leagueoflegends.com/cdn/${this.version}/data/en_US/champion/${id}.json`);
return body.data[id];
}
};
+2 -2
View File
@@ -42,9 +42,9 @@ module.exports = class NPMCommand extends Command {
body.license || 'None', true)
.addField(' Author',
body.author ? body.author.name : 'Unknown', true)
.addField(' Created',
.addField(' Creation Date',
new Date(body.time.created).toDateString(), true)
.addField(' Modified',
.addField(' Modification Date',
new Date(body.time.modified).toDateString(), true)
.addField(' Main File',
version.main || '???', true)
+1 -1
View File
@@ -51,7 +51,7 @@ module.exports = class StackOverflowCommand extends Command {
data.view_count, true)
.addField(' Score',
data.score, true)
.addField(' Created',
.addField(' Creation Date',
new Date(data.creation_date * 1000).toDateString(), true)
.addField(' Last Activity',
new Date(data.last_activity_date * 1000).toDateString(), true);
+1 -1
View File
@@ -59,7 +59,7 @@ module.exports = class SteamCommand extends Command {
data.recommendations ? data.recommendations.total : '???', true)
.addField(' Platforms',
platforms.join(', ') || 'None', true)
.addField(' Release Data',
.addField(' Release Date',
data.release_date ? data.release_date.date : '???', true)
.addField(' DLC Count',
data.dlc ? data.dlc.length : 0, true)
+1 -1
View File
@@ -48,7 +48,7 @@ module.exports = class TwitterCommand extends Command {
body.protected ? 'Yes' : 'No', true)
.addField(' Verified?',
body.verified ? 'Yes' : 'No', true)
.addField(' Created',
.addField(' Creation Date',
new Date(body.created_at).toDateString(), true)
.addField(' Latest Tweet',
body.status ? body.status.text : 'None');
+2 -2
View File
@@ -41,11 +41,11 @@ module.exports = class WattpadCommand extends Command {
.setTitle(data.title)
.setDescription(shorten(data.description))
.setThumbnail(data.cover)
.addField(' Created On',
.addField(' Creation Date',
new Date(data.createDate).toDateString(), true)
.addField(' Author',
data.user, true)
.addField(' Parts',
.addField(' Chapters',
data.numParts, true)
.addField(' Reads',
data.readCount, true)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "56.5.1",
"version": "56.6.0",
"description": "Your personal server companion.",
"main": "XiaoBot.js",
"scripts": {