Just some updates

This commit is contained in:
Daniel Odendahl Jr
2017-10-20 21:00:08 +00:00
parent bac7e3e6b8
commit 15d5ff0be1
25 changed files with 48 additions and 146 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ module.exports = class AkinatorCommand extends Command {
aliases: ['the-web-genie', 'web-genie'],
group: 'games',
memberName: 'akinator',
description: 'Play a game of Akinator!',
description: 'Play a game of Akinator.',
clientPermissions: ['EMBED_LINKS']
});
+5 -5
View File
@@ -88,14 +88,13 @@ module.exports = class BattleCommand extends Command {
} else if (choice === 'special') {
const hit = Math.floor(Math.random() * 4) + 1;
if (hit === 1) {
const damage = Math.floor(Math.random() * ((guard ? 300 : 150) - 100 + 1)) + 100;
const damage = Math.floor(Math.random() * ((guard ? 150 : 300) - 100 + 1)) + 100;
await msg.say(`${user} deals **${damage}** damage!`);
dealDamage(damage);
reset();
} else {
await msg.say(`${user}'s attack missed!`);
reset();
}
reset();
} else if (choice === 'run') {
await msg.say(`${user} flees!`);
forfeit();
@@ -105,10 +104,11 @@ module.exports = class BattleCommand extends Command {
}
}
this.fighting.delete(msg.channel.id);
const userWin = userHP > oppoHP;
return msg.say(stripIndents`
The match is over!
**Winner**: ${userHP > oppoHP ? `${msg.author} (${userHP}HP)` : `${opponent} (${oppoHP}HP)`}
**Loser**: ${userHP > oppoHP ? `${opponent} (${oppoHP}HP)` : `${msg.author} (${userHP}HP)`}
**Winner**: ${userWin ? `${msg.author} (${userHP}HP)` : `${opponent} (${oppoHP}HP)`}
**Loser**: ${userWin ? `${opponent} (${oppoHP}HP)` : `${msg.author} (${userHP}HP)`}
`);
} catch (err) {
this.fighting.delete(msg.channel.id);
+2 -1
View File
@@ -63,7 +63,8 @@ module.exports = class EmojiEmojiRevolutionCommand extends Command {
}
this.playing.delete(msg.channel.id);
if (aPts === oPts) return msg.say('It\'s a tie!');
return msg.say(`You win ${aPts > oPts ? msg.author : opponent} with ${aPts > oPts ? aPts : oPts} points!`);
const userWin = aPts > oPts;
return msg.say(`You win ${userWin ? msg.author : opponent} with ${userWin ? aPts : oPts} points!`);
} catch (err) {
this.playing.delete(msg.channel.id);
throw err;
+2 -2
View File
@@ -36,7 +36,7 @@ module.exports = class GunfightCommand extends Command {
return msg.say('Looks like they declined...');
}
await msg.say('Get Ready...');
const length = Math.floor(Math.random() * ((30000 - 1000) + 1)) + 1000;
const length = Math.floor(Math.random() * (30000 - 1000 + 1)) + 1000;
await wait(length);
const word = words[Math.floor(Math.random() * words.length)];
await msg.say(`TYPE \`${word.toUpperCase()}\` NOW!`);
@@ -47,7 +47,7 @@ module.exports = class GunfightCommand extends Command {
});
this.fighting.delete(msg.channel.id);
if (!winner.size) return msg.say('Oh... No one won.');
return msg.say(`And the winner is ${winner.first().author.username}!`);
return msg.say(`The winner is ${winner.first().author}!`);
} catch (err) {
this.fighting.delete(msg.channel.id);
throw err;
+4 -1
View File
@@ -49,7 +49,10 @@ module.exports = class HangmanCommand extends Command {
}
const choice = guess.first().content.toLowerCase();
if (choice === 'end') break;
if (confirmation.includes(choice) || incorrect.includes(choice)) {
if (choice.length > 1) {
if (word === choice) break;
else await msg.say('Nope, that\'s not the word, try again!');
} else if (confirmation.includes(choice) || incorrect.includes(choice)) {
await msg.say('You have already picked that letter!');
} else if (word.includes(choice)) {
await msg.say('Nice job!');
+1 -2
View File
@@ -20,8 +20,7 @@ module.exports = class WhosThatPokemonCommand extends Command {
{
key: 'hide',
prompt: 'Do you want to silhouette the Pokémon\'s image?',
type: 'boolean',
default: false
type: 'boolean'
}
]
});
+2 -2
View File
@@ -38,8 +38,8 @@ module.exports = class GuessMyLooksCommand extends Command {
const extra = extras[Math.floor(Math.random() * extras.length)];
const prefix = user.id === msg.author.id ? 'You' : 'They';
return msg.reply(oneLine`
${prefix} are, I think, a ${age} year old ${gender} with ${eyeColor} eyes and ${hairStyle}
${hairColor} hair. ${prefix} are ${feet}'${inches}" and weigh ${weight} pounds. Don't forget the ${extra}!
${prefix} are, I think, a ${age} year old ${gender} with ${eyeColor} eyes and ${hairStyle} ${hairColor} hair.
${prefix} are ${feet}'${inches}" and weigh ${weight} pounds. Don't forget the ${extra}!
`);
}
};
+1 -8
View File
@@ -27,11 +27,6 @@ module.exports = class BotInfoCommand extends Command {
const { body } = await snekfetch
.get(`https://bots.discord.pw/api/bots/${bot.id}`)
.set({ Authorization: DBOTS_KEY });
const owners = [];
for (const owner of body.owner_ids) {
const user = await this.client.users.fetch(owner);
owners.push(user.tag);
}
const embed = new MessageEmbed()
.setColor(0x9797FF)
.setAuthor('Discord Bots', 'https://i.imgur.com/tHTKaks.jpg')
@@ -43,9 +38,7 @@ module.exports = class BotInfoCommand extends Command {
.addField(' Invite',
`[Here](${body.invite_url})`, true)
.addField(' Prefix',
body.prefix, true)
.addField(' Owner(s)',
owners.join(', '), true);
body.prefix, true);
return msg.embed(embed);
} catch (err) {
if (err.status === 404) return msg.say('Could not find any results.');
+1 -1
View File
@@ -44,7 +44,7 @@ module.exports = class BulbapediaCommand extends Command {
.setTitle(data.title)
.setAuthor('Bulbapedia', 'https://i.imgur.com/ePpoeFA.png')
.setThumbnail(data.thumbnail ? data.thumbnail.source : null)
.setURL(`https://bulbapedia.bulbagarden.net/wiki/${encodeURIComponent(query.replace(/\)/gi, '%29'))}`)
.setURL(`https://bulbapedia.bulbagarden.net/wiki/${encodeURIComponent(query.replace(/\)/g, '%29'))}`)
.setDescription(shorten(data.extract.replace(/\n/g, '\n\n')));
return msg.embed(embed);
} catch (err) {
+3 -2
View File
@@ -1,6 +1,7 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
const { GITHUB_LOGIN } = process.env;
module.exports = class GitHubCommand extends Command {
@@ -37,8 +38,8 @@ module.exports = class GitHubCommand extends Command {
.setAuthor('GitHub', 'https://i.imgur.com/e4HunUm.png')
.setTitle(body.full_name)
.setURL(body.html_url)
.setDescription(body.description || 'No description.')
.setThumbnail(body.owner.avatar_url || null)
.setDescription(body.description ? shorten(body.description) : 'No description.')
.setThumbnail(body.owner.avatar_url)
.addField(' Stars',
body.stargazers_count, true)
.addField(' Forks',
-52
View File
@@ -1,52 +0,0 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class IPInfoCommand extends Command {
constructor(client) {
super(client, {
name: 'ip-info',
aliases: ['ip'],
group: 'search',
memberName: 'ip-info',
description: 'Gets data for an IP address.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'ip',
prompt: 'Which IP would you like to get information on?',
type: 'string',
parse: ip => encodeURIComponent(ip)
}
]
});
}
async run(msg, { ip }) {
try {
const { body } = await snekfetch.get(`https://ipinfo.io/${ip}/json`);
const embed = new MessageEmbed()
.setColor(0x9797FF)
.setURL(`https://ipinfo.io/${ip}`)
.setTitle(body.ip)
.addField(' Hostname',
body.hostname || 'N/A')
.addField(' Location',
body.loc || 'N/A', true)
.addField(' Organization',
body.org || 'N/A', true)
.addField(' Zip',
body.postal || 'N/A', true)
.addField(' City',
body.city || 'N/A', true)
.addField(' Region',
body.region || 'N/A', true)
.addField(' Country',
body.country || 'N/A', true);
return msg.embed(embed);
} catch (err) {
if (err.status === 404) return msg.say('Could not find any results.');
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+4 -3
View File
@@ -1,6 +1,7 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
module.exports = class KickstarterCommand extends Command {
constructor(client) {
@@ -36,12 +37,12 @@ module.exports = class KickstarterCommand extends Command {
.setTitle(data.name)
.setURL(data.urls.web.project)
.setAuthor('Kickstarter', 'https://i.imgur.com/EHDlH5t.png')
.setDescription(data.blurb)
.setDescription(shorten(data.blurb))
.setThumbnail(data.photo ? data.photo.full : null)
.addField(' Goal',
`${data.currency_symbol}${data.goal.toLocaleString()}`, true)
`${data.currency_symbol}${data.goal}`, true)
.addField(' Pledged',
`${data.currency_symbol}${data.pledged.toLocaleString()}`, true)
`${data.currency_symbol}${data.pledged}`, true)
.addField(' Backers',
data.backers_count, true)
.addField(' Creator',
+2 -1
View File
@@ -1,6 +1,7 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
module.exports = class MDNCommand extends Command {
constructor(client) {
@@ -33,7 +34,7 @@ module.exports = class MDNCommand extends Command {
.setAuthor('MDN', 'https://i.imgur.com/DFGXabG.png')
.setURL(data.url)
.setTitle(data.title)
.setDescription(data.excerpt);
.setDescription(shorten(data.excerpt));
return msg.embed(embed);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
+2 -1
View File
@@ -1,6 +1,7 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
const { NYTIMES_KEY } = process.env;
module.exports = class NewYorkTimesCommand extends Command {
@@ -38,7 +39,7 @@ module.exports = class NewYorkTimesCommand extends Command {
.setAuthor('New York Times', 'https://i.imgur.com/ZbuTWwO.png')
.setURL(data.web_url)
.setTitle(data.headline.main)
.setDescription(data.snippet)
.setDescription(shorten(data.snippet))
.addField(' Publish Date',
new Date(data.pub_date).toDateString(), true);
return msg.embed(embed);
+2 -2
View File
@@ -31,7 +31,7 @@ module.exports = class NPMCommand extends Command {
.setAuthor('NPM', 'https://i.imgur.com/ErKf5Y0.png')
.setTitle(body.name)
.setURL(`https://www.npmjs.com/package/${query}`)
.setDescription(body.description || 'No Description.')
.setDescription(body.description ? shorten(body.description) : 'No description.')
.addField(' Version',
body['dist-tags'].latest, true)
.addField(' License',
@@ -47,7 +47,7 @@ module.exports = class NPMCommand extends Command {
.addField(' Keywords',
body.keywords && body.keywords.length ? shorten(body.keywords.join(', '), 1000) : 'None')
.addField(' Maintainers',
body.maintainers.map(user => user.name).join(', '));
shorten(body.maintainers.map(user => user.name).join(', '), 1000));
return msg.embed(embed);
} catch (err) {
if (err.status === 404) return msg.say('Could not find any results.');
+1 -1
View File
@@ -34,7 +34,7 @@ module.exports = class PokedexCommand extends Command {
.setURL(`https://www.serebii.net/pokedex-sm/${id}.shtml`)
.setDescription(stripIndents`
**The ${filterPkmn(body.genera).genus} Pokémon**
${filterPkmn(body.flavor_text_entries).flavor_text.replace(/(\n|\f|\r)/g, ' ')}
${filterPkmn(body.flavor_text_entries).flavor_text.replace(/\n|\f|\r/g, ' ')}
`)
.setThumbnail(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
return msg.embed(embed);
-48
View File
@@ -1,48 +0,0 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
module.exports = class StudioGhibliCommand extends Command {
constructor(client) {
super(client, {
name: 'studio-ghibli',
aliases: ['ghibli', 'ghibli-film', 'studio-ghibli-film'],
group: 'search',
memberName: 'studio-ghibli',
description: 'Searches Studio Ghibli films for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What film would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, { query }) {
try {
const { body } = await snekfetch
.get('http://ghibliapi.herokuapp.com/films')
.query({ title: query });
if (!body.length) return msg.say('Could not find any results.');
const data = body[0];
const embed = new MessageEmbed()
.setColor(0xE7E7E7)
.setAuthor('Studio Ghibli', 'https://i.imgur.com/fQvw2B8.jpg')
.setTitle(data.title)
.setDescription(shorten(data.description))
.addField(' Release Year',
data.release_date || 'N/A', true)
.addField(' Director',
data.director || 'N/A', true)
.addField(' Rotten Tomatoes Score',
data.rt_score ? `${data.rt_score}%` : 'N/A', true);
return msg.embed(embed);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+4 -4
View File
@@ -32,12 +32,12 @@ module.exports = class ThesaurusCommand extends Command {
api_key: WORDNIK_KEY
});
if (!body.length) return msg.say('Could not find any results.');
const synonyms = body.find(i => i.relationshipType === 'synonym');
const antonyms = body.find(i => i.relationshipType === 'antonym');
const synonyms = body.filter(word => word.relationshipType === 'synonym');
const antonyms = body.filter(word => word.relationshipType === 'antonym');
return msg.say(stripIndents`
**${query}**
__Synonyms:__ ${synonyms ? synonyms.words.join(', ') : 'N/A'}
__Antonyms:__ ${antonyms ? antonyms.words.join(', ') : 'N/A'}
__Synonyms:__ ${synonyms.length ? synonyms.words.join(', ') : 'N/A'}
__Antonyms:__ ${antonyms.length ? antonyms.words.join(', ') : 'N/A'}
`);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
+2 -2
View File
@@ -28,7 +28,7 @@ module.exports = class UrbanCommand extends Command {
.get('http://api.urbandictionary.com/v0/define')
.query({ term: query });
if (!body.list.length) return msg.say('Could not find any results.');
const data = body.list[0];
const data = body.list[Math.floor(Math.random() * body.list.length)];
const embed = new MessageEmbed()
.setColor(0x32A8F0)
.setAuthor('Urban Dictionary', 'https://i.imgur.com/Fo0nRTe.png')
@@ -36,7 +36,7 @@ module.exports = class UrbanCommand extends Command {
.setTitle(data.word)
.setDescription(shorten(data.definition))
.addField(' Example',
shorten(data.example, 1000) || 'None');
data.example ? shorten(data.example, 1000) : 'None');
return msg.embed(embed);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
+1 -1
View File
@@ -44,7 +44,7 @@ module.exports = class WikipediaCommand extends Command {
.setTitle(data.title)
.setAuthor('Wikipedia', 'https://i.imgur.com/Z7NJBK2.png')
.setThumbnail(data.thumbnail ? data.thumbnail.source : null)
.setURL(`https://en.wikipedia.org/wiki/${encodeURIComponent(query.replace(/\)/gi, '%29'))}`)
.setURL(`https://en.wikipedia.org/wiki/${encodeURIComponent(query.replace(/\)/g, '%29'))}`)
.setDescription(shorten(data.extract.replace(/\n/g, '\n\n')));
return msg.embed(embed);
} catch (err) {
+2 -1
View File
@@ -1,6 +1,7 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
const { GOOGLE_KEY } = process.env;
module.exports = class YouTubeCommand extends Command {
@@ -38,7 +39,7 @@ module.exports = class YouTubeCommand extends Command {
const embed = new MessageEmbed()
.setColor(0xDD2825)
.setTitle(data.snippet.title)
.setDescription(data.snippet.description)
.setDescription(shorten(data.snippet.description))
.setAuthor(`YouTube - ${data.snippet.channelTitle}`, 'https://i.imgur.com/kKHJg9Q.png')
.setURL(`https://www.youtube.com/watch?v=${data.id.videoId}`)
.setThumbnail(data.snippet.thumbnails.default.url);
+2 -1
View File
@@ -1,6 +1,7 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
module.exports = class YuGiOhCommand extends Command {
constructor(client) {
@@ -31,7 +32,7 @@ module.exports = class YuGiOhCommand extends Command {
const embed = new MessageEmbed()
.setColor(0xBE5F1F)
.setTitle(data.name)
.setDescription(data.text)
.setDescription(shorten(data.text))
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/AJNBflD.png')
.setThumbnail(image.headers.location)
.addField(' Card Type',
+2 -2
View File
@@ -14,7 +14,7 @@ module.exports = class BCommand extends Command {
prompt: 'What text would you like to 🅱?',
type: 'string',
validate: text => {
if (text.replace(/(b|d|g|p|q)/gi, '🅱').length < 2000) return true;
if (text.replace(/b/gi, '🅱').length < 2000) return true;
return 'Invalid text, your text is too long.';
}
}
@@ -23,6 +23,6 @@ module.exports = class BCommand extends Command {
}
run(msg, { text }) {
return msg.say(text.replace(/(b|d|g|p|q)/gi, '🅱'));
return msg.say(text.replace(/b/gi, '🅱'));
}
};
+1 -1
View File
@@ -10,7 +10,7 @@ module.exports = class UpvoteCommand extends Command {
aliases: ['upvoters', 'updoot'],
group: 'util',
memberName: 'upvote',
description: 'Responds with Xiao\'s upvoter link on Discord Bots.',
description: 'Responds with Xiao\'s upvoter link on discordbots.org.',
guarded: true
});
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "48.1.1",
"version": "49.0.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {