Lots of changes

This commit is contained in:
dragonfire535
2017-10-07 11:18:08 -04:00
parent e81226dbd6
commit a006a8a8de
32 changed files with 68 additions and 53 deletions
@@ -1,28 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { shorten } = require('../../structures/Util');
const { GOV_KEY } = process.env;
module.exports = class AstronomyPictureOfTheDayCommand extends Command {
constructor(client) {
super(client, {
name: 'astronomy-picture-of-the-day',
aliases: ['nasa-apod', 'apod', 'nasa-astronomy-picture-of-the-day'],
group: 'random',
memberName: 'astronomy-picture-of-the-day',
description: 'Responds with today\'s Astronomy Picture of the Day.',
clientPermissions: ['ATTACH_FILES']
});
}
async run(msg) {
try {
const { body } = await snekfetch
.get('https://api.nasa.gov/planetary/apod')
.query({ api_key: GOV_KEY });
return msg.say(shorten(body.explanation), { files: [body.url] });
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-31
View File
@@ -1,31 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class AvatarCommand extends Command {
constructor(client) {
super(client, {
name: 'avatar',
aliases: ['profile-picture', 'profile-pic'],
group: 'random',
memberName: 'avatar',
description: 'Responds with a link to a user\'s avatar.',
args: [
{
key: 'user',
prompt: 'Which user would you like to get the avatar of?',
type: 'user',
default: ''
}
]
});
}
run(msg, { user }) {
if (!user) user = msg.author;
if (!user.avatar) return msg.say('This user has no avatar.');
const avatar = user.avatarURL({
format: user.avatar.startsWith('a_') ? 'gif' : 'png',
size: 2048
});
return msg.say(avatar);
}
};
-16
View File
@@ -1,16 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class CanYouNotCommand extends Command {
constructor(client) {
super(client, {
name: 'can-you-not',
group: 'random',
memberName: 'can-you-not',
description: 'Can YOU not?'
});
}
run(msg) {
return msg.say('Can YOU not?');
}
};
-33
View File
@@ -1,33 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class CoolnessCommand extends Command {
constructor(client) {
super(client, {
name: 'coolness',
group: 'random',
memberName: 'coolness',
description: 'Determines your coolness.',
args: [
{
key: 'user',
prompt: 'Which user do you want to determine the coolness of?',
type: 'user',
default: ''
}
]
});
}
run(msg, { user }) {
if (!user) user = msg.author;
const coolness = user.id / this.client.user.id;
const prefix = user.id === msg.author.id ? 'You\'re' : 'They\'re';
if (user.id === '234318196893548545') return msg.reply(`${prefix} the best person ever ❤.`);
if (coolness < 0.3) return msg.reply(`${prefix} the coolest being to walk this Earth.`);
if (coolness < 0.5) return msg.reply(`${prefix} an extremely cool dude.`);
if (coolness < 0.8) return msg.reply(`${prefix} pretty sweet, not gonna lie.`);
if (coolness < 1) return msg.reply(`${prefix} okay, nothing special.`);
if (coolness < 1.3) return msg.reply(`${prefix} just not all that neat.`);
return msg.reply(`${prefix} awful, honestly.`);
}
};
-18
View File
@@ -1,18 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class DarkThemeLightThemeCommand extends Command {
constructor(client) {
super(client, {
name: 'dark-theme-light-theme',
aliases: ['light-theme-dark-theme', 'dark-theme', 'light-theme'],
group: 'random',
memberName: 'dark-theme-light-theme',
description: 'Determines whether you use dark or light theme.',
clientPermissions: ['ATTACH_FILES']
});
}
run(msg) {
return msg.say({ files: ['https://i.imgur.com/k0G7sZL.png'] });
}
};
-34
View File
@@ -1,34 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class DaysUntilCommand extends Command {
constructor(client) {
super(client, {
name: 'days-until',
aliases: ['days-until-christmas'],
group: 'random',
memberName: 'days-until',
description: 'Responds with how many days until a certain date this year.',
args: [
{
key: 'date',
prompt: 'What date do you want to get the days until? Month/Day format.',
type: 'string',
default: ['12', '25'],
parse: date => date.split('/')
}
]
});
}
run(msg, { date }) {
const month = parseInt(date[0], 10);
const day = parseInt(date[1], 10);
if (!month || !day) return msg.say('There are N/A days until Invalid Date!');
const now = new Date();
let year = now.getMonth() + 1 <= month ? now.getFullYear() : now.getFullYear() + 1;
if (month === now.getMonth() + 1 && now.getDate() >= day) ++year;
const future = new Date(`${month}/${day}/${year}`);
const time = Math.round((future - now) / (1000 * 60 * 60 * 24)) + 1;
return msg.say(`There are ${time || 'N/A'} days until ${future.toDateString()}!`);
}
};
-17
View File
@@ -1,17 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class EatPantCommand extends Command {
constructor(client) {
super(client, {
name: 'eat-pant',
group: 'random',
memberName: 'eat-pant',
description: 'eat pant',
clientPermissions: ['ATTACH_FILES']
});
}
run(msg) {
return msg.say({ files: ['https://i.imgur.com/sSmhvxt.jpg'] });
}
};
-33
View File
@@ -1,33 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
module.exports = class GenderGuessCommand extends Command {
constructor(client) {
super(client, {
name: 'gender-guess',
aliases: ['gender', 'guess-gender'],
group: 'random',
memberName: 'gender',
description: 'Determines the gender of name.',
args: [
{
key: 'name',
prompt: 'What name do you want to determine the gender of?',
type: 'string'
}
]
});
}
async run(msg, { name }) {
try {
const { body } = await snekfetch
.get('https://api.genderize.io/')
.query({ name });
if (!body.gender) return msg.say(`I have no idea what gender ${body.name} is.`);
return msg.say(`I'm ${Math.round(body.probability * 100)}% sure ${body.name} is a ${body.gender} name.`);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-16
View File
@@ -1,16 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class GiveFlowerCommand extends Command {
constructor(client) {
super(client, {
name: 'give-flower',
group: 'random',
memberName: 'give-flower',
description: 'Gives Xiao Pai a flower.'
});
}
run(msg) {
return msg.say('Ooh, what a pretty flower. What, I may have it? Thanks! I like flowers, yes? ♪');
}
};
-53
View File
@@ -1,53 +0,0 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { list } = require('../../structures/Util');
const signs = require('../../assets/json/horoscope');
module.exports = class HoroscopeCommand extends Command {
constructor(client) {
super(client, {
name: 'horoscope',
group: 'random',
memberName: 'horoscope',
description: 'Responds with today\'s horoscope for a particular sign.',
details: `**Signs:** ${signs.join(', ')}`,
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'sign',
prompt: `Which sign would you like to get the horoscope for? Either ${list(signs, 'or')}.`,
type: 'string',
validate: sign => {
if (signs.includes(sign.toLowerCase())) return true;
return `Invalid sign, please enter either ${list(signs, 'or')}.`;
},
parse: sign => sign.toLowerCase()
}
]
});
}
async run(msg, { sign }) {
try {
const { text } = await snekfetch
.get(`http://sandipbgt.com/theastrologer/api/horoscope/${sign}/today/`);
const body = JSON.parse(text);
const embed = new MessageEmbed()
.setColor(0x9797FF)
.setTitle(`Horoscope for ${body.sunsign}...`)
.setURL('https://new.theastrologer.com/horoscopes/')
.setTimestamp()
.setDescription(body.horoscope)
.addField(' Mood',
body.meta.mood, true)
.addField(' Intensity',
body.meta.intensity, true)
.addField(' Date',
body.date, true);
return msg.embed(embed);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-17
View File
@@ -1,17 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class ItsJokeCommand extends Command {
constructor(client) {
super(client, {
name: 'its-joke',
group: 'random',
memberName: 'its-joke',
description: 'It\'s joke!',
clientPermissions: ['ATTACH_FILES']
});
}
run(msg) {
return msg.say({ files: ['https://i.imgur.com/NwKdpKK.jpg'] });
}
};
-16
View File
@@ -1,16 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class LennyCommand extends Command {
constructor(client) {
super(client, {
name: 'lenny',
group: 'random',
memberName: 'lenny',
description: 'Responds with the lenny face.'
});
}
run(msg) {
return msg.say('( ͡° ͜ʖ ͡°)');
}
};
-25
View File
@@ -1,25 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class LMGTFYCommand extends Command {
constructor(client) {
super(client, {
name: 'lmgtfy',
aliases: ['let-me-google-that-for-you', 'google'],
group: 'random',
memberName: 'lmgtfy',
description: 'Creates a LMGTFY link with the query you provide.',
args: [
{
key: 'query',
prompt: 'What would you like the link to search for?',
type: 'string',
parse: query => encodeURIComponent(query)
}
]
});
}
run(msg, { query }) {
return msg.say(`http://lmgtfy.com/?iie=1&q=${query}`);
}
};
-34
View File
@@ -1,34 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { GOOGLE_KEY } = process.env;
module.exports = class ShortenURLCommand extends Command {
constructor(client) {
super(client, {
name: 'shorten-url',
aliases: ['short-url', 'url-shorten', 'url-short'],
group: 'random',
memberName: 'shorten-url',
description: 'Creates a goo.gl short URL from another URL.',
args: [
{
key: 'url',
prompt: 'What url do you want to shorten?',
type: 'string'
}
]
});
}
async run(msg, { url }) {
try {
const { body } = await snekfetch
.post('https://www.googleapis.com/urlshortener/v1/url')
.query({ key: GOOGLE_KEY })
.send({ longUrl: url });
return msg.say(`<${body.id}>`);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-16
View File
@@ -1,16 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class SlowClapCommand extends Command {
constructor(client) {
super(client, {
name: 'slow-clap',
group: 'random',
memberName: 'slow-clap',
description: '_slow clap_'
});
}
run(msg) {
return msg.say('_slow clap_');
}
};
-56
View File
@@ -1,56 +0,0 @@
const { Command } = require('discord.js-commando');
const { list } = require('../../structures/Util');
const path = require('path');
const sounds = ['airhorn', 'cat', 'dun-dun-dun', 'laugh track', 'pikachu', 'space'];
module.exports = class SoundboardCommand extends Command {
constructor(client) {
super(client, {
name: 'soundboard',
aliases: ['sound'],
group: 'random',
memberName: 'soundboard',
description: 'Plays a sound in your voice channel.',
details: `**Sounds:** ${sounds.join(', ')}`,
guildOnly: true,
throttling: {
usages: 1,
duration: 15
},
args: [
{
key: 'sound',
prompt: `What sound would you like to play? Either ${list(sounds, 'or')}.`,
type: 'string',
default: '',
validate: sound => {
if (sounds.includes(sound.toLowerCase())) return true;
return `Invalid sound, please enter either ${list(sounds, 'or')}.`;
},
parse: sound => sound.toLowerCase()
}
]
});
}
async run(msg, { sound }) {
if (!sound) sound = sounds[Math.floor(Math.random() * sounds.length)];
const channel = msg.member.voiceChannel;
if (!channel) return msg.say('Please enter a voice channel first.');
if (!channel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK'])) {
return msg.say('Missing the "Connect" or "Speak" permission for the voice channel.');
}
if (!channel.joinable) return msg.say('Your voice channel is not joinable.');
if (this.client.voiceConnections.has(channel.guild.id)) return msg.say('I am already playing a sound.');
try {
const connection = await channel.join();
const dispatcher = connection.playFile(path.join(__dirname, '..', '..', 'assets', 'sounds', `${sound}.mp3`));
dispatcher.once('end', () => channel.leave());
dispatcher.once('error', () => channel.leave());
return null;
} catch (err) {
channel.leave();
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-17
View File
@@ -1,17 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class SpamCommand extends Command {
constructor(client) {
super(client, {
name: 'spam',
group: 'random',
memberName: 'spam',
description: 'Responds with a picture of Spam.',
clientPermissions: ['ATTACH_FILES']
});
}
run(msg) {
return msg.say({ files: ['https://i.imgur.com/Az9IrXY.jpg'] });
}
};
-36
View File
@@ -1,36 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { stripIndents } = require('common-tags');
module.exports = class SpoopyLinkCommand extends Command {
constructor(client) {
super(client, {
name: 'spoopy-link',
group: 'random',
memberName: 'spoopy-link',
description: 'Checks if a link is spoopy or not.',
args: [
{
key: 'site',
prompt: 'What site do you think is spoopy?',
type: 'string',
parse: site => encodeURIComponent(site)
}
]
});
}
async run(msg, { site }) {
if (/discord(\.gg|app\.com%2Finvite|\.me)%2F/gi.test(site)) return msg.say('Discord invites are safe!');
try {
const { body } = await snekfetch
.get(`https://spoopy.link/api/${site}`);
return msg.say(stripIndents`
${body.safe ? 'This site is safe!' : 'This site may not be safe...'}
${body.chain.map(url => `<${url.url}> [${url.safe ? 'SAFE' : `UNSAFE: ${url.reasons.join(', ')}`}]`).join('\n')}
`);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-53
View File
@@ -1,53 +0,0 @@
const { Command } = require('discord.js-commando');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
module.exports = class StrawpollCommand extends Command {
constructor(client) {
super(client, {
name: 'strawpoll',
aliases: ['poll'],
group: 'random',
memberName: 'strawpoll',
description: 'Creates a Strawpoll from the options you provide.',
args: [
{
key: 'title',
prompt: 'What would you like the title of the Strawpoll to be?',
type: 'string',
validate: title => {
if (title.length < 200) return true;
return 'Invalid title, please keep the title under 200 characters.';
}
},
{
key: 'options',
prompt: 'What options do you want to be able to pick from? You may have a maximum of 30.',
type: 'string',
infinite: true,
validate: choice => {
if (choice.length < 140) return true;
return 'Invalid option, please keep options under 140 characters each.';
}
}
]
});
}
async run(msg, { title, options }) {
if (options.length < 2) return msg.say('Please provide more than one choice.');
if (options.length > 31) return msg.say('Please provide thirty or less choices.');
try {
const { body } = await snekfetch
.post('https://www.strawpoll.me/api/v2/polls')
.set({ 'Content-Type': 'application/json' })
.send({ title, options });
return msg.say(stripIndents`
${body.title}
http://www.strawpoll.me/${body.id}
`);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-30
View File
@@ -1,30 +0,0 @@
const { Command } = require('discord.js-commando');
const { wait } = require('../../structures/Util');
const frames = [
'(-°□°)- ┬─┬',
'(╯°□°)╯ ]',
'(╯°□°)╯ ︵ ┻━┻',
'(╯°□°)╯ [',
'(╯°□°)╯ ┬─┬'
];
module.exports = class TableflipCommand extends Command {
constructor(client) {
super(client, {
name: 'tableflip',
aliases: ['a-tableflip', 'animated-tableflip', 'tableflip-animated', 'tableflip-a'],
group: 'random',
memberName: 'tableflip',
description: 'Flips a table... With animation!'
});
}
async run(msg) {
const message = await msg.say('(\\\\°□°)\\\\ ┬─┬');
for (const frame of frames) {
await wait(300);
await message.edit(frame);
}
return message;
}
};
-30
View File
@@ -1,30 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { stripIndents } = require('common-tags');
const { WORDNIK_KEY } = process.env;
module.exports = class WordOfTheDayCommand extends Command {
constructor(client) {
super(client, {
name: 'word-of-the-day',
aliases: ['wordnik-word-of-the-day'],
group: 'random',
memberName: 'word-of-the-day',
description: 'Gets the word of the day.'
});
}
async run(msg) {
try {
const { body } = await snekfetch
.get('http://api.wordnik.com/v4/words.json/wordOfTheDay')
.query({ api_key: WORDNIK_KEY });
return msg.say(stripIndents`
**${body.word}**
(${body.definitions[0].partOfSpeech || 'N/A'}) ${body.definitions[0].text}
`);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-66
View File
@@ -1,66 +0,0 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class XKCDCommand extends Command {
constructor(client) {
super(client, {
name: 'xkcd',
aliases: ['kcd'],
group: 'random',
memberName: 'xkcd',
description: 'Gets an XKCD Comic, optionally opting for today\'s or a specific number.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'type',
prompt: 'Please enter either a specific comic number, today, or random.',
type: 'string',
default: 'random',
parse: type => type.toLowerCase()
}
]
});
}
async run(msg, { type }) {
try {
const current = await snekfetch
.get('https://xkcd.com/info.0.json');
if (type === 'today') {
const embed = new MessageEmbed()
.setTitle(`${current.body.num} - ${current.body.title}`)
.setColor(0x9797FF)
.setURL(`https://xkcd.com/${current.body.num}`)
.setImage(current.body.img)
.setFooter(current.body.alt);
return msg.embed(embed);
}
if (type === 'random') {
const random = Math.floor(Math.random() * current.body.num) + 1;
const { body } = await snekfetch
.get(`https://xkcd.com/${random}/info.0.json`);
const embed = new MessageEmbed()
.setTitle(`${body.num} - ${body.title}`)
.setColor(0x9797FF)
.setURL(`https://xkcd.com/${body.num}`)
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
}
const choice = parseInt(type, 10);
if (isNaN(choice) || current.body.num < choice || choice < 1) return msg.say('Could not find any results.');
const { body } = await snekfetch
.get(`https://xkcd.com/${choice}/info.0.json`);
const embed = new MessageEmbed()
.setTitle(`${body.num} - ${body.title}`)
.setColor(0x9797FF)
.setURL(`https://xkcd.com/${body.num}`)
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};