This commit is contained in:
Daniel Odendahl Jr
2017-06-01 08:44:02 +00:00
parent 7802bb49cb
commit 14f85f94bd
129 changed files with 1915 additions and 1720 deletions
+3 -1
View File
@@ -1,4 +1,6 @@
const { ShardingManager } = require('discord.js'); const { ShardingManager } = require('discord.js');
const { TOKEN } = process.env; const { TOKEN } = process.env;
const Manager = new ShardingManager('./XiaoBot.js', { token: TOKEN }); const Manager = new ShardingManager('./XiaoBot.js', {
token: TOKEN
});
Manager.spawn(2); Manager.spawn(2);
+36 -36
View File
@@ -1,13 +1,11 @@
const { TOKEN, OWNER, PREFIX, INVITE } = process.env; const { TOKEN, OWNER, PREFIX, INVITE } = process.env;
const path = require('path'); const path = require('path');
const { FriendlyError } = require('discord.js-commando'); const CommandoClient = require('./structures/Client');
const CommandoClient = require('./structures/CommandoClient');
const client = new CommandoClient({ const client = new CommandoClient({
commandPrefix: PREFIX, commandPrefix: PREFIX,
owner: OWNER, owner: OWNER,
disableEveryone: true,
invite: INVITE, invite: INVITE,
unknownCommandResponse: false disableEveryone: true
}); });
const { carbon, dBots } = require('./structures/Stats'); const { carbon, dBots } = require('./structures/Stats');
const SequelizeProvider = require('./providers/Sequelize'); const SequelizeProvider = require('./providers/Sequelize');
@@ -32,16 +30,19 @@ client.registry
['roleplay', 'Roleplay'] ['roleplay', 'Roleplay']
]) ])
.registerDefaultGroups() .registerDefaultGroups()
.registerDefaultCommands({ help: false, ping: false }) .registerDefaultCommands({
help: false,
ping: false
})
.registerCommandsIn(path.join(__dirname, 'commands')); .registerCommandsIn(path.join(__dirname, 'commands'));
client.on('ready', () => { client.on('ready', () => {
console.log(`[Ready] Shard ${client.shard.id} Logged in as ${client.user.tag} (${client.user.id})!`); console.log(`[READY] Shard ${client.shard.id} Logged in as ${client.user.tag} (${client.user.id})!`);
client.user.setGame(`${PREFIX}help | Shard ${client.shard.id}`); client.user.setGame(`${PREFIX}help | Shard ${client.shard.id}`);
}); });
client.on('disconnect', (event) => { client.on('disconnect', (event) => {
console.log(`[Disconnect] Shard ${client.shard.id} disconnected with Code ${event.code}.`); console.log(`[DISCONNECT] Shard ${client.shard.id} disconnected with Code ${event.code}.`);
process.exit(0); process.exit(0);
}); });
@@ -49,52 +50,52 @@ client.on('error', console.error);
client.on('warn', console.warn); client.on('warn', console.warn);
client.on('commandError', (command, err) => { client.on('commandError', (command, err) => console.error(command.name, err));
if (err instanceof FriendlyError) return;
console.error(command.name, err);
});
client.dispatcher.addInhibitor(msg => { client.dispatcher.addInhibitor(msg => {
if (msg.channel.type === 'dm') return false;
const role = msg.guild.settings.get('singleRole'); const role = msg.guild.settings.get('singleRole');
if (!role) return false; if (!msg.guild || !msg.guild.roles.has(role) || msg.member.hasPermission('ADMINISTRATOR')) {
if (!msg.guild.roles.has(role)) return false; return false;
if (client.isOwner(msg.author)) return false; }
if (msg.member.hasPermission('ADMINISTRATOR')) return false; if (!msg.member.roles.has(role)) {
if (!msg.member.roles.has(role))
return ['singleRole', msg.reply(`Only the ${msg.guild.roles.get(role).name} role may use commands.`)]; return ['singleRole', msg.reply(`Only the ${msg.guild.roles.get(role).name} role may use commands.`)];
} else {
return false;
}
}); });
client.on('message', (msg) => { client.on('message', (msg) => {
if (msg.guild && msg.guild.settings.get('inviteGuard') && /(discord(\.gg\/|app\.com\/invite\/|\.me\/))/gi.test(msg.content)) { if (!msg.guild || !msg.guild.settings.get('inviteGuard')) return;
if (msg.author.bot || if (/(discord(\.gg\/|app\.com\/invite\/|\.me\/))/gi.test(msg.content)) {
msg.member.hasPermission('ADMINISTRATOR') || if (msg.author.bot || msg.member.hasPermission('ADMINISTRATOR')) return;
msg.author.id === msg.guild.ownerID || if (msg.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) {
msg.member.roles.has(msg.guild.settings.get('staffRole')) || msg.delete();
!msg.channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; return msg.reply('Invites are prohibited from being posted here.');
if (msg.channel.permissionsFor(client.user).has('MANAGE_MESSAGES')) msg.delete(); }
return msg.reply('Invites are prohibited from being posted here.');
} }
}); });
client.on('messageReactionAdd', (reaction, user) => { client.on('messageReactionAdd', (reaction, user) => {
if (reaction.emoji.name !== '⭐') return; if (reaction.emoji.name !== '⭐') return;
const msg = reaction.message; const { message } = reaction;
const channel = msg.guild.channels.get(msg.guild.settings.get('starboard')); const channel = message.guild.channels.get(message.guild.settings.get('starboard'));
if (!channel) return; if (!channel) return;
if (user.id === msg.author.id) { if (user.id === message.author.id) {
if (msg.channel.permissionsFor(client.user).has('MANAGE_MESSAGES')) reaction.remove(user); if (message.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) {
return msg.reply('You cannot star your own messages, baka.'); reaction.remove(user);
return message.reply('You cannot star your own messages, baka.');
} else return;
} }
client.registry.resolveCommand('random:star').run(msg, { id: msg.id }, true); return client.registry.resolveCommand('random:star').run(message, { id: message.id }, true);
}); });
client.on('guildMemberAdd', (member) => { client.on('guildMemberAdd', (member) => {
const role = member.guild.roles.get(member.guild.settings.get('joinRole')); const role = member.guild.roles.get(member.guild.settings.get('joinRole'));
if (role && member.guild.me.hasPermission('MANAGE_ROLES')) member.addRole(role).catch(() => null); if (role && member.guild.me.hasPermission('MANAGE_ROLES')) {
member.addRole(role).catch(() => null);
}
const channel = member.guild.channels.get(member.guild.settings.get('memberLog')); const channel = member.guild.channels.get(member.guild.settings.get('memberLog'));
if (!channel) return; if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
if (!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
const msg = member.guild.settings.get('joinMsg', 'Welcome <user>!') const msg = member.guild.settings.get('joinMsg', 'Welcome <user>!')
.replace(/(<user>)/gi, member.user.username) .replace(/(<user>)/gi, member.user.username)
.replace(/(<server>)/gi, member.guild.name) .replace(/(<server>)/gi, member.guild.name)
@@ -104,8 +105,7 @@ client.on('guildMemberAdd', (member) => {
client.on('guildMemberRemove', (member) => { client.on('guildMemberRemove', (member) => {
const channel = member.guild.channels.get(member.guild.settings.get('memberLog')); const channel = member.guild.channels.get(member.guild.settings.get('memberLog'));
if (!channel) return; if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
if (!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
const msg = member.guild.settings.get('leaveMsg', 'Bye <user>...') const msg = member.guild.settings.get('leaveMsg', 'Bye <user>...')
.replace(/(<user>)/gi, member.user.username) .replace(/(<user>)/gi, member.user.username)
.replace(/(<server>)/gi, member.guild.name) .replace(/(<server>)/gi, member.guild.name)
-1
View File
@@ -4,7 +4,6 @@
"memberLog", "memberLog",
"joinMsg", "joinMsg",
"leaveMsg", "leaveMsg",
"staffRole",
"singleRole", "singleRole",
"joinRole", "joinRole",
"starboard" "starboard"
+21
View File
@@ -0,0 +1,21 @@
{
"operations": [
"+",
"-",
"*"
],
"difficulties": [
"easy",
"medium",
"hard",
"extreme",
"impossible"
],
"maxValues": {
"easy": 10,
"medium": 50,
"hard": 100,
"extreme": 1000,
"impossible": 10000
}
}
+2 -8
View File
@@ -3,20 +3,14 @@
"airhorn", "airhorn",
"cat", "cat",
"dun dun dun", "dun dun dun",
"mario death",
"pikachu", "pikachu",
"pokemon center", "space"
"space",
"zelda chest"
], ],
"paths": { "paths": {
"airhorn": "airhorn.mp3", "airhorn": "airhorn.mp3",
"cat": "cat.mp3", "cat": "cat.mp3",
"dun dun dun": "dun-dun-dun.mp3", "dun dun dun": "dun-dun-dun.mp3",
"mario death": "mario-death.mp3",
"pikachu": "pikachu.mp3", "pikachu": "pikachu.mp3",
"pokemon center": "pokemon-center.mp3", "space": "space.mp3"
"space": "space.mp3",
"zelda chest": "zelda-chest.mp3"
} }
} }
+48 -32
View File
@@ -1,32 +1,48 @@
[ {
"The quick brown fox jumps over the lazy dog.", "sentences": [
"Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.", "The quick brown fox jumps over the lazy dog.",
"How razorback-jumping frogs can level six piqued gymnasts!", "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.",
"Amazingly few discotheques provide jukeboxes.", "How razorback-jumping frogs can level six piqued gymnasts!",
"I am so blue I'm greener than purple.", "Amazingly few discotheques provide jukeboxes.",
"I stepped on a Corn Flake, now I'm a Cereal Killer.", "I am so blue I'm greener than purple.",
"On a scale from one to ten what is your favourite colour of the alphabet?", "I stepped on a Corn Flake, now I'm a Cereal Killer.",
"The sparkly lamp ate a pillow then punched Larry.", "On a scale from one to ten what is your favourite colour of the alphabet?",
"My world is where everybody is a pony and we all eat rainbows and poop butterflies.", "The sparkly lamp ate a pillow then punched Larry.",
"If your canoe is stuck in a tree with the headlights on, how many pancakes does it take to get to the moon?", "My world is where everybody is a pony and we all eat rainbows and poop butterflies.",
"There's a purple mushroom in my backyard, screaming Taco's!", "If your canoe is stuck in a tree with the headlights on, how many pancakes does it take to get to the moon?",
"When life gives you lemons, chuck them at people you hate.", "There's a purple mushroom in my backyard, screaming Taco's!",
"I think I will buy the red car, or I will lease the blue one.", "When life gives you lemons, chuck them at people you hate.",
"Italy is my favorite country; in fact, I plan to spend two weeks there next year.", "I think I will buy the red car, or I will lease the blue one.",
"She borrowed the book from him many years ago and hasn't yet returned it.", "Italy is my favorite country; in fact, I plan to spend two weeks there next year.",
"Lets all be unique together until we realise we are all the same.", "She borrowed the book from him many years ago and hasn't yet returned it.",
"If Purple People Eaters are real… where do they find purple people to eat?", "Lets all be unique together until we realise we are all the same.",
"The waves were crashing on the shore; it was a lovely sight.", "If Purple People Eaters are real… where do they find purple people to eat?",
"This is the last random sentence I will be writing and I am going to stop mid-sent.", "The waves were crashing on the shore; it was a lovely sight.",
"The memory we used to share is no longer coherent.", "This is the last random sentence I will be writing and I am going to stop mid-sent.",
"She did not cheat on the test, for it was not the right thing to do.", "The memory we used to share is no longer coherent.",
"She only paints with bold colors; she does not like pastels.", "She did not cheat on the test, for it was not the right thing to do.",
"Malls are great places to shop; I can find everything I need under one roof.", "She only paints with bold colors; she does not like pastels.",
"The body may perhaps compensates for the loss of a true metaphysics.", "Malls are great places to shop; I can find everything I need under one roof.",
"They got there early, and they got really good seats.", "The body may perhaps compensates for the loss of a true metaphysics.",
"Everyone was busy, so I went to the movie alone.", "They got there early, and they got really good seats.",
"Yeah, I think it's a good environment for learning English.", "Everyone was busy, so I went to the movie alone.",
"I would have gotten the promotion, but my attendance wasnt good enough.", "Yeah, I think it's a good environment for learning English.",
"There were white out conditions in the town; subsequently, the roads were impassable.", "I would have gotten the promotion, but my attendance wasnt good enough.",
"If you like tuna and tomato sauce- try combining the two. Its really not as bad as it sounds." "There were white out conditions in the town; subsequently, the roads were impassable.",
] "If you like tuna and tomato sauce- try combining the two. Its really not as bad as it sounds."
],
"difficulties": [
"easy",
"medium",
"hard",
"extreme",
"impossible"
]
"times": {
"easy": 25000,
"medium": 20000,
"hard": 15000,
"extreme": 10000,
"impossible": 5000
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"statuses": {
"online": "<:online:313956277808005120> Online",
"idle": "<:away:313956277220802560> Idle",
"dnd": "<:dnd:313956276893646850> Do Not Disturb",
"offline": "<:offline:313956277237710868> Offline"
},
"colors": {
"online": 0x00AE86,
"idle": 0xFFFF00,
"dnd": 0xFF0000,
"offline": 0x808080
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+19 -21
View File
@@ -22,34 +22,32 @@ module.exports = class YearsCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256); const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(856, 569);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 461, 127, 200, 200);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', '3000-years.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'az.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(856, 569);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 461, 127, 200, 200);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', '3000-years.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'az.png' }] });
} }
}; };
+20 -22
View File
@@ -22,35 +22,33 @@ module.exports = class BeautifulCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256); const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(500, 532);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 341, 35, 117, 135);
ctx.drawImage(avatar, 343, 301, 117, 135);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'beautiful.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'grunkle.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(500, 532);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 341, 35, 117, 135);
ctx.drawImage(avatar, 343, 301, 117, 135);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'beautiful.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'grunkle.png' }] });
} }
}; };
+23 -25
View File
@@ -22,38 +22,36 @@ module.exports = class BobRossCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256); const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(600, 775);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 600, 775);
ctx.rotate(3 * Math.PI / 180);
ctx.drawImage(avatar, 69, 102, 256, 256);
ctx.rotate(-3 * Math.PI / 180);
ctx.drawImage(base, 0, 0);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'bob-ross.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ross.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(600, 775);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 600, 775);
ctx.rotate(3 * Math.PI / 180);
ctx.drawImage(avatar, 69, 102, 256, 256);
ctx.rotate(-3 * Math.PI / 180);
ctx.drawImage(base, 0, 0);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'bob-ross.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ross.png' }] });
} }
}; };
+43 -41
View File
@@ -25,55 +25,57 @@ module.exports = class CardCommand extends Command {
{ {
key: 'member', key: 'member',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'member' type: 'member',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { member } = args; const member = args.member || msg.member;
const avatarURL = member.user.avatarURL('png', 512); const avatarURL = member.user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
const cardID = Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000; const cardID = Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000;
let rarity; let rarity;
if (cardID < 5000) rarity = 'C'; if (cardID < 5000) {
else if (cardID < 8000) rarity = 'U'; rarity = 'C';
else rarity = 'R'; } else if (cardID < 8000) {
try { rarity = 'U';
const Image = Canvas.Image; } else {
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' }); rarity = 'R';
const canvas = new Canvas(390, 544);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 390, 544);
ctx.drawImage(avatar, 11, 11, 370, 370);
ctx.drawImage(base, 0, 0);
ctx.font = '18px Open Sans';
ctx.fillStyle = 'black';
ctx.fillText(member.displayName, 30, 62);
ctx.fillText('Discord Join Date:', 148, 400);
ctx.fillText(moment(member.user.createdTimestamp).format('MMMM Do YYYY'), 148, 420);
ctx.fillText('Role:', 148, 457);
ctx.fillText(member.highestRole.name, 148, 477);
ctx.fillText(rarity, 73, 411);
ctx.fillText(cardID, 60, 457);
ctx.fillText(version.split('.')[0], 68, 502);
ctx.font = '14px Open Sans';
ctx.fillText(member.id, 30, 355);
ctx.fillText(`#${member.user.discriminator}`, 313, 355);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'card.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'card.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' });
const canvas = new Canvas(390, 544);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 390, 544);
ctx.drawImage(avatar, 11, 11, 370, 370);
ctx.drawImage(base, 0, 0);
ctx.font = '18px Open Sans';
ctx.fillStyle = 'black';
ctx.fillText(member.displayName, 30, 62);
ctx.fillText('Discord Join Date:', 148, 400);
ctx.fillText(moment(member.user.createdTimestamp).format('MMMM Do YYYY'), 148, 420);
ctx.fillText('Role:', 148, 457);
ctx.fillText(member.highestRole.name, 148, 477);
ctx.fillText(rarity, 73, 411);
ctx.fillText(cardID, 60, 457);
ctx.fillText(version.split('.')[0], 68, 502);
ctx.font = '14px Open Sans';
ctx.fillText(member.id, 30, 355);
ctx.fillText(`#${member.user.discriminator}`, 313, 355);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'card.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'card.png' }] });
} }
}; };
+21 -23
View File
@@ -21,36 +21,34 @@ module.exports = class ChallengerCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256); const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(500, 500);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = '#ff0028';
ctx.fillRect(0, 0, 500, 500);
ctx.drawImage(avatar, 226, 155, 200, 200);
ctx.drawImage(base, 0, 0);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'challenger.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(500, 500);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = '#ff0028';
ctx.fillRect(0, 0, 500, 500);
ctx.drawImage(avatar, 226, 155, 200, 200);
ctx.drawImage(base, 0, 0);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'challenger.png' }] });
} }
}; };
+21 -23
View File
@@ -21,36 +21,34 @@ module.exports = class DexterCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256); const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(744, 554);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.rotate(-11 * Math.PI / 180);
ctx.drawImage(avatar, 234, 274, 225, 225);
ctx.rotate(11 * Math.PI / 180);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'dexter.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'dexter.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(744, 554);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.rotate(-11 * Math.PI / 180);
ctx.drawImage(avatar, 234, 274, 225, 225);
ctx.rotate(11 * Math.PI / 180);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'dexter.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'dexter.png' }] });
} }
}; };
+25 -27
View File
@@ -19,40 +19,38 @@ module.exports = class GreyscaleCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256); const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(256, 256);
const ctx = canvas.getContext('2d');
const avatar = new Image();
const generate = () => {
ctx.drawImage(avatar, 0, 0, 256, 256);
const imgData = ctx.getImageData(0, 0, 256, 256);
const { data } = imgData;
for (let i = 0; i < data.length; i += 4) {
const brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2];
data[i] = brightness;
data[i + 1] = brightness;
data[i + 2] = brightness;
}
ctx.putImageData(imgData, 0, 0);
};
const avatarImg = await snekfetch.get(avatarURL);
avatar.src = avatarImg.body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'greyscale.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(256, 256);
const ctx = canvas.getContext('2d');
const avatar = new Image();
const generate = () => {
ctx.drawImage(avatar, 0, 0, 256, 256);
const imgData = ctx.getImageData(0, 0, 256, 256);
const { data } = imgData;
for (let i = 0; i < data.length; i += 4) {
const brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2];
data[i] = brightness;
data[i + 1] = brightness;
data[i + 2] = brightness;
}
ctx.putImageData(imgData, 0, 0);
};
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'greyscale.png' }] });
} }
}; };
+24 -26
View File
@@ -18,39 +18,37 @@ module.exports = class InvertCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256); const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(256, 256);
const ctx = canvas.getContext('2d');
const avatar = new Image();
const generate = () => {
ctx.drawImage(avatar, 0, 0, 256, 256);
const imgData = ctx.getImageData(0, 0, 256, 256);
const { data } = imgData;
for (let i = 0; i < data.length; i += 4) {
data[i] = 255 - data[i];
data[i + 1] = 255 - data[i + 1];
data[i + 2] = 255 - data[i + 2];
}
ctx.putImageData(imgData, 0, 0);
};
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'invert.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(256, 256);
const ctx = canvas.getContext('2d');
const avatar = new Image();
const generate = () => {
ctx.drawImage(avatar, 0, 0, 256, 256);
const imgData = ctx.getImageData(0, 0, 256, 256);
const { data } = imgData;
for (let i = 0; i < data.length; i += 4) {
data[i] = 255 - data[i];
data[i + 1] = 255 - data[i + 1];
data[i + 2] = 255 - data[i + 2];
}
ctx.putImageData(imgData, 0, 0);
};
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'invert.png' }] });
} }
}; };
+28 -30
View File
@@ -22,43 +22,41 @@ module.exports = class RIPCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256); const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This User has no Avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(507, 338);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 158, 51, 200, 200);
const imgData = ctx.getImageData(158, 51, 200, 200);
const { data } = imgData;
for (let i = 0; i < data.length; i += 4) {
const brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2];
data[i] = brightness;
data[i + 1] = brightness;
data[i + 2] = brightness;
}
ctx.putImageData(imgData, 158, 51);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'rip.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'rip.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(507, 338);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 158, 51, 200, 200);
const imgData = ctx.getImageData(158, 51, 200, 200);
const { data } = imgData;
for (let i = 0; i < data.length; i += 4) {
const brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2];
data[i] = brightness;
data[i + 1] = brightness;
data[i + 2] = brightness;
}
ctx.putImageData(imgData, 158, 51);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'rip.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'rip.png' }] });
} }
}; };
+21 -23
View File
@@ -21,36 +21,34 @@ module.exports = class SimbaCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256); const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(500, 281);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.rotate(-24 * Math.PI / 180);
ctx.drawImage(avatar, 75, 160, 130, 150);
ctx.rotate(24 * Math.PI / 180);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'simba.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'simba.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(500, 281);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.rotate(-24 * Math.PI / 180);
ctx.drawImage(avatar, 75, 160, 130, 150);
ctx.rotate(24 * Math.PI / 180);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'simba.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'simba.png' }] });
} }
}; };
+24 -26
View File
@@ -21,39 +21,37 @@ module.exports = class SteamCardCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 512); const avatarURL = user.avatarURL('png', 512);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' });
const canvas = new Canvas(494, 568);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 494, 568);
ctx.drawImage(avatar, 25, 25, 450, 450);
ctx.drawImage(base, 0, 0);
ctx.font = '30px Open Sans';
ctx.fillText(user.username, 35, 48);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'steam-card.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'steam.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' });
const canvas = new Canvas(494, 568);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 494, 568);
ctx.drawImage(avatar, 25, 25, 450, 450);
ctx.drawImage(base, 0, 0);
ctx.font = '30px Open Sans';
ctx.fillText(user.username, 35, 48);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'steam-card.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'steam.png' }] });
} }
}; };
+27 -29
View File
@@ -21,42 +21,40 @@ module.exports = class TriggeredCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 512); const avatarURL = user.avatarURL('png', 512);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(320, 371);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 320, 371);
ctx.drawImage(avatar, 0, 0, 320, 320);
const imgData = ctx.getImageData(0, 0, 320, 320);
const { data } = imgData;
for (let i = 0; i < data.length; i += 4) {
data[i] = Math.max(255, data[i]);
}
ctx.putImageData(imgData, 0, 0);
ctx.drawImage(base, 0, 0);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'triggered.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'triggered.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(320, 371);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 320, 371);
ctx.drawImage(avatar, 0, 0, 320, 320);
const imgData = ctx.getImageData(0, 0, 320, 320);
const { data } = imgData;
for (let i = 0; i < data.length; i += 4) {
data[i] = Math.max(255, data[i]);
}
ctx.putImageData(imgData, 0, 0);
ctx.drawImage(base, 0, 0);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'triggered.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'triggered.png' }] });
} }
}; };
+19 -21
View File
@@ -21,34 +21,32 @@ module.exports = class WantedCommand extends Command {
{ {
key: 'user', key: 'user',
prompt: 'Which user would you like to edit the avatar of?', prompt: 'Which user would you like to edit the avatar of?',
type: 'user' type: 'user',
default: ''
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { user } = args; const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 512); const avatarURL = user.avatarURL('png', 512);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) {
try { return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(741, 1000);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 150, 360, 430, 430);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'wanted.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'wanted.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const Image = Canvas.Image;
const canvas = new Canvas(741, 1000);
const ctx = canvas.getContext('2d');
const base = new Image();
const avatar = new Image();
const generate = () => {
ctx.drawImage(base, 0, 0);
ctx.drawImage(avatar, 150, 360, 430, 430);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'wanted.png'));
const { body } = await snekfetch.get(avatarURL);
avatar.src = body;
generate();
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'wanted.png' }] });
} }
}; };
+47 -20
View File
@@ -24,13 +24,19 @@ module.exports = class BattleCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { opponent } = args; const { opponent } = args;
if (opponent.bot) return msg.say('You cannot fight bots!'); if (opponent.bot) {
if (opponent.id === msg.author.id) return msg.say('You cannot fight yourself!'); return msg.say('Bots cannot be fought.');
if (this.fighting.has(msg.guild.id)) return msg.say('There is already a fight in this server...'); }
if (opponent.id === msg.author.id) {
return msg.say('You may not fight yourself.');
}
if (this.fighting.has(msg.guild.id)) {
return msg.say('Only one fight may be occurring per server.');
}
this.fighting.add(msg.guild.id); this.fighting.add(msg.guild.id);
await msg.say(`**${opponent.username}**, do you accept this challenge? **__Y__es** or **No**?`); await msg.say(`**${opponent.username}**, do you accept this challenge? **__Y__es** or **No**?`);
try { try {
const verify = await msg.channel.awaitMessages(res => res.author.id === opponent.id, { const verify = await msg.channel.awaitMessages((res) => res.author.id === opponent.id, {
max: 1, max: 1,
time: 15000, time: 15000,
errors: ['time'] errors: ['time']
@@ -50,14 +56,14 @@ module.exports = class BattleCommand extends Command {
**${opponent.username}**: ${oppoHP}HP **${opponent.username}**: ${oppoHP}HP
`); `);
try { try {
const turn = await msg.channel.awaitMessages(res => res.author.id === (userTurn ? msg.author.id : opponent.id), { const turn = await msg.channel.awaitMessages((res) => res.author.id === (userTurn ? msg.author.id : opponent.id), {
max: 1, max: 1,
time: 15000, time: 15000,
errors: ['time'] errors: ['time']
}); });
const choice = turn.first().content.toLowerCase(); const choice = turn.first().content.toLowerCase();
if (choice === 'fight') { if (choice === 'fight') {
const damage = Math.floor(Math.random() * (guard ? 25 : 100)) + 1; const damage = Math.floor(Math.random() * (guard ? 10 : 100)) + 1;
await msg.say(`**${username}** deals **${damage}** damage!`); await msg.say(`**${username}** deals **${damage}** damage!`);
if (userTurn) { if (userTurn) {
oppoHP = oppoHP - damage; oppoHP = oppoHP - damage;
@@ -66,12 +72,17 @@ module.exports = class BattleCommand extends Command {
userHP = userHP - damage; userHP = userHP - damage;
userTurn = true; userTurn = true;
} }
if (guard) guard = false; if (guard) {
guard = false;
}
} else if (choice === 'guard') { } else if (choice === 'guard') {
await msg.say(`**${username}** guards!`); await msg.say(`**${username}** guards!`);
guard = true; guard = true;
if (userTurn) userTurn = false; if (userTurn) {
else userTurn = true; userTurn = false;
} else {
userTurn = true;
}
} else if (choice === 'special') { } else if (choice === 'special') {
const hit = Math.floor(Math.random() * 4) + 1; const hit = Math.floor(Math.random() * 4) + 1;
if (hit === 1) { if (hit === 1) {
@@ -84,12 +95,19 @@ module.exports = class BattleCommand extends Command {
userHP = userHP - damage; userHP = userHP - damage;
userTurn = true; userTurn = true;
} }
if (guard) guard = false; if (guard) {
guard = false;
}
} else { } else {
await msg.say(`**${username}**'s attack missed!`); await msg.say(`**${username}**'s attack missed!`);
if (guard) guard = false; if (userTurn) {
if (userTurn) userTurn = false; userTurn = false;
else userTurn = true; } else {
userTurn = true;
}
if (guard) {
guard = false;
}
} }
} else if (choice === 'cure') { } else if (choice === 'cure') {
if (userTurn ? userCure : oppoCure) { if (userTurn ? userCure : oppoCure) {
@@ -103,13 +121,22 @@ module.exports = class BattleCommand extends Command {
oppoCure = false; oppoCure = false;
userTurn = true; userTurn = true;
} }
if (guard) guard = false; if (guard) {
} else await msg.say('You have already cured!'); guard = false;
}
} else {
await msg.say('You have already cured!');
}
} else if (choice === 'run') { } else if (choice === 'run') {
await msg.say(`**${username}** flees!`); await msg.say(`**${username}** flees!`);
if (userTurn) userHP = 0; if (userTurn) {
else oppoHP = 0; userHP = 0;
} else await msg.say('I do not understand what you want to do.'); } else {
oppoHP = 0;
}
} else {
await msg.say('I do not understand what you want to do.');
}
} catch (err) { } catch (err) {
await msg.say('Time!'); await msg.say('Time!');
break; break;
@@ -118,8 +145,8 @@ module.exports = class BattleCommand extends Command {
this.fighting.delete(msg.guild.id); this.fighting.delete(msg.guild.id);
return msg.say(stripIndents` return msg.say(stripIndents`
The match is over! The match is over!
**Winner: ${(userHP > oppoHP) ? `${msg.author.username}** (${userHP}HP)` : `${opponent.username}** (${oppoHP}HP)`} **Winner: ${userHP > oppoHP ? `${msg.author.username}** (${userHP}HP)` : `${opponent.username}** (${oppoHP}HP)`}
**Loser: ${(userHP > oppoHP) ? `${opponent.username}** (${oppoHP}HP)` : `${msg.author.username}** (${userHP}HP)`} **Loser: ${userHP > oppoHP ? `${opponent.username}** (${oppoHP}HP)` : `${msg.author.username}** (${userHP}HP)`}
`); `);
} else { } else {
this.fighting.delete(msg.guild.id); this.fighting.delete(msg.guild.id);
+5 -2
View File
@@ -12,7 +12,10 @@ module.exports = class LotteryCommand extends Command {
run(msg) { run(msg) {
const lottery = Math.floor(Math.random() * 100) + 1; const lottery = Math.floor(Math.random() * 100) + 1;
if (lottery < 99) return msg.say(`Nope, sorry ${msg.author.username}, you lost.`); if (lottery === 1) {
return msg.say(`Wow ${msg.author.username}! You actually won! Great job!`); return msg.say(`Wow ${msg.author.username}! You actually won! Great job!`);
} else {
return msg.say(`Nope, sorry ${msg.author.username}, you lost.`);
}
} }
}; };
+17 -28
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js'); const { RichEmbed } = require('discord.js');
const math = require('mathjs'); const math = require('mathjs');
const operations = ['+', '-', '*']; const { operations, difficulties, maxValues } = require('../../assets/json/math-game');
module.exports = class MathGameCommand extends Command { module.exports = class MathGameCommand extends Command {
constructor(client) { constructor(client) {
@@ -14,13 +14,16 @@ module.exports = class MathGameCommand extends Command {
args: [ args: [
{ {
key: 'difficulty', key: 'difficulty',
prompt: 'What should the difficulty of the game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', prompt: `What should the difficulty of the game be? One of: ${difficulties.join(', ')}`,
type: 'string', type: 'string',
validate: difficulty => { validate: (difficulty) => {
if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) return true; if (difficulties.includes(difficulty.toLowerCase())) {
return 'The difficulty must be either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; return true;
} else {
return `The difficulty must be one of: ${difficulties.join(', ')}`;
}
}, },
parse: difficulty => difficulty.toLowerCase() parse: (difficulty) => difficulty.toLowerCase()
} }
] ]
}); });
@@ -29,38 +32,24 @@ module.exports = class MathGameCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { difficulty } = args; const { difficulty } = args;
const operation = operations[Math.floor(Math.random() * operations.length)]; const operation = operations[Math.floor(Math.random() * operations.length)];
let value; const value = maxValues[difficulty];
switch(difficulty) {
case 'easy':
value = 10;
break;
case 'medium':
value = 50;
break;
case 'hard':
value = 100;
break;
case 'extreme':
value = 1000;
break;
case 'impossible':
value = 10000;
break;
}
const expression = `${Math.floor(Math.random() * value) + 1} ${operation} ${Math.floor(Math.random() * value) + 1}`; const expression = `${Math.floor(Math.random() * value) + 1} ${operation} ${Math.floor(Math.random() * value) + 1}`;
const answer = math.eval(expression).toString(); const answer = math.eval(expression).toString();
const embed = new RichEmbed() const embed = new RichEmbed()
.setTitle('You have **10** seconds to answer:') .setTitle('You have 10 seconds to answer:')
.setDescription(expression); .setDescription(expression);
await msg.embed(embed); await msg.embed(embed);
try { try {
const collected = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, { const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1, max: 1,
time: 10000, time: 10000,
errors: ['time'] errors: ['time']
}); });
if (collected.first().content !== answer) return msg.say(`Nope, sorry, it's ${answer}.`); if (collected.first().content !== answer) {
return msg.say('Nice job! 10/10! You deserve some cake!'); return msg.say(`Nope, sorry, it's ${answer}.`);
} else {
return msg.say('Nice job! 10/10! You deserve some cake!');
}
} catch (err) { } catch (err) {
return msg.say(`Time! It was ${answer}, sorry!`); return msg.say(`Time! It was ${answer}, sorry!`);
} }
+24 -25
View File
@@ -16,35 +16,34 @@ module.exports = class QuizCommand extends Command {
} }
async run(msg) { async run(msg) {
const { body } = await snekfetch
.get('https://opentdb.com/api.php')
.query({
amount: 1,
type: 'boolean',
encode: 'url3986'
});
const answer = body.results[0].correct_answer.toLowerCase();
const embed = new RichEmbed()
.setTitle('You have 15 seconds to answer this question:')
.setDescription(stripIndents`
**${decodeURIComponent(body.results[0].category)}**
True or False: ${decodeURIComponent(body.results[0].question)}
`);
await msg.embed(embed);
try { try {
const { body } = await snekfetch const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
.get('https://opentdb.com/api.php') max: 1,
.query({ time: 15000,
amount: 1, errors: ['time']
type: 'boolean', });
encode: 'url3986' if (collected.first().content.toLowerCase() !== answer) {
}); return msg.say(`Nope, sorry, it's ${answer}.`);
const answer = body.results[0].correct_answer.toLowerCase(); } else {
const embed = new RichEmbed()
.setTitle('You have **15** seconds to answer this question:')
.setDescription(stripIndents`
**${decodeURIComponent(body.results[0].category)}**
True or False: ${decodeURIComponent(body.results[0].question)}
`);
await msg.embed(embed);
try {
const collected = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (collected.first().content.toLowerCase() !== answer) return msg.say(`Nope, sorry, it's ${answer}.`);
return msg.say('Nice job! 10/10! You deserve some cake!'); return msg.say('Nice job! 10/10! You deserve some cake!');
} catch (err) {
return msg.say(`Time! It was ${answer}, sorry!`);
} }
} catch (err) { } catch (err) {
return msg.say(`${err.name}: ${err.message}`); return msg.say(`Time! It was ${answer}, sorry!`);
} }
} }
}; };
+30 -15
View File
@@ -1,5 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const responses = ['Paper', 'Rock', 'Scissors']; const choices = ['paper', 'rock', 'scissors'];
module.exports = class RockPaperScissorsCommand extends Command { module.exports = class RockPaperScissorsCommand extends Command {
constructor(client) { constructor(client) {
@@ -14,11 +14,14 @@ module.exports = class RockPaperScissorsCommand extends Command {
key: 'choice', key: 'choice',
prompt: '`Rock`, `Paper`, or `Scissors`?', prompt: '`Rock`, `Paper`, or `Scissors`?',
type: 'string', type: 'string',
validate: choice => { validate: (choice) => {
if (['rock', 'paper', 'scissors'].includes(choice.toLowerCase())) return true; if (choices.includes(choice.toLowerCase())) {
return 'Please enter either `rock`, `paper`, or `scissors`.'; return true;
} else {
return 'Please enter either `rock`, `paper`, or `scissors`.';
}
}, },
parse: choice => choice.toLowerCase() parse: (choice) => choice.toLowerCase()
} }
] ]
}); });
@@ -26,19 +29,31 @@ module.exports = class RockPaperScissorsCommand extends Command {
run(msg, args) { run(msg, args) {
const { choice } = args; const { choice } = args;
const response = responses[Math.floor(Math.random() * responses.length)]; const response = choices[Math.floor(Math.random() * choices.length)];
if (choice === 'rock') { if (choice === 'rock') {
if (response === 'Rock') return msg.say('Rock! Aw, it\'s a tie!'); if (response === 'rock') {
if (response === 'Paper') return msg.say('Paper! Yes! I win!'); return msg.say('Rock! Aw... A tie...');
if (response === 'Scissors') return msg.say('Scissors! Aw... I lose...'); } else if (response === 'paper') {
return msg.say('Paper! Yes! I win!');
} else if (response === 'scissors') {
return msg.say('Scissors! Aw... I lose...');
}
} else if (choice === 'paper') { } else if (choice === 'paper') {
if (response === 'Rock') return msg.say('Rock! Aw... I lose...'); if (response === 'rock') {
if (response === 'Paper') return msg.say('Paper! Aw, it\'s a tie!'); return msg.say('Rock! Aw... I lose...');
if (response === 'Scissors') return msg.say('Scissors! Yes! I win!'); } else if (response === 'paper') {
return msg.say('Paper! Aw... A tie...');
} else if (response === 'scissors') {
return msg.say('Scissors! Yes! I win!');
}
} else if (choice === 'scissors') { } else if (choice === 'scissors') {
if (response === 'Rock') return msg.say('Rock! Yes! I win!'); if (response === 'rock') {
if (response === 'Paper') return msg.say('Paper! Aw... I lose...'); return msg.say('Rock! Yes! I win!');
if (response === 'Scissors') return msg.say('Scissors! Aw, it\'s a tie!'); } else if (response === 'paper') {
return msg.say('Paper! Aw... I lose...');
} else if (response === 'scissors') {
return msg.say('Scissors! Aw... A tie...');
}
} }
} }
}; };
+11 -9
View File
@@ -1,6 +1,6 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags'); const { stripIndents } = require('common-tags');
const slotThing = [':grapes:', ':tangerine:', ':pear:', ':cherries:']; const slots = [':grapes:', ':tangerine:', ':pear:', ':cherries:'];
module.exports = class SlotsCommand extends Command { module.exports = class SlotsCommand extends Command {
constructor(client) { constructor(client) {
@@ -13,17 +13,19 @@ module.exports = class SlotsCommand extends Command {
} }
run(msg) { run(msg) {
const slotOne = slotThing[Math.floor(Math.random() * slotThing.length)]; const slotOne = slots[Math.floor(Math.random() * slots.length)];
const slotTwo = slotThing[Math.floor(Math.random() * slotThing.length)]; const slotTwo = slots[Math.floor(Math.random() * slots.length)];
const slotThree = slotThing[Math.floor(Math.random() * slotThing.length)]; const slotThree = slots[Math.floor(Math.random() * slots.length)];
if (slotOne === slotTwo && slotOne === slotThree) if (slotOne === slotTwo && slotOne === slotThree) {
return msg.say(stripIndents` return msg.say(stripIndents`
${slotOne}|${slotTwo}|${slotThree} ${slotOne}|${slotTwo}|${slotThree}
Wow! You won! Great job... er... luck! Wow! You won! Great job... er... luck!
`); `);
return msg.say(stripIndents` } else {
${slotOne}|${slotTwo}|${slotThree} return msg.say(stripIndents`
Aww... You lost... Guess it's just bad luck, huh? ${slotOne}|${slotTwo}|${slotThree}
`); Aww... You lost... Guess it's just bad luck, huh?
`);
}
} }
}; };
+17 -28
View File
@@ -1,6 +1,6 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js'); const { RichEmbed } = require('discord.js');
const sentences = require('../../assets/json/typing-game'); const { sentences, difficulties, times } = require('../../assets/json/typing-game');
module.exports = class TypingGameCommand extends Command { module.exports = class TypingGameCommand extends Command {
constructor(client) { constructor(client) {
@@ -13,13 +13,16 @@ module.exports = class TypingGameCommand extends Command {
args: [ args: [
{ {
key: 'difficulty', key: 'difficulty',
prompt: 'What should the difficulty of the game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', prompt: `What should the difficulty of the game be? One of: ${difficulties.join(', ')}`,
type: 'string', type: 'string',
validate: difficulty => { validate: (difficulty) => {
if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) return true; if (difficulties.includes(difficulty.toLowerCase())) {
return 'The difficulty must be either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; return true;
} else {
return `The difficulty must be one of: ${difficulties.join(', ')}`;
}
}, },
parse: difficulty => difficulty.toLowerCase() parse: (difficulty) => difficulty.toLowerCase()
} }
] ]
}); });
@@ -28,36 +31,22 @@ module.exports = class TypingGameCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { difficulty } = args; const { difficulty } = args;
const sentence = sentences[Math.floor(Math.random() * sentences.length)]; const sentence = sentences[Math.floor(Math.random() * sentences.length)];
let time; const time = times[difficulty];
switch(difficulty) {
case 'easy':
time = 25000;
break;
case 'medium':
time = 20000;
break;
case 'hard':
time = 15000;
break;
case 'extreme':
time = 10000;
break;
case 'impossible':
time = 5000;
break;
}
const embed = new RichEmbed() const embed = new RichEmbed()
.setTitle(`You have **${time / 1000}** seconds to type:`) .setTitle(`You have ${time / 1000} seconds to type:`)
.setDescription(sentence); .setDescription(sentence);
await msg.embed(embed); await msg.embed(embed);
try { try {
const collected = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, { const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1, max: 1,
time: time, time: time,
errors: ['time'] errors: ['time']
}); });
if (collected.first().content !== sentence) return msg.say('Nope, sorry!'); if (collected.first().content !== sentence) {
return msg.say(`Good Job! You won!`); return msg.say('Nope, sorry!');
} else {
return msg.say('Nice job! 10/10! You deserve some cake!');
}
} catch (err) { } catch (err) {
return msg.say('Time! Sorry!'); return msg.say('Time! Sorry!');
} }
+5 -2
View File
@@ -12,7 +12,10 @@ module.exports = class EmojiCommand extends Command {
} }
run(msg) { run(msg) {
return msg.say(msg.guild.emojis.map(e => e).join('')) const emoji = msg.guild.emojis;
.catch(() => msg.say('There was an error sending the emoji.')); if (!emoji.size) {
return msg.say('You have no Custom Emoji.');
}
return msg.say(emoji.map((e) => e).join(''));
} }
}; };
+11 -13
View File
@@ -1,8 +1,7 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js'); const { RichEmbed } = require('discord.js');
const { stripIndents } = require('common-tags');
const moment = require('moment'); const moment = require('moment');
require('moment-duration-format'); const filterLevels = ['Off', 'No Role', 'Everyone'];
module.exports = class GuildInfoCommand extends Command { module.exports = class GuildInfoCommand extends Command {
constructor(client) { constructor(client) {
@@ -21,22 +20,21 @@ module.exports = class GuildInfoCommand extends Command {
const embed = new RichEmbed() const embed = new RichEmbed()
.setColor(0x00AE86) .setColor(0x00AE86)
.setThumbnail(msg.guild.iconURL()) .setThumbnail(msg.guild.iconURL())
.addField('Name', .addField(' Name',
msg.guild.name, true) msg.guild.name, true)
.addField('ID', .addField(' ID',
msg.guild.id, true) msg.guild.id, true)
.addField('Creation Date', .addField(' Creation Date',
stripIndents` moment(msg.guild.createdAt).format('MMMM Do YYYY'), true)
${moment(msg.guild.createdTimestamp).format('MMMM Do YYYY h:mm:ss A')} .addField(' Default Channel',
${moment.duration(Date.now() - msg.guild.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.
`)
.addField('Default Channel',
msg.guild.defaultChannel, true) msg.guild.defaultChannel, true)
.addField('Region', .addField(' Region',
msg.guild.region, true) msg.guild.region, true)
.addField('Owner', .addField(' Explicit Filter',
filterLevels[msg.guild.explicitContentFilter], true)
.addField(' Owner',
msg.guild.owner, true) msg.guild.owner, true)
.addField('Members', .addField(' Members',
msg.guild.memberCount, true); msg.guild.memberCount, true);
return msg.embed(embed); return msg.embed(embed);
} }
+53 -31
View File
@@ -13,7 +13,6 @@ module.exports = class BanCommand extends Command {
guildOnly: true, guildOnly: true,
clientPermissions: ['BAN_MEMBERS'], clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['BAN_MEMBERS'], userPermissions: ['BAN_MEMBERS'],
allowStaff: true,
args: [ args: [
{ {
key: 'member', key: 'member',
@@ -24,9 +23,12 @@ module.exports = class BanCommand extends Command {
key: 'reason', key: 'reason',
prompt: 'What do you want to set the reason as?', prompt: 'What do you want to set the reason as?',
type: 'string', type: 'string',
validate: reason => { validate: (reason) => {
if (reason.length < 140) return true; if (reason.length < 140) {
return 'Invalid Reason. Reason must be under 140 characters.'; return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
} }
} }
] ]
@@ -35,37 +37,57 @@ module.exports = class BanCommand extends Command {
async run(msg, args) { async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { member, reason } = args; const { member, reason } = args;
if (!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?'); if (!member.bannable) {
return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
}
try { try {
try { await msg.say(`Are you sure you want to ban ${member.user.tag} (${member.id})?`);
await member.user.send(stripIndents` const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
You were banned from ${msg.guild.name}! max: 1,
Reason: ${reason}. time: 15000,
`); errors: ['time']
} catch (err) { });
await msg.say('Failed to Send DM.'); if (['y', 'yes'].includes(collected.first().content.toLowerCase())) {
try {
await member.user.send(stripIndents`
You were banned from ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason}`
});
await msg.say(`Successfully banned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user.has('SEND_MESSAGES'))) {
return msg.say('Could not log the ban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF0000)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Ban.');
} }
await member.ban({ days: 7, reason });
msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF0000)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}
`);
modlogs.send({ embed });
return null;
} catch (err) { } catch (err) {
return msg.say(`${err.name}: ${err.message}`); return msg.say('Aborting Ban.');
} }
} }
}; };
+52 -30
View File
@@ -6,13 +6,13 @@ module.exports = class KickCommand extends Command {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'kick', name: 'kick',
aliases: ['kickke'],
group: 'moderation', group: 'moderation',
memberName: 'kick', memberName: 'kick',
description: 'Kicks a user and logs the kick to the mod logs.', description: 'Kicks a user and logs the kick to the mod logs.',
guildOnly: true, guildOnly: true,
clientPermissions: ['KICK_MEMBERS'], clientPermissions: ['KICK_MEMBERS'],
userPermissions: ['KICK_MEMBERS'], userPermissions: ['KICK_MEMBERS'],
allowStaff: true,
args: [ args: [
{ {
key: 'member', key: 'member',
@@ -24,8 +24,11 @@ module.exports = class KickCommand extends Command {
prompt: 'What do you want to set the reason as?', prompt: 'What do you want to set the reason as?',
type: 'string', type: 'string',
validate: reason => { validate: reason => {
if (reason.length < 140) return true; if (reason.length < 140) {
return 'Invalid Reason. Reason must be under 140 characters.'; return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
} }
} }
] ]
@@ -34,37 +37,56 @@ module.exports = class KickCommand extends Command {
async run(msg, args) { async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { member, reason } = args; const { member, reason } = args;
if (!member.kickable) return msg.say('This member is not kickable. Perhaps they have a higher role than me?'); if (!member.kickable) {
return msg.say('This member is not kickable. Perhaps they have a higher role than me?');
}
try { try {
try { await msg.say(`Are you sure you want to kick ${member.user.tag} (${member.id})?`);
await member.user.send(stripIndents` const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
You were kicked from ${msg.guild.name}! max: 1,
Reason: ${reason}. time: 15000,
`); errors: ['time']
} catch (err) { });
await msg.say('Failed to Send DM.'); if (['y', 'yes'].includes(collected.first().content.toLowerCase())) {
try {
await member.user.send(stripIndents`
You were kicked from ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await member.kick({
reason: `${msg.author.tag}: ${reason}`
});
await msg.say(`Successfully kicked ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user.has('SEND_MESSAGES'))) {
return msg.say('Could not log the kick to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFA500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Kick.');
} }
await member.kick({ reason });
msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFA500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}
`);
modlogs.send({ embed });
return null;
} catch (err) { } catch (err) {
return msg.say(`${err.name}: ${err.message}`); return msg.say('Aborting Kick.');
} }
} }
}; };
+16 -25
View File
@@ -7,22 +7,24 @@ module.exports = class LockdownCommand extends Command {
name: 'lockdown', name: 'lockdown',
group: 'moderation', group: 'moderation',
memberName: 'lockdown', memberName: 'lockdown',
description: 'Locks down the current channel or removes a lockdown, which prevents non-administrator members from speaking.', description: 'Locks down the current channel or removes a lockdown.',
guildOnly: true, guildOnly: true,
clientPermissions: ['ADMINISTRATOR'], clientPermissions: ['ADMINISTRATOR'],
userPermissions: ['ADMINISTRATOR'], userPermissions: ['ADMINISTRATOR'],
allowStaff: true,
args: [ args: [
{ {
key: 'type', key: 'type',
prompt: 'Please enter either `start` or `stop`.', prompt: 'Please enter either `start` or `stop`.',
type: 'string', type: 'string',
validate: type => { default: 'start',
if (['start', 'stop'].includes(type.toLowerCase())) return true; validate: (type) => {
return 'Please enter either `start` or `stop`.'; if (['start', 'stop'].includes(type.toLowerCase())) {
return true;
} else {
return 'Please enter either `start` or `stop`.';
}
}, },
parse: type => type.toLowerCase(), parse: (type) => type.toLowerCase()
default: 'start'
} }
] ]
}); });
@@ -31,25 +33,14 @@ module.exports = class LockdownCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { type } = args; const { type } = args;
if (type === 'start') { if (type === 'start') {
try { await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false });
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false }); return msg.say(stripIndents`
const staffRole = msg.guild.settings.get('staffRole'); Lockdown Started, users without Administrator can no longer post messages.
if (staffRole && !msg.channel.permissionOverwrites.has(staffRole)) Please use \`lockdown stop\` to end the lockdown.
await msg.channel.overwritePermissions(msg.guild.roles.get(staffRole), { SEND_MESSAGES: true }); `);
return msg.say(stripIndents`
Lockdown Started, users without Administrator ${staffRole ? 'or the Staff Role ' : ''}can no longer post messages.
Please use \`lockdown stop\` to end the lockdown.
`);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} else if (type === 'stop') { } else if (type === 'stop') {
try { await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: null });
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: null }); return msg.say('Lockdown Ended.');
return msg.say('Lockdown Ended.');
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} }
} }
}; };
+8 -5
View File
@@ -6,7 +6,7 @@ module.exports = class PruneCommand extends Command {
name: 'prune', name: 'prune',
group: 'moderation', group: 'moderation',
memberName: 'prune', memberName: 'prune',
description: 'Deletes a specified number of messages from the current channel, up to 99.', description: 'Deletes messages from the current channel, up to 99.',
guildOnly: true, guildOnly: true,
throttling: { throttling: {
usages: 1, usages: 1,
@@ -14,21 +14,24 @@ module.exports = class PruneCommand extends Command {
}, },
clientPermissions: ['READ_MESSAGE_HISTORY', 'MANAGE_MESSAGES'], clientPermissions: ['READ_MESSAGE_HISTORY', 'MANAGE_MESSAGES'],
userPermissions: ['MANAGE_MESSAGES'], userPermissions: ['MANAGE_MESSAGES'],
allowStaff: true,
args: [ args: [
{ {
key: 'count', key: 'count',
label: 'amount of messages', label: 'amount of messages',
prompt: 'How many messages do you want to delete? Limit of up to 99.', prompt: 'How many messages do you want to delete? Limit of up to 99.',
type: 'integer', type: 'integer',
validate: count => { validate: (count) => {
if (count < 100 && count > 0) return true; if (count < 100 && count > 0) {
return 'Invalid Count. Count must be from 1-99.'; return true;
} else {
return 'Invalid Count. Count must be from 1-99.';
}
} }
} }
] ]
}); });
} }
async run(msg, args) { async run(msg, args) {
const { count } = args; const { count } = args;
try { try {
+54 -32
View File
@@ -13,7 +13,6 @@ module.exports = class SoftbanCommand extends Command {
guildOnly: true, guildOnly: true,
clientPermissions: ['BAN_MEMBERS'], clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['KICK_MEMBERS'], userPermissions: ['KICK_MEMBERS'],
allowStaff: true,
args: [ args: [
{ {
key: 'member', key: 'member',
@@ -24,9 +23,12 @@ module.exports = class SoftbanCommand extends Command {
key: 'reason', key: 'reason',
prompt: 'What do you want to set the reason as?', prompt: 'What do you want to set the reason as?',
type: 'string', type: 'string',
validate: reason => { validate: (reason) => {
if (reason.length < 140) return true; if (reason.length < 140) {
return 'Invalid Reason. Reason must be under 140 characters.'; return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
} }
} }
] ]
@@ -35,38 +37,58 @@ module.exports = class SoftbanCommand extends Command {
async run(msg, args) { async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { member, reason } = args; const { member, reason } = args;
if (!member.bannable) return msg.say('This member is not softbannable. Perhaps they have a higher role than me?'); if (!member.bannable) {
return msg.say('This member is not softbannable. Perhaps they have a higher role than me?');
}
try { try {
try { await msg.say(`Are you sure you want to softban ${member.user.tag} (${member.id})?`);
await member.user.send(stripIndents` const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
You were softbanned from ${msg.guild.name}! max: 1,
Reason: ${reason}. time: 15000,
`); errors: ['time']
} catch (err) { });
await msg.say('Failed to Send DM.'); if (['y', 'yes'].includes(collected.first().content.toLowerCase())) {
try {
await member.user.send(stripIndents`
You were softbanned from ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason} (Softban)`
});
await msg.guild.unban(member.user, 'Softban');
await msg.say(`Successfully softbanned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user.has('SEND_MESSAGES'))) {
return msg.say('Could not log the softban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF4500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Softban.');
} }
await member.ban({ days: 7, reason });
await msg.guild.unban(member.user);
msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF4500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}
`);
modlogs.send({ embed });
return null;
} catch (err) { } catch (err) {
return msg.say(`${err.name}: ${err.message}`); return msg.say('Aborting Softban.');
} }
} }
}; };
+44 -25
View File
@@ -13,20 +13,22 @@ module.exports = class UnbanCommand extends Command {
guildOnly: true, guildOnly: true,
clientPermissions: ['BAN_MEMBERS'], clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['BAN_MEMBERS'], userPermissions: ['BAN_MEMBERS'],
allowStaff: true,
args: [ args: [
{ {
key: 'id', key: 'id',
prompt: 'What member do you want to unban? Please enter the ID of the user.', prompt: 'What is the id of the member you want to unban?',
type: 'string' type: 'string'
}, },
{ {
key: 'reason', key: 'reason',
prompt: 'What do you want to set the reason as?', prompt: 'What do you want to set the reason as?',
type: 'string', type: 'string',
validate: reason => { validate: (reason) => {
if (reason.length < 140) return true; if (reason.length < 140) {
return 'Invalid Reason. Reason must be under 140 characters.'; return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
} }
} }
] ]
@@ -35,31 +37,48 @@ module.exports = class UnbanCommand extends Command {
async run(msg, args) { async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { id, reason } = args; const { id, reason } = args;
const bans = await msg.guild.fetchBans(); const bans = await msg.guild.fetchBans();
if (!bans.has(id)) return msg.say('This ID is not in the Guild Banlist.'); if (!bans.has(id)) {
return msg.say('This ID is not in the Guild Banlist.');
}
const member = bans.get(id).user; const member = bans.get(id).user;
try { try {
await msg.guild.unban(member, reason); await msg.say(`Are you sure you want to unban ${member.tag} (${member.id})?`);
msg.say(':ok_hand:'); const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
const embed = new RichEmbed() max: 1,
.setAuthor(msg.author.tag, msg.author.displayAvatarURL) time: 15000,
.setColor(0x00AE86) errors: ['time']
.setTimestamp() });
.setDescription(stripIndents` if (['y', 'yes'].includes(collected.first().content.toLowerCase())) {
**Member:** ${member.tag} (${member.id}) await msg.guild.unban(member, `${msg.author.tag}: ${reason}`);
**Action:** Unban await msg.say(`Successfully unbanned ${member.user.tag}.`);
**Reason:** ${reason} if (!modlogs || !modlogs.permissionsFor(this.client.user.has('SEND_MESSAGES'))) {
`); return msg.say('Could not log the unban to the mod logs.');
modlogs.send({ embed }); } else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return null; return modlogs.send(stripIndents`
**Member:** ${member.tag} (${member.id})
**Action:** Unban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0x00AE86)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.tag} (${member.id})
**Action:** Unban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Unban.');
}
} catch (err) { } catch (err) {
return msg.say(`${err.name}: ${err.message}`); return msg.say('Aborting Unban.');
} }
} }
}; };
+48 -27
View File
@@ -6,11 +6,11 @@ module.exports = class WarnCommand extends Command {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'warn', name: 'warn',
aliases: ['warnne'],
group: 'moderation', group: 'moderation',
memberName: 'warn', memberName: 'warn',
description: 'Warns a user and logs the warn to the mod logs.', description: 'Warns a user and logs the warn to the mod logs.',
guildOnly: true, guildOnly: true,
allowStaff: true,
userPermissions: ['KICK_MEMBERS'], userPermissions: ['KICK_MEMBERS'],
args: [ args: [
{ {
@@ -22,9 +22,12 @@ module.exports = class WarnCommand extends Command {
key: 'reason', key: 'reason',
prompt: 'What do you want to set the reason as?', prompt: 'What do you want to set the reason as?',
type: 'string', type: 'string',
validate: reason => { validate: (reason) => {
if (reason.length < 140) return true; if (reason.length < 140) {
return 'Invalid Reason. Reason must be under 140 characters.'; return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
} }
} }
] ]
@@ -33,32 +36,50 @@ module.exports = class WarnCommand extends Command {
async run(msg, args) { async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { member, reason } = args; const { member, reason } = args;
if (!member.kickable) return msg.say('This member is not warnable. Perhaps they have a higher role than me?');
try { try {
await member.user.send(stripIndents` await msg.say(`Are you sure you want to warn ${member.user.tag} (${member.id})?`);
You were warned in ${msg.guild.name}! const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
Reason: ${reason}. max: 1,
`); time: 15000,
errors: ['time']
});
if (['y', 'yes'].includes(collected.first().content.toLowerCase())) {
try {
await member.user.send(stripIndents`
You were warned in ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await msg.say(`Successfully warned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user.has('SEND_MESSAGES'))) {
return msg.say('Could not log the warn to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Warn.');
}
} catch (err) { } catch (err) {
await msg.say('Failed to Send DM.'); return msg.say('Aborting Warn.');
} }
msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
`);
await modlogs.send({ embed });
return null;
} }
}; };
+23 -20
View File
@@ -15,21 +15,27 @@ module.exports = class CurrencyCommand extends Command {
key: 'base', key: 'base',
prompt: 'What currency code do you want to use as the base?', prompt: 'What currency code do you want to use as the base?',
type: 'string', type: 'string',
validate: base => { validate: (base) => {
if (codes.includes(base.toUpperCase())) return true; if (codes.includes(base.toUpperCase())) {
return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.'; return true;
} else {
return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.';
}
}, },
parse: base => base.toUpperCase() parse: (base) => base.toUpperCase()
}, },
{ {
key: 'to', key: 'to',
prompt: 'What currency code do you want to convert to?', prompt: 'What currency code do you want to convert to?',
type: 'string', type: 'string',
validate: to => { validate: (to) => {
if (codes.includes(to.toUpperCase())) return true; if (codes.includes(to.toUpperCase())) {
return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.'; return true;
} else {
return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.';
}
}, },
parse: to => to.toUpperCase() parse: (to) => to.toUpperCase()
}, },
{ {
key: 'amount', key: 'amount',
@@ -42,18 +48,15 @@ module.exports = class CurrencyCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { base, to, amount } = args; const { base, to, amount } = args;
if (base === to) return msg.say(`Converting ${base} to ${to} is the same value, dummy.`); if (base === to) {
try { return msg.say(`Converting ${base} to ${to} is the same value, dummy.`);
const { body } = await snekfetch
.get('http://api.fixer.io/latest')
.query({
base,
symbols: to
});
const rate = body.rates[to];
return msg.say(`${amount} ${base} is ${amount * rate} ${to}.`);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const { body } = await snekfetch
.get('http://api.fixer.io/latest')
.query({
base,
symbols: to
});
return msg.say(`${amount} ${base} is ${amount * body.rates[to]} ${to}.`);
} }
}; };
+3 -3
View File
@@ -21,10 +21,10 @@ module.exports = class MathCommand extends Command {
run(msg, args) { run(msg, args) {
const { expression } = args; const { expression } = args;
try { try {
const solved = math.eval(expression); const solved = math.eval(expression).toString();
return msg.say(solved).catch(() => msg.say('Invalid Statement.')); return msg.say(solved);
} catch (err) { } catch (err) {
return msg.say('Invalid Statement.'); return msg.say('Invalid Statement');
} }
} }
}; };
+32 -15
View File
@@ -12,21 +12,27 @@ module.exports = class TemperatureCommand extends Command {
key: 'base', key: 'base',
prompt: 'What temperature unit do you want to use as the base?', prompt: 'What temperature unit do you want to use as the base?',
type: 'string', type: 'string',
validate: base => { validate: (base) => {
if (['celsius', 'fahrenheit', 'kelvin'].includes(base.toLowerCase())) return true; if (['celsius', 'fahrenheit', 'kelvin'].includes(base.toLowerCase())) {
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.'; return true;
} else {
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
}
}, },
parse: base => base.toLowerCase() parse: (base) => base.toLowerCase()
}, },
{ {
key: 'to', key: 'to',
prompt: 'What temperature unit do you want to convert to?', prompt: 'What temperature unit do you want to convert to?',
type: 'string', type: 'string',
validate: to => { validate: (to) => {
if (['celsius', 'fahrenheit', 'kelvin'].includes(to.toLowerCase())) return true; if (['celsius', 'fahrenheit', 'kelvin'].includes(to.toLowerCase())) {
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.'; return true;
} else {
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
}
}, },
parse: to => to.toLowerCase() parse: (to) => to.toLowerCase()
}, },
{ {
key: 'amount', key: 'amount',
@@ -39,16 +45,27 @@ module.exports = class TemperatureCommand extends Command {
run(msg, args) { run(msg, args) {
const { base, to, amount } = args; const { base, to, amount } = args;
if (base === to) return msg.say(`Converting ${base} to ${to} is the same value, dummy.`); if (base === to) {
return msg.say(`Converting ${base} to ${to} is the same value, dummy.`);
}
if (base === 'celsius') { if (base === 'celsius') {
if (to === 'fahrenheit') return msg.say(`${amount}°C is ${(amount * 1.8) + 32}°F.`); if (to === 'fahrenheit') {
if (to === 'kelvin') return msg.say(`${amount}°C is ${amount + 273.15}°K.`); return msg.say(`${amount}°C is ${(amount * 1.8) + 32}°F.`);
} else if (to === 'kelvin') {
return msg.say(`${amount}°C is ${amount + 273.15}°K.`);
}
} else if (base === 'fahrenheit') { } else if (base === 'fahrenheit') {
if (to === 'celsius') return msg.say(`${amount}°F is ${(amount - 32) / 1.8}°C.`); if (to === 'celsius') {
if (to === 'kelvin') return msg.say(`${amount}°F is ${(amount + 459.67) * (5 / 9)}°K.`); return msg.say(`${amount}°F is ${(amount - 32) / 1.8}°C.`);
} else if (to === 'kelvin') {
return msg.say(`${amount}°F is ${(amount + 459.67) * (5 / 9)}°K.`);
}
} else if (base === 'kelvin') { } else if (base === 'kelvin') {
if (to === 'celsius') return msg.say(`${amount}°K is ${amount - 273.15}°C.`); if (to === 'celsius') {
if (to === 'fahrenheit') return msg.say(`${amount}°K is ${(amount * 1.8) - 459.67}°F.`); return msg.say(`${amount}°K is ${amount - 273.15}°C.`);
} else if (to === 'fahrenheit') {
return msg.say(`${amount}°K is ${(amount * 1.8) - 459.67}°F.`);
}
} }
} }
}; };
+2 -7
View File
@@ -29,12 +29,7 @@ module.exports = class CleverbotCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { text } = args; const { text } = args;
msg.channel.startTyping(); const { response } = await this.clevs.ask(text);
try { return msg.reply(response);
const { response } = await this.clevs.ask(text);
return msg.reply(response).then(() => msg.channel.stopTyping());
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} }
}; };
+7 -4
View File
@@ -14,11 +14,14 @@ module.exports = class EasterEggCommand extends Command {
key: 'tag', key: 'tag',
prompt: 'What easter egg do you want to view?', prompt: 'What easter egg do you want to view?',
type: 'string', type: 'string',
validate: tag => { validate: (tag) => {
if (eastereggs[tag.toLowerCase()]) return true; if (eastereggs[tag.toLowerCase()]) {
return 'Nope, that\'s not a valid easter egg. Try again!'; return true;
} else {
return 'Nope, that\'s not a valid easter egg. Try again!';
}
}, },
parse: tag => tag.toLowerCase() parse: (tag) => tag.toLowerCase()
} }
] ]
}); });
+22 -23
View File
@@ -17,11 +17,14 @@ module.exports = class HoroscopeCommand extends Command {
key: 'sign', key: 'sign',
prompt: 'Which sign would you like to get the horoscope for?', prompt: 'Which sign would you like to get the horoscope for?',
type: 'string', type: 'string',
validate: sign => { validate: (sign) => {
if (signs.includes(sign.toLowerCase())) return true; if (signs.includes(sign.toLowerCase())) {
return 'Invalid sign. Use `help horoscope` for a list of signs.'; return true;
} else {
return 'Invalid sign. Use `help horoscope` for a list of signs.';
}
}, },
parse: sign => sign.toLowerCase() parse: (sign) => sign.toLowerCase()
} }
] ]
}); });
@@ -29,24 +32,20 @@ module.exports = class HoroscopeCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { sign } = args; const { sign } = args;
try { const { text } = await snekfetch
const { text } = await snekfetch .get(`http://sandipbgt.com/theastrologer/api/horoscope/${sign}/today`);
.get(`http://sandipbgt.com/theastrologer/api/horoscope/${sign}/today`); const body = JSON.parse(text);
const body = JSON.parse(text); const embed = new RichEmbed()
const embed = new RichEmbed() .setColor(0x9797FF)
.setColor(0x9797FF) .setTitle(`Horoscope for ${body.sunsign}...`)
.setTitle(`Horoscope for ${body.sunsign}...`) .setTimestamp()
.setTimestamp() .setDescription(body.horoscope)
.setDescription(body.horoscope) .addField('Mood',
.addField('Mood', body.meta.mood, true)
body.meta.mood, true) .addField('Intensity',
.addField('Intensity', body.meta.intensity, true)
body.meta.intensity, true) .addField('Date',
.addField('Date', body.date, true);
body.date, true); return msg.embed(embed);
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} }
}; };
+10 -8
View File
@@ -15,23 +15,26 @@ module.exports = class MemeCommand extends Command {
key: 'type', key: 'type',
prompt: 'What meme type do you want to use?', prompt: 'What meme type do you want to use?',
type: 'string', type: 'string',
validate: type => { validate: (type) => {
if (codes.includes(type.toLowerCase())) return true; if (codes.includes(type.toLowerCase())) {
return 'Invalid meme type. Use `help meme` to view a list of meme types.'; return true;
} else {
return 'Invalid meme type. Use `help meme` to view a list of meme types.';
}
}, },
parse: type => type.toLowerCase() parse: (type) => type.toLowerCase()
}, },
{ {
key: 'top', key: 'top',
prompt: 'What should the top row of the meme to be?', prompt: 'What should the top row of the meme to be?',
type: 'string', type: 'string',
parse: top => encodeURIComponent(top.replace(/[ ]/g, '-')) parse: (top) => encodeURIComponent(top.replace(/[ ]/g, '-'))
}, },
{ {
key: 'bottom', key: 'bottom',
prompt: 'What should the bottom row of the meme to be?', prompt: 'What should the bottom row of the meme to be?',
type: 'string', type: 'string',
parse: bottom => encodeURIComponent(bottom.replace(/[ ]/g, '-')) parse: (bottom) => encodeURIComponent(bottom.replace(/[ ]/g, '-'))
} }
] ]
}); });
@@ -39,7 +42,6 @@ module.exports = class MemeCommand extends Command {
run(msg, args) { run(msg, args) {
const { type, top, bottom } = args; const { type, top, bottom } = args;
return msg.say({ files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`] }) return msg.say({ files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`] });
.catch(err => msg.say(`${err.name}: ${err.message}`));
} }
}; };
+24 -22
View File
@@ -22,11 +22,14 @@ module.exports = class SoundboardCommand extends Command {
key: 'sound', key: 'sound',
prompt: 'What sound would you like to play?', prompt: 'What sound would you like to play?',
type: 'string', type: 'string',
validate: sound => { validate: (sound) => {
if (names.includes(sound.toLowerCase())) return true; if (names.includes(sound.toLowerCase())) {
return 'Invalid Sound. Use `help soundboard` for a list of sounds.'; return true;
} else {
return 'Invalid Sound. Use `help soundboard` for a list of sounds.';
}
}, },
parse: sound => sound.toLowerCase() parse: (sound) => sound.toLowerCase()
} }
] ]
}); });
@@ -34,26 +37,25 @@ module.exports = class SoundboardCommand extends Command {
async run(msg, args) { async run(msg, args) {
const voiceChannel = msg.member.voiceChannel; const voiceChannel = msg.member.voiceChannel;
if (!voiceChannel) return msg.say('Please enter a Voice Channel first.'); if (!voiceChannel) {
if (!voiceChannel.permissionsFor(this.client.user).has('CONNECT')) return msg.say('Please enter a Voice Channel first.');
} else if (!voiceChannel.permissionsFor(this.client.user).has('CONNECT')) {
return msg.say('This Command requires the `CONNECT` Permission.'); return msg.say('This Command requires the `CONNECT` Permission.');
if (!voiceChannel.permissionsFor(this.client.user).has('SPEAK')) } else if (!voiceChannel.permissionsFor(this.client.user).has('SPEAK')) {
return msg.say('This Command requires the `SPEAK` Permission.'); return msg.say('This Command requires the `SPEAK` Permission.');
if (!voiceChannel.joinable) return msg.say('This Voice Channel is not joinable.'); } else if (!voiceChannel.joinable) {
const alreadyConnected = this.client.voiceConnections.get(voiceChannel.guild.id); return msg.say('This Voice Channel is not joinable.');
if (alreadyConnected) return msg.say('I am already playing a sound.'); } else if (this.client.voiceConnections.get(voiceChannel.guild.id)) {
const { sound } = args; return msg.say('I am already playing a sound.');
try {
const connection = await voiceChannel.join();
msg.react('🔊');
const dispatcher = connection.playFile(path.join(__dirname, '..', '..', 'assets', 'sounds', paths[sound]));
dispatcher.on('end', () => {
voiceChannel.leave();
msg.react('✅');
return null;
});
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const { sound } = args;
const connection = await voiceChannel.join();
msg.react('🔊');
const dispatcher = connection.playFile(path.join(__dirname, '..', '..', 'assets', 'sounds', paths[sound]));
dispatcher.on('end', () => {
voiceChannel.leave();
msg.react('✅');
return null;
});
} }
}; };
+1 -2
View File
@@ -13,7 +13,6 @@ module.exports = class SpamCommand extends Command {
} }
run(msg) { run(msg) {
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', 'spam.png')] }) return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', 'spam.png')] });
.catch(err => msg.say(`${err.name}: ${err.message}`));
} }
}; };
+20 -11
View File
@@ -1,5 +1,6 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js'); const { RichEmbed } = require('discord.js');
const { stripIndents } = require('common-tags');
const moment = require('moment'); const moment = require('moment');
module.exports = class StarCommand extends Command { module.exports = class StarCommand extends Command {
@@ -24,23 +25,31 @@ module.exports = class StarCommand extends Command {
async run(msg, args, reaction) { async run(msg, args, reaction) {
const { id } = args; const { id } = args;
const channel = msg.guild.channels.get(msg.guild.settings.get('starboard')); const channel = msg.guild.channels.get(msg.guild.settings.get('starboard'));
if (!channel || !channel.permissionsFor(this.client.user).has(['SEND_MESSAGES', 'EMBED_LINKS'])) return null; if (!channel || this.starred.includes(id)) {
if (this.starred.includes(id)) return null; return null;
try { } else if (!channel.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
const message = await msg.channel.fetchMessage(id); return msg.say('I do not have Permission to send the message.');
if (!reaction && msg.author.id === message.author.id) }
return msg.reply('You cannot star your own messages, baka.'); const message = await msg.channel.fetchMessage(id);
if (!reaction && msg.author.id === message.author.id) {
return msg.reply('You cannot star your own messages, baka.');
}
this.starred.push(id);
if (!channel.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return msg.say(stripIndents`
**Author:** ${message.author.tag}
**Content:** ${message.content}
**Date:** ${moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A')}
${message.attachments.first() ? `**Image:** ${message.attachments.first().url}` : ''}
`);
} else {
const embed = new RichEmbed() const embed = new RichEmbed()
.setColor(0xFFFF00) .setColor(0xFFFF00)
.setAuthor(message.author.tag, message.author.displayAvatarURL) .setAuthor(message.author.tag, message.author.displayAvatarURL)
.setDescription(message.content) .setDescription(message.content)
.setImage(message.attachments.first() ? message.attachments.first().url : null) .setImage(message.attachments.first() ? message.attachments.first().url : null)
.setFooter(moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A')); .setFooter(moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A'));
this.starred.push(id); return channel.send({ embed });
await channel.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
} }
}; };
+24 -18
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { FriendlyError } = require('discord.js-commando');
const { stripIndents } = require('common-tags'); const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch'); const snekfetch = require('snekfetch');
@@ -14,9 +15,12 @@ module.exports = class StrawpollCommand extends Command {
key: 'title', key: 'title',
prompt: 'What would you like the title of the Strawpoll to be?', prompt: 'What would you like the title of the Strawpoll to be?',
type: 'string', type: 'string',
validate: title => { validate: (title) => {
if (title.length < 200) return true; if (title.length < 200) {
return 'Invalid Title. Title must be under 200 characters.'; return true;
} else {
return 'Invalid Title. Title must be under 200 characters.';
}
} }
}, },
{ {
@@ -24,9 +28,12 @@ module.exports = class StrawpollCommand extends Command {
prompt: 'What options do you want me pick from? Maximum of 31.', prompt: 'What options do you want me pick from? Maximum of 31.',
type: 'string', type: 'string',
infinite: true, infinite: true,
validate: choice => { validate: (choice) => {
if (choice.length < 160) return true; if (choice.length < 160) {
return 'Invalid Choice. Choices must be under 140 characters each.'; return true;
} else {
return 'Invalid Choice. Choices must be under 140 characters each.';
}
} }
} }
] ]
@@ -35,18 +42,17 @@ module.exports = class StrawpollCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { title, options } = args; const { title, options } = args;
if (options.length < 2) return msg.say('You provided less than two choices.'); if (options.length < 2) {
if (options.length > 31) return msg.say('You provided more than thirty choices.'); throw new FriendlyError('You provided less than two choices.');
try { } else if (options.length > 31) {
const { body } = await snekfetch throw new FriendlyError('You provided more than thirty choices.');
.post('https://strawpoll.me/api/v2/polls')
.send({ title, options });
return msg.say(stripIndents`
${body.title}
http://strawpoll.me/${body.id}
`);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const { body } = await snekfetch
.post('https://strawpoll.me/api/v2/polls')
.send({ title, options });
return msg.say(stripIndents`
${body.title}
http://strawpoll.me/${body.id}
`);
} }
}; };
+12 -16
View File
@@ -14,21 +14,17 @@ module.exports = class TodayCommand extends Command {
} }
async run(msg) { async run(msg) {
try { const { text } = await snekfetch
const { text } = await snekfetch .get('http://history.muffinlabs.com/date');
.get('http://history.muffinlabs.com/date'); const body = JSON.parse(text);
const body = JSON.parse(text); const events = body.data.Events;
const events = body.data.Events; const event = events[Math.floor(Math.random() * events.length)];
const event = events[Math.floor(Math.random() * events.length)]; const embed = new RichEmbed()
const embed = new RichEmbed() .setColor(0x9797FF)
.setColor(0x9797FF) .setURL(body.url)
.setURL(body.url) .setTitle(`On this day (${body.date})...`)
.setTitle(`On this day (${body.date})...`) .setTimestamp()
.setTimestamp() .setDescription(`${event.year}: ${event.text}`);
.setDescription(`${event.year}: ${event.text}`); return msg.embed(embed);
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} }
}; };
+8 -12
View File
@@ -15,17 +15,13 @@ module.exports = class WouldYouRatherCommand extends Command {
} }
async run(msg) { async run(msg) {
try { const { body } = await snekfetch
const { body } = await snekfetch .get('http://www.rrrather.com/botapi');
.get('http://www.rrrather.com/botapi'); const embed = new RichEmbed()
const embed = new RichEmbed() .setTitle(`${body.title}...`)
.setTitle(`${body.title}...`) .setURL(body.link)
.setURL(body.link) .setColor(0x9797FF)
.setColor(0x9797FF) .setDescription(`${body.choicea} OR ${body.choiceb}?`);
.setDescription(`${body.choicea} OR ${body.choiceb}?`); return msg.embed(embed);
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} }
}; };
+3 -7
View File
@@ -13,12 +13,8 @@ module.exports = class CatCommand extends Command {
} }
async run(msg) { async run(msg) {
try { const { body } = await snekfetch
const { body } = await snekfetch .get('http://random.cat/meow');
.get('http://random.cat/meow'); return msg.say(body.file);
return msg.say(body.file);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} }
}; };
+3 -7
View File
@@ -12,12 +12,8 @@ module.exports = class DogCommand extends Command {
} }
async run(msg) { async run(msg) {
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://random.dog/woof.json');
.get('https://random.dog/woof.json'); return msg.say(body.url);
return msg.say(body.url);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} }
}; };
+1 -2
View File
@@ -15,7 +15,6 @@ module.exports = class XiaoCommand extends Command {
run(msg) { run(msg) {
const xiao = Math.floor(Math.random() * 10) + 1; const xiao = Math.floor(Math.random() * 10) + 1;
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', `xiao${xiao}.png`)] }) return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', `xiao${xiao}.png`)] });
.catch(err => msg.say(`${err.name}: ${err.message}`));
} }
}; };
+27 -28
View File
@@ -16,11 +16,14 @@ module.exports = class XKCDCommand extends Command {
key: 'type', key: 'type',
prompt: 'Would you like to get the comic for today or random?', prompt: 'Would you like to get the comic for today or random?',
type: 'string', type: 'string',
validate: type => { default: 'random',
if (['today', 'random'].includes(type.toLowerCase())) return true; validate: (type) => {
return 'Please enter either `today` or `random`'; if (['today', 'random'].includes(type.toLowerCase())) {
}, return true;
default: 'random' } else {
return 'Please enter either `today` or `random`';
}
}
} }
] ]
}); });
@@ -28,29 +31,25 @@ module.exports = class XKCDCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { type } = args; const { type } = args;
try { const current = await snekfetch
const current = await snekfetch .get('https://xkcd.com/info.0.json');
.get('https://xkcd.com/info.0.json'); if (type === 'today') {
if (type === 'today') { const embed = new RichEmbed()
const embed = new RichEmbed() .setTitle(`${current.body.num} - ${current.body.title}`)
.setTitle(`${current.body.num} - ${current.body.title}`) .setURL(`https://xkcd.com/${current.body.num}`)
.setURL(`https://xkcd.com/${current.body.num}`) .setImage(current.body.img)
.setImage(current.body.img) .setFooter(current.body.alt);
.setFooter(current.body.alt); return msg.embed(embed);
return msg.embed(embed); } else {
} else { const random = Math.floor(Math.random() * current.body.num) + 1;
const random = Math.floor(Math.random() * current.body.num) + 1; const { body } = await snekfetch
const { body } = await snekfetch .get(`https://xkcd.com/${random}/info.0.json`);
.get(`https://xkcd.com/${random}/info.0.json`); const embed = new RichEmbed()
const embed = new RichEmbed() .setTitle(`${body.num} - ${body.title}`)
.setTitle(`${body.num} - ${body.title}`) .setURL(`https://xkcd.com/${body.num}`)
.setURL(`https://xkcd.com/${body.num}`) .setImage(body.img)
.setImage(body.img) .setFooter(body.alt);
.setFooter(body.alt); return msg.embed(embed);
return msg.embed(embed);
}
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
} }
}; };
+7 -6
View File
@@ -7,20 +7,21 @@ module.exports = class ComplimentCommand extends Command {
name: 'compliment', name: 'compliment',
group: 'response', group: 'response',
memberName: 'compliment', memberName: 'compliment',
description: 'Compliments something/someone.', description: 'Compliments a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to compliment?', prompt: 'What user do you want to compliment?',
type: 'string' type: 'user',
default: ''
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const user = args.user || msg.author;
const compliment = compliments[Math.floor(Math.random() * compliments.length)]; const compliment = compliments[Math.floor(Math.random() * compliments.length)];
return msg.say(`${thing}, ${compliment}`); return msg.say(`${user}, ${compliment}`);
} }
}; };
+7 -4
View File
@@ -13,11 +13,14 @@ module.exports = class RandomNameCommand extends Command {
key: 'gender', key: 'gender',
prompt: 'Which gender do you want to generate a name for?', prompt: 'Which gender do you want to generate a name for?',
type: 'string', type: 'string',
validate: gender => { validate: (gender) => {
if (['male', 'female'].includes(gender.toLowerCase())) return true; if (['male', 'female'].includes(gender.toLowerCase())) {
return 'Please enter either `male` or `female`.'; return true;
} else {
return 'Please enter either `male` or `female`.';
}
}, },
parse: gender => gender.toLowerCase() parse: (gender) => gender.toLowerCase()
} }
] ]
}); });
+5 -5
View File
@@ -7,11 +7,11 @@ module.exports = class RoastCommand extends Command {
name: 'roast', name: 'roast',
group: 'response', group: 'response',
memberName: 'roast', memberName: 'roast',
description: 'Roasts something/someone.', description: 'Roasts a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roast?', prompt: 'What user do you want to roast?',
type: 'string' type: 'string'
} }
] ]
@@ -19,8 +19,8 @@ module.exports = class RoastCommand extends Command {
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const user = args.user || msg.author;
const roast = roasts[Math.floor(Math.random() * roasts.length)]; const roast = roasts[Math.floor(Math.random() * roasts.length)];
return msg.say(`${thing}, ${roast}`); return msg.say(`${user}, ${roast}`);
} }
}; };
+2 -1
View File
@@ -13,7 +13,8 @@ module.exports = class RollCommand extends Command {
key: 'value', key: 'value',
label: 'maximum number', label: 'maximum number',
prompt: 'What is the maximum number you wish to appear?', prompt: 'What is the maximum number you wish to appear?',
type: 'integer' type: 'integer',
default: 6
} }
] ]
}); });
+1 -7
View File
@@ -21,12 +21,6 @@ module.exports = class ShipCommand extends Command {
run(msg, args) { run(msg, args) {
const { things } = args; const { things } = args;
const rating = Math.floor(Math.random() * 100) + 1; const rating = Math.floor(Math.random() * 100) + 1;
let response; return msg.say(`I'd give ${things} a ${rating}%!`);
if (rating < 25) response = 'Ouch. Might want to keep them apart.';
else if (rating < 50) response = 'Meh, they should keep looking.';
else if (rating < 75) response = 'Could be worse, they should try it.';
else if (rating < 90) response = 'Not too bad. It might work out.';
else response = 'These guys have one bright future ahead of them!';
return msg.say(`I'd give ${things} a ${rating}%! ${response}`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class CuddleCommand extends Command { module.exports = class CuddleCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class CuddleCommand extends Command {
name: 'cuddle', name: 'cuddle',
group: 'roleplay', group: 'roleplay',
memberName: 'cuddle', memberName: 'cuddle',
description: 'Cuddles something/someone.', description: 'Cuddles a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *cuddles* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *cuddles* **${user.username}**
https://i.imgur.com/0yAIWbg.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class DivorceCommand extends Command { module.exports = class DivorceCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class DivorceCommand extends Command {
name: 'divorce', name: 'divorce',
group: 'roleplay', group: 'roleplay',
memberName: 'divorce', memberName: 'divorce',
description: 'Divorces something/someone.', description: 'Divorces a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *divorces* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *divorces* **${user.username}**
https://i.imgur.com/IgvLWaa.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class EatCommand extends Command { module.exports = class EatCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class EatCommand extends Command {
name: 'eat', name: 'eat',
group: 'roleplay', group: 'roleplay',
memberName: 'eat', memberName: 'eat',
description: 'Eats something/someone.', description: 'Eats a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *eats* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *eats* **${user.username}**
https://i.imgur.com/O7FQ5kz.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class FalconPunchCommand extends Command { module.exports = class FalconPunchCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class FalconPunchCommand extends Command {
name: 'falcon-punch', name: 'falcon-punch',
group: 'roleplay', group: 'roleplay',
memberName: 'falcon-punch', memberName: 'falcon-punch',
description: 'Falcon Punches something/someone.', description: 'Falcon Punches a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *falcon punches* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *falcon punches* **${user.username}**
https://i.imgur.com/LOuK637.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class FistBumpCommand extends Command { module.exports = class FistBumpCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class FistBumpCommand extends Command {
name: 'fist-bump', name: 'fist-bump',
group: 'roleplay', group: 'roleplay',
memberName: 'fist-bump', memberName: 'fist-bump',
description: 'Fistbumps something/someone.', description: 'Fistbumps a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *fist-bumps* ${thing} *badalalala*`); return msg.say(stripIndents`
**${msg.author.username}** *fist-bumps* **${user.username}**
*badalalala* https://i.imgur.com/lO2xZHC.gif
`);
} }
}; };
+9 -5
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class HighFivesCommand extends Command { module.exports = class HighFivesCommand extends Command {
constructor(client) { constructor(client) {
@@ -9,16 +10,19 @@ module.exports = class HighFivesCommand extends Command {
description: 'High Fives something/someone.', description: 'High Fives something/someone.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *high-fives* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *high-fives* **${user.username}**
https://i.imgur.com/7BJ6gfM.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class HitwithShovelCommand extends Command { module.exports = class HitwithShovelCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class HitwithShovelCommand extends Command {
name: 'hit-with-shovel', name: 'hit-with-shovel',
group: 'roleplay', group: 'roleplay',
memberName: 'hit-with-shovel', memberName: 'hit-with-shovel',
description: 'Hits something/someone with a shovel.', description: 'Hits a user with a shovel.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *hits* ${thing} *with a shovel*`); return msg.say(stripIndents`
**${msg.author.username}** *hits* **${user.username}** *with a shovel*
https://i.imgur.com/4yvqw81.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class HugCommand extends Command { module.exports = class HugCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class HugCommand extends Command {
name: 'hug', name: 'hug',
group: 'roleplay', group: 'roleplay',
memberName: 'hug', memberName: 'hug',
description: 'Hugs something/someone.', description: 'Hugs a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *hugs* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *hugs* **${user.username}**
https://i.imgur.com/q9Wkhz4.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class InhaleCommand extends Command { module.exports = class InhaleCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class InhaleCommand extends Command {
name: 'inhale', name: 'inhale',
group: 'roleplay', group: 'roleplay',
memberName: 'inhale', memberName: 'inhale',
description: 'Inhales something/someone.', description: 'Inhales a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *inhales* ${thing} *but gained no ability...*`); return msg.say(stripIndents`
**${msg.author.username}** *inhales* **${user.username}** *but gained no ability...*
https://i.imgur.com/b4NeOXj.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class KillCommand extends Command { module.exports = class KillCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class KillCommand extends Command {
name: 'kill', name: 'kill',
group: 'roleplay', group: 'roleplay',
memberName: 'kill', memberName: 'kill',
description: 'Kills something/someone.', description: 'Kills a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *kills* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *kills* **${user.username}**
https://i.imgur.com/WxD4XMe.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class KissCommand extends Command { module.exports = class KissCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class KissCommand extends Command {
name: 'kiss', name: 'kiss',
group: 'roleplay', group: 'roleplay',
memberName: 'kiss', memberName: 'kiss',
description: 'Kisses something/someone.', description: 'Kisses a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *kisses* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *kisses* **${user.username}**
https://i.imgur.com/S7mwPfE.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class MarryCommand extends Command { module.exports = class MarryCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class MarryCommand extends Command {
name: 'marry', name: 'marry',
group: 'roleplay', group: 'roleplay',
memberName: 'marry', memberName: 'marry',
description: 'Marries something/someone.', description: 'Marries a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *marries* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *marries* **${user.username}**
https://i.imgur.com/u67QLhB.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class PatCommand extends Command { module.exports = class PatCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class PatCommand extends Command {
name: 'pat', name: 'pat',
group: 'roleplay', group: 'roleplay',
memberName: 'pat', memberName: 'pat',
description: 'Pats something/someone.', description: 'Pats a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *pats* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *pats* **${user.username}**
https://i.imgur.com/oynHZmT.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class PokeCommand extends Command { module.exports = class PokeCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class PokeCommand extends Command {
name: 'poke', name: 'poke',
group: 'roleplay', group: 'roleplay',
memberName: 'poke', memberName: 'poke',
description: 'Pokes something/someone.', description: 'Pokes a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *pokes* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *pokes* **${user.username}**
https://i.imgur.com/XMuJ7K8.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class PunchCommand extends Command { module.exports = class PunchCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class PunchCommand extends Command {
name: 'punch', name: 'punch',
group: 'roleplay', group: 'roleplay',
memberName: 'punch', memberName: 'punch',
description: 'Punches something/someone.', description: 'Punches a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *punches* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *punches* **${user.username}**
https://i.imgur.com/R5KBiYV.gif
`);
} }
}; };
+10 -6
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
module.exports = class SlapCommand extends Command { module.exports = class SlapCommand extends Command {
constructor(client) { constructor(client) {
@@ -6,19 +7,22 @@ module.exports = class SlapCommand extends Command {
name: 'slap', name: 'slap',
group: 'roleplay', group: 'roleplay',
memberName: 'slap', memberName: 'slap',
description: 'Slaps something/someone.', description: 'Slaps a user.',
args: [ args: [
{ {
key: 'thing', key: 'user',
prompt: 'What do you want to roleplay with?', prompt: 'What user do you want to roleplay with?',
type: 'string' type: 'user'
} }
] ]
}); });
} }
run(msg, args) { run(msg, args) {
const { thing } = args; const { user } = args;
return msg.say(`${msg.author} *slaps* ${thing}`); return msg.say(stripIndents`
**${msg.author.username}** *slaps* **${user.username}**
https://i.imgur.com/rfy8z2K.gif
`);
} }
}; };
+7 -13
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js'); const { RichEmbed } = require('discord.js');
const snekfetch = require('snekfetch'); const snekfetch = require('snekfetch');
const { cleanXML } = require('../../util/Util');
const { promisifyAll } = require('tsubaki'); const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js')); const xml = promisifyAll(require('xml2js'));
const { ANIMELIST_LOGIN } = process.env; const { ANIMELIST_LOGIN } = process.env;
@@ -32,14 +33,7 @@ module.exports = class AnimeCommand extends Command {
q: query q: query
}); });
const { anime } = await xml.parseStringAsync(text); const { anime } = await xml.parseStringAsync(text);
const synopsis = anime.entry[0].synopsis[0].substr(0, 2000) const synopsis = cleanXML(anime.entry[0].synopsis[0].substr(0, 2000));
.replace(/(<br \/>)/g, '')
.replace(/(&#039;)/g, '\'')
.replace(/(&mdash;)/g, '—')
.replace(/(&#034;)/g, '"')
.replace(/(&#038;)/g, '&')
.replace(/(&quot;)/g, '"')
.replace(/(\[i\]|\[\/i\])/g, '*');
const embed = new RichEmbed() const embed = new RichEmbed()
.setColor(0x2D54A2) .setColor(0x2D54A2)
.setAuthor('My Anime List', 'https://i.imgur.com/R4bmNFz.png') .setAuthor('My Anime List', 'https://i.imgur.com/R4bmNFz.png')
@@ -47,17 +41,17 @@ module.exports = class AnimeCommand extends Command {
.setThumbnail(anime.entry[0].image[0]) .setThumbnail(anime.entry[0].image[0])
.setTitle(`${anime.entry[0].title[0]} (English: ${anime.entry[0].english[0] || 'N/A'})`) .setTitle(`${anime.entry[0].title[0]} (English: ${anime.entry[0].english[0] || 'N/A'})`)
.setDescription(synopsis) .setDescription(synopsis)
.addField('Type', .addField(' Type',
`${anime.entry[0].type[0]} - ${anime.entry[0].status[0]}`, true) `${anime.entry[0].type[0]} - ${anime.entry[0].status[0]}`, true)
.addField('Episodes', .addField(' Episodes',
anime.entry[0].episodes[0], true) anime.entry[0].episodes[0], true)
.addField('Start Date', .addField(' Start Date',
anime.entry[0].start_date[0], true) anime.entry[0].start_date[0], true)
.addField('End Date', .addField(' End Date',
anime.entry[0].end_date[0], true); anime.entry[0].end_date[0], true);
return msg.embed(embed); return msg.embed(embed);
} catch (err) { } catch (err) {
return msg.say('Error: No Results.'); return msg.say('No Results.');
} }
} }
}; };
+7 -5
View File
@@ -26,22 +26,24 @@ module.exports = class BotSearchCommand extends Command {
try { try {
const { body } = await snekfetch const { body } = await snekfetch
.get(`https://bots.discord.pw/api/bots/${bot.id}`) .get(`https://bots.discord.pw/api/bots/${bot.id}`)
.set({ Authorization: DBOTS_KEY }); .set({
Authorization: DBOTS_KEY
});
const embed = new RichEmbed() const embed = new RichEmbed()
.setColor(0x9797FF) .setColor(0x9797FF)
.setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg') .setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg')
.setTitle(body.name) .setTitle(body.name)
.setURL(`https://bots.discord.pw/bots/${bot.id}`) .setURL(`https://bots.discord.pw/bots/${bot.id}`)
.setDescription(body.description) .setDescription(body.description)
.addField('Library', .addField(' Library',
body.library, true) body.library, true)
.addField('Invite', .addField(' Invite',
`[Here](${body.invite_url})`, true) `[Here](${body.invite_url})`, true)
.addField('Prefix', .addField(' Prefix',
body.prefix, true); body.prefix, true);
return msg.embed(embed); return msg.embed(embed);
} catch (err) { } catch (err) {
return msg.say(`${err.name}: ${err.message}`); return msg.say(err.message);
} }
} }
}; };
+20 -22
View File
@@ -23,28 +23,26 @@ module.exports = class BulbapediaCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('http://bulbapedia.bulbagarden.net/w/api.php')
.get('http://bulbapedia.bulbagarden.net/w/api.php') .query({
.query({ action: 'query',
action: 'query', prop: 'extracts',
prop: 'extracts', format: 'json',
format: 'json', titles: query,
titles: query, exintro: '',
exintro: '', explaintext: '',
explaintext: '', redirects: '',
redirects: '', formatversion: 2
formatversion: 2 });
}); if (body.query.pages[0].missing) {
if (body.query.pages[0].missing) throw new Error('No Results.'); return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0x3E7614)
.setTitle(body.query.pages[0].title)
.setAuthor('Bulbapedia', 'https://i.imgur.com/09eYo5T.png')
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const embed = new RichEmbed()
.setColor(0x3E7614)
.setTitle(body.query.pages[0].title)
.setAuthor('Bulbapedia', 'https://i.imgur.com/09eYo5T.png')
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
return msg.embed(embed);
} }
}; };
+9 -12
View File
@@ -22,18 +22,15 @@ module.exports = class DanbooruCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://danbooru.donmai.us/posts.json')
.get('https://danbooru.donmai.us/posts.json') .query({
.query({ tags: `${query ? `${query} ` : ''}order:random`,
tags: `${query ? `${query} ` : ''}order:random`, limit: 1
limit: 1 });
}); if (!body.length || !body[0].file_url) {
if (!body.length) throw new Error('No Results.'); return msg.say('No Results');
if (!body[0].file_url) throw new Error('No Results.');
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https://danbooru.donmai.us${body[0].file_url}`);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https://danbooru.donmai.us${body[0].file_url}`);
} }
}; };
+16 -18
View File
@@ -16,7 +16,7 @@ module.exports = class DefineCommand extends Command {
key: 'query', key: 'query',
prompt: 'What would you like to define?', prompt: 'What would you like to define?',
type: 'string', type: 'string',
parse: query => encodeURIComponent(query) parse: (query) => encodeURIComponent(query)
} }
] ]
}); });
@@ -24,23 +24,21 @@ module.exports = class DefineCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions`)
.get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions`) .query({
.query({ limit: 1,
limit: 1, includeRelated: false,
includeRelated: false, useCanonical: false,
useCanonical: false, api_key: WORDNIK_KEY
api_key: WORDNIK_KEY });
}); if (!body.length) {
if (!body.length) throw new Error('No Results.'); return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0x9797FF)
.setTitle(body[0].word)
.setDescription(body[0].text);
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const embed = new RichEmbed()
.setColor(0x9797FF)
.setTitle(body[0].word)
.setDescription(body[0].text);
return msg.embed(embed);
} }
}; };
+9 -5
View File
@@ -15,9 +15,13 @@ module.exports = class DiscrimCommand extends Command {
key: 'discrim', key: 'discrim',
prompt: 'Which discriminator would you like to search for?', prompt: 'Which discriminator would you like to search for?',
type: 'string', type: 'string',
validate: discrim => { default: '',
if (/[0-9]+$/g.test(discrim) && discrim.length === 4) return true; validate: (discrim) => {
return `${discrim} is not a valid discriminator.`; if (/[0-9]+$/g.test(discrim) && discrim.length === 4) {
return true;
} else {
return 'Invalid Discriminator.';
}
} }
} }
] ]
@@ -25,8 +29,8 @@ module.exports = class DiscrimCommand extends Command {
} }
run(msg, args) { run(msg, args) {
const { discrim } = args; const discrim = args.discrim || msg.author.discriminator;
const users = this.client.users.filter(u => u.discriminator === discrim).map(u => u.username).sort(); const users = this.client.users.filter((u) => u.discriminator === discrim).map((u) => u.username);
const embed = new RichEmbed() const embed = new RichEmbed()
.setTitle(`${users.length} Users with the discriminator: ${discrim}`) .setTitle(`${users.length} Users with the discriminator: ${discrim}`)
.setDescription(users.join(', ')); .setDescription(users.join(', '));
+29 -31
View File
@@ -22,37 +22,35 @@ module.exports = class ForecastCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://query.yahooapis.com/v1/public/yql')
.get('https://query.yahooapis.com/v1/public/yql') .query({
.query({ q: `select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")`,
q: `select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")`, format: 'json'
format: 'json' });
}); if (!body.query.count) {
if (!body.query.count) throw new Error('Location Not Found.'); return msg.say('Location Not Found.');
const forecasts = body.query.results.channel.item.forecast;
const embed = new RichEmbed()
.setColor(0x0000FF)
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
.setURL(body.query.results.channel.link)
.setTimestamp()
.addField(`${forecasts[0].day} - ${forecasts[0].date}`,
`**High:** ${forecasts[0].high}°F, **Low:** ${forecasts[0].low}°F, **Condition:** ${forecasts[0].text}`)
.addField(`${forecasts[1].day} - ${forecasts[1].date}`,
`**High:** ${forecasts[1].high}°F, **Low:** ${forecasts[1].low}°F, **Condition:** ${forecasts[1].text}`)
.addField(`${forecasts[2].day} - ${forecasts[2].date}`,
`**High:** ${forecasts[2].high}°F, **Low:** ${forecasts[2].low}°F, **Condition:** ${forecasts[2].text}`)
.addField(`${forecasts[3].day} - ${forecasts[3].date}`,
`**High:** ${forecasts[3].high}°F, **Low:** ${forecasts[3].low}°F, **Condition:** ${forecasts[3].text}`)
.addField(`${forecasts[4].day} - ${forecasts[4].date}`,
`**High:** ${forecasts[4].high}°F, **Low:** ${forecasts[4].low}°F, **Condition:** ${forecasts[4].text}`)
.addField(`${forecasts[5].day} - ${forecasts[5].date}`,
`**High:** ${forecasts[5].high}°F, **Low:** ${forecasts[5].low}°F, **Condition:** ${forecasts[5].text}`)
.addField(`${forecasts[6].day} - ${forecasts[6].date}`,
`**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`);
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const forecasts = body.query.results.channel.item.forecast;
const embed = new RichEmbed()
.setColor(0x0000FF)
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
.setURL(body.query.results.channel.link)
.setTimestamp()
.addField(` ${forecasts[0].day} - ${forecasts[0].date}`,
`**High:** ${forecasts[0].high}°F, **Low:** ${forecasts[0].low}°F, **Condition:** ${forecasts[0].text}`)
.addField(` ${forecasts[1].day} - ${forecasts[1].date}`,
`**High:** ${forecasts[1].high}°F, **Low:** ${forecasts[1].low}°F, **Condition:** ${forecasts[1].text}`)
.addField(` ${forecasts[2].day} - ${forecasts[2].date}`,
`**High:** ${forecasts[2].high}°F, **Low:** ${forecasts[2].low}°F, **Condition:** ${forecasts[2].text}`)
.addField(` ${forecasts[3].day} - ${forecasts[3].date}`,
`**High:** ${forecasts[3].high}°F, **Low:** ${forecasts[3].low}°F, **Condition:** ${forecasts[3].text}`)
.addField(` ${forecasts[4].day} - ${forecasts[4].date}`,
`**High:** ${forecasts[4].high}°F, **Low:** ${forecasts[4].low}°F, **Condition:** ${forecasts[4].text}`)
.addField(` ${forecasts[5].day} - ${forecasts[5].date}`,
`**High:** ${forecasts[5].high}°F, **Low:** ${forecasts[5].low}°F, **Condition:** ${forecasts[5].text}`)
.addField(` ${forecasts[6].day} - ${forecasts[6].date}`,
`**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`);
return msg.embed(embed);
} }
}; };
+3 -5
View File
@@ -23,7 +23,6 @@ module.exports = class GelbooruCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try {
const { text } = await snekfetch const { text } = await snekfetch
.get('https://gelbooru.com/index.php') .get('https://gelbooru.com/index.php')
.query({ .query({
@@ -34,10 +33,9 @@ module.exports = class GelbooruCommand extends Command {
limit: 1 limit: 1
}); });
const { posts } = await xml.parseStringAsync(text); const { posts } = await xml.parseStringAsync(text);
if (posts.$.count === '0') throw new Error('No Results.'); if (posts.$.count === '0') {
return msg.say('No Results.');
}
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`); return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} }
}; };
+11 -13
View File
@@ -21,19 +21,17 @@ module.exports = class GiphyCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('http://api.giphy.com/v1/gifs/search')
.get('http://api.giphy.com/v1/gifs/search') .query({
.query({ q: query,
q: query, api_key: GIPHY_KEY,
api_key: GIPHY_KEY, rating: msg.channel.nsfw ? 'r' : 'pg'
rating: msg.channel.nsfw ? 'r' : 'pg' });
}); if (!body.data.length) {
if (!body.data.length) throw new Error('No Results.'); return msg.say('No Results.');
const random = Math.floor(Math.random() * body.data.length);
return msg.say(body.data[random].images.original.url);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const random = Math.floor(Math.random() * body.data.length);
return msg.say(body.data[random].images.original.url);
} }
}; };
+7 -7
View File
@@ -34,21 +34,21 @@ module.exports = class GithubCommand extends Command {
.setTitle(body.full_name) .setTitle(body.full_name)
.setDescription(body.description) .setDescription(body.description)
.setThumbnail(body.owner.avatar_url) .setThumbnail(body.owner.avatar_url)
.addField('Creation Date', .addField(' Creation Date',
moment(body.created_at).format('MMMM Do YYYY'), true) moment(body.created_at).format('MMMM Do YYYY'), true)
.addField('Last Updated On', .addField(' Last Updated On',
moment(body.updated_at).format('MMMM Do YYYY'), true) moment(body.updated_at).format('MMMM Do YYYY'), true)
.addField('Stargazers', .addField(' Stargazers',
body.stargazers_count, true) body.stargazers_count, true)
.addField('Watchers', .addField(' Watchers',
body.watchers_count, true) body.watchers_count, true)
.addField('Open Issues', .addField(' Open Issues',
body.open_issues_count, true) body.open_issues_count, true)
.addField('Language', .addField(' Language',
body.language, true); body.language, true);
return msg.embed(embed); return msg.embed(embed);
} catch (err) { } catch (err) {
return msg.say(`${err.name}: ${err.message}`); return msg.say(err.message);
} }
} }
}; };
+11 -13
View File
@@ -23,19 +23,17 @@ module.exports = class GoogleCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
const message = await msg.say('Searching...'); const message = await msg.say('Searching...');
try { const { text } = await snekfetch
const { text } = await snekfetch .get('https://www.google.com/search')
.get('https://www.google.com/search') .query({
.query({ q: query
q: query });
}); const $ = cheerio.load(text);
const $ = cheerio.load(text); let href = $('.r').first().find('a').first().attr('href');
let href = $('.r').first().find('a').first().attr('href'); if (!href) {
if (!href) throw new Error('No Results.'); return msg.say('No Results.');
href = querystring.parse(href.replace('/url?', ''));
return message.edit(href.q);
} catch (err) {
return message.edit(`${err.name}: ${err.message}`);
} }
href = querystring.parse(href.replace('/url?', ''));
return message.edit(href.q);
} }
}; };
+9 -11
View File
@@ -22,17 +22,15 @@ module.exports = class KonachanCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://konachan.net/post.json')
.get('https://konachan.net/post.json') .query({
.query({ tags: `${query ? `${query} ` : ''}order:random`,
tags: `${query ? `${query} ` : ''}order:random`, limit: 1
limit: 1 });
}); if (!body.length) {
if (!body.length) throw new Error('No Results.'); return msg.say('No Results.');
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https:${body[0].file_url}`);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https:${body[0].file_url}`);
} }
}; };
+1 -1
View File
@@ -12,7 +12,7 @@ module.exports = class LMGTFYCommand extends Command {
key: 'query', key: 'query',
prompt: 'What would you like to the link to search for?', prompt: 'What would you like to the link to search for?',
type: 'string', type: 'string',
parse: query => encodeURIComponent(query) parse: (query) => encodeURIComponent(query)
} }
] ]
}); });
+7 -13
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js'); const { RichEmbed } = require('discord.js');
const snekfetch = require('snekfetch'); const snekfetch = require('snekfetch');
const { cleanXML } = require('../../util/Util');
const { promisifyAll } = require('tsubaki'); const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js')); const xml = promisifyAll(require('xml2js'));
const { ANIMELIST_LOGIN } = process.env; const { ANIMELIST_LOGIN } = process.env;
@@ -32,14 +33,7 @@ module.exports = class MangaCommand extends Command {
q: query q: query
}); });
const { manga } = await xml.parseStringAsync(text); const { manga } = await xml.parseStringAsync(text);
const synopsis = manga.entry[0].synopsis[0].substr(0, 2000) const synopsis = cleanXML(manga.entry[0].synopsis[0].substr(0, 2000));
.replace(/(<br \/>)/g, '')
.replace(/(&#039;)/g, '\'')
.replace(/(&mdash;)/g, '—')
.replace(/(&#034;)/g, '"')
.replace(/(&#038;)/g, '&')
.replace(/(&quot;)/g, '"')
.replace(/(\[i\]|\[\/i\])/g, '*');
const embed = new RichEmbed() const embed = new RichEmbed()
.setColor(0x2D54A2) .setColor(0x2D54A2)
.setAuthor('My Anime List', 'https://i.imgur.com/R4bmNFz.png') .setAuthor('My Anime List', 'https://i.imgur.com/R4bmNFz.png')
@@ -47,17 +41,17 @@ module.exports = class MangaCommand extends Command {
.setThumbnail(manga.entry[0].image[0]) .setThumbnail(manga.entry[0].image[0])
.setTitle(`${manga.entry[0].title[0]} (English: ${manga.entry[0].english[0] || 'N/A'})`) .setTitle(`${manga.entry[0].title[0]} (English: ${manga.entry[0].english[0] || 'N/A'})`)
.setDescription(synopsis) .setDescription(synopsis)
.addField('Type', .addField(' Type',
`${manga.entry[0].type[0]} - ${manga.entry[0].status[0]}`, true) `${manga.entry[0].type[0]} - ${manga.entry[0].status[0]}`, true)
.addField('Volumes / Chapters', .addField(' Volumes / Chapters',
`${manga.entry[0].volumes[0]} / ${manga.entry[0].chapters[0]}`, true) `${manga.entry[0].volumes[0]} / ${manga.entry[0].chapters[0]}`, true)
.addField('Start Date', .addField(' Start Date',
manga.entry[0].start_date[0], true) manga.entry[0].start_date[0], true)
.addField('End Date', .addField(' End Date',
manga.entry[0].end_date[0], true); manga.entry[0].end_date[0], true);
return msg.embed(embed); return msg.embed(embed);
} catch (err) { } catch (err) {
return msg.say('Error: No Results.'); return msg.say('No Results.');
} }
} }
}; };
+14 -17
View File
@@ -16,10 +16,12 @@ module.exports = class MapCommand extends Command {
label: 'zoom level', label: 'zoom level',
prompt: 'What would you like the zoom level for the map to be? Limit 1-20.', prompt: 'What would you like the zoom level for the map to be? Limit 1-20.',
type: 'integer', type: 'integer',
validate: zoom => { validate: (zoom) => {
if (zoom < 21 && zoom > 0) if (zoom < 21 && zoom > 0) {
return true; return true;
return 'Please enter a zoom value from 1-20'; } else {
return 'Please enter a zoom value from 1-20';
}
} }
}, },
{ {
@@ -33,19 +35,14 @@ module.exports = class MapCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { zoom, query } = args; const { zoom, query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://maps.googleapis.com/maps/api/staticmap')
.get('https://maps.googleapis.com/maps/api/staticmap') .query({
.query({ center: query,
center: query, zoom,
zoom, size: '500x500',
size: '500x500', key: GOOGLE_KEY
key: GOOGLE_KEY });
}); return msg.say({ files: [{ attachment: body, name: 'map.png' }] });
return msg.say({ files: [{ attachment: body, name: 'map.png' }] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
} }
}; };
+12 -14
View File
@@ -21,20 +21,18 @@ module.exports = class NeopetCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { text } = await snekfetch
const { text } = await snekfetch .get('http://www.sunnyneo.com/petimagefinder.php')
.get('http://www.sunnyneo.com/petimagefinder.php') .query({
.query({ name: query,
name: query, size: 5,
size: 5, mood: 1
mood: 1 });
}); const $ = cheerio.load(text);
const $ = cheerio.load(text); const link = $('textarea').first().text();
const link = $('textarea').first().text(); if (!link.includes('cp')) {
if (!link.includes('cp')) throw new Error('Invalid Pet Name.'); return msg.say('Invalid Pet Name.');
return msg.say(link);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
return msg.say(link);
} }
}; };
+38 -40
View File
@@ -23,46 +23,44 @@ module.exports = class OsuCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://osu.ppy.sh/api/get_user')
.get('https://osu.ppy.sh/api/get_user') .query({
.query({ k: OSU_KEY,
k: OSU_KEY, u: query,
u: query, type: 'string'
type: 'string' });
}); if (!body.length) {
if (!body.length) throw new Error('No Results.'); return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0xFF66AA)
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
.setURL('https://osu.ppy.sh/')
.addField('Username',
body[0].username, true)
.addField('ID',
body[0].user_id, true)
.addField('Level',
body[0].level, true)
.addField('Accuracy',
body[0].accuracy, true)
.addField('Rank',
body[0].pp_rank, true)
.addField('Play Count',
body[0].playcount, true)
.addField('Country',
body[0].country, true)
.addField('Ranked Score',
body[0].ranked_score, true)
.addField('Total Score',
body[0].total_score, true)
.addField('SS',
body[0].count_rank_ss, true)
.addField('S',
body[0].count_rank_s, true)
.addField('A',
body[0].count_rank_a, true);
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const embed = new RichEmbed()
.setColor(0xFF66AA)
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
.setURL('https://osu.ppy.sh/')
.addField(' Username',
body[0].username, true)
.addField(' ID',
body[0].user_id, true)
.addField(' Level',
body[0].level, true)
.addField(' Accuracy',
body[0].accuracy, true)
.addField(' Rank',
body[0].pp_rank, true)
.addField(' Play Count',
body[0].playcount, true)
.addField(' Country',
body[0].country, true)
.addField(' Ranked Score',
body[0].ranked_score, true)
.addField(' Total Score',
body[0].total_score, true)
.addField(' SS',
body[0].count_rank_ss, true)
.addField(' S',
body[0].count_rank_s, true)
.addField(' A',
body[0].count_rank_a, true);
return msg.embed(embed);
} }
}; };
+13 -15
View File
@@ -23,21 +23,19 @@ module.exports = class Rule34Command extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { text } = await snekfetch
const { text } = await snekfetch .get('https://rule34.xxx/index.php')
.get('https://rule34.xxx/index.php') .query({
.query({ page: 'dapi',
page: 'dapi', s: 'post',
s: 'post', q: 'index',
q: 'index', tags: query,
tags: query, limit: 1
limit: 1 });
}); const { posts } = await xml.parseStringAsync(text);
const { posts } = await xml.parseStringAsync(text); if (posts.$.count === '0') {
if (posts.$.count === '0') throw new Error('No Results.'); return msg.say('No Results.');
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
} }
}; };
+25 -27
View File
@@ -23,33 +23,31 @@ module.exports = class SoundCloudCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://api.soundcloud.com/tracks')
.get('https://api.soundcloud.com/tracks') .query({
.query({ q: query,
q: query, client_id: SOUNDCLOUD_KEY
client_id: SOUNDCLOUD_KEY });
}); if (!body.length) {
if (!body.length) throw new Error('No Results.'); return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0xF15A22)
.setAuthor('SoundCloud', 'https://i.imgur.com/lFIz7RU.png')
.setTitle(body[0].title)
.setURL(body[0].permalink_url)
.setThumbnail(body[0].artwork_url)
.addField('Artist',
body[0].user.username)
.addField('Download Count',
body[0].download_count, true)
.addField('Comment Count',
body[0].comment_count, true)
.addField('Playback Count',
body[0].playback_count, true)
.addField('Favorited Count',
body[0].favoritings_count, true);
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const embed = new RichEmbed()
.setColor(0xF15A22)
.setAuthor('SoundCloud', 'https://i.imgur.com/lFIz7RU.png')
.setTitle(body[0].title)
.setURL(body[0].permalink_url)
.setThumbnail(body[0].artwork_url)
.addField(' Artist',
body[0].user.username)
.addField(' Download Count',
body[0].download_count, true)
.addField(' Comment Count',
body[0].comment_count, true)
.addField(' Playback Count',
body[0].playback_count, true)
.addField(' Favorited Count',
body[0].favoritings_count, true);
return msg.embed(embed);
} }
}; };
+16 -18
View File
@@ -22,24 +22,22 @@ module.exports = class UrbanCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('http://api.urbandictionary.com/v0/define')
.get('http://api.urbandictionary.com/v0/define') .query({
.query({ term: query
term: query });
}); if (!body.list.length) {
if (!body.list.length) throw new Error('No Results.'); return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0x32a8f0)
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
.setURL(body.list[0].permalink)
.setTitle(body.list[0].word)
.setDescription(body.list[0].definition.substr(0, 2000))
.addField('Example',
body.list[0].example.substr(0, 2000) || 'None');
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const embed = new RichEmbed()
.setColor(0x32a8f0)
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
.setURL(body.list[0].permalink)
.setTitle(body.list[0].word)
.setDescription(body.list[0].definition.substr(0, 2000))
.addField(' Example',
body.list[0].example.substr(0, 2000) || 'None');
return msg.embed(embed);
} }
}; };
+31 -31
View File
@@ -24,37 +24,37 @@ module.exports = class WattpadCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://api.wattpad.com:443/v4/stories')
.get('https://api.wattpad.com:443/v4/stories') .query({
.query({ query,
query, limit: 1
limit: 1 })
}) .set({
.set({ Authorization: `Basic ${WATTPAD_KEY}` }); Authorization: `Basic ${WATTPAD_KEY}`
if (!body.stories.length) throw new Error('No Results.'); });
const embed = new RichEmbed() if (!body.stories.length) {
.setColor(0xF89C34) return msg.say('No Results.');
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
.setURL(body.stories[0].url)
.setTitle(body.stories[0].title)
.setDescription(body.stories[0].description.substr(0, 2000))
.setThumbnail(body.stories[0].cover)
.addField('Created On',
moment(body.stories[0].createDate).format('MMMM Do YYYY'), true)
.addField('Author',
body.stories[0].user, true)
.addField('Parts',
body.stories[0].numParts, true)
.addField('Reads',
body.stories[0].readCount, true)
.addField('Votes',
body.stories[0].voteCount, true)
.addField('Comments',
body.stories[0].commentCount, true);
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const embed = new RichEmbed()
.setColor(0xF89C34)
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
.setURL(body.stories[0].url)
.setTitle(body.stories[0].title)
.setDescription(body.stories[0].description.substr(0, 2000))
.setThumbnail(body.stories[0].cover)
.addField(' Created On',
moment(body.stories[0].createDate).format('MMMM Do YYYY'), true)
.addField(' Author',
body.stories[0].user, true)
.addField(' Parts',
body.stories[0].numParts, true)
.addField(' Reads',
body.stories[0].readCount, true)
.addField(' Votes',
body.stories[0].voteCount, true)
.addField(' Comments',
body.stories[0].commentCount, true);
return msg.embed(embed);
} }
}; };
+38 -40
View File
@@ -22,46 +22,44 @@ module.exports = class WeatherCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://query.yahooapis.com/v1/public/yql')
.get('https://query.yahooapis.com/v1/public/yql') .query({
.query({ q: `select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")`,
q: `select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")`, format: 'json'
format: 'json' });
}); if (!body.query.count) {
if (!body.query.count) throw new Error('Location Not Found.'); return msg.say('Location Not Found.');
const embed = new RichEmbed()
.setColor(0x0000FF)
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
.setURL(body.query.results.channel.link)
.setTimestamp()
.addField('City',
body.query.results.channel.location.city, true)
.addField('Country',
body.query.results.channel.location.country, true)
.addField('Region',
body.query.results.channel.location.region, true)
.addField('Condition',
body.query.results.channel.item.condition.text, true)
.addField('Temperature',
`${body.query.results.channel.item.condition.temp}°F`, true)
.addField('Humidity',
body.query.results.channel.atmosphere.humidity, true)
.addField('Pressure',
body.query.results.channel.atmosphere.pressure, true)
.addField('Rising',
body.query.results.channel.atmosphere.rising, true)
.addField('Visibility',
body.query.results.channel.atmosphere.visibility, true)
.addField('Wind Chill',
body.query.results.channel.wind.chill, true)
.addField('Wind Direction',
body.query.results.channel.wind.direction, true)
.addField('Wind Speed',
body.query.results.channel.wind.speed, true);
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const embed = new RichEmbed()
.setColor(0x0000FF)
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
.setURL(body.query.results.channel.link)
.setTimestamp()
.addField(' City',
body.query.results.channel.location.city, true)
.addField(' Country',
body.query.results.channel.location.country, true)
.addField(' Region',
body.query.results.channel.location.region, true)
.addField(' Condition',
body.query.results.channel.item.condition.text, true)
.addField(' Temperature',
`${body.query.results.channel.item.condition.temp}°F`, true)
.addField(' Humidity',
body.query.results.channel.atmosphere.humidity, true)
.addField(' Pressure',
body.query.results.channel.atmosphere.pressure, true)
.addField(' Rising',
body.query.results.channel.atmosphere.rising, true)
.addField(' Visibility',
body.query.results.channel.atmosphere.visibility, true)
.addField(' Wind Chill',
body.query.results.channel.wind.chill, true)
.addField(' Wind Direction',
body.query.results.channel.wind.direction, true)
.addField(' Wind Speed',
body.query.results.channel.wind.speed, true);
return msg.embed(embed);
} }
}; };
+20 -22
View File
@@ -22,28 +22,26 @@ module.exports = class WikipediaCommand extends Command {
async run(msg, args) { async run(msg, args) {
const { query } = args; const { query } = args;
try { const { body } = await snekfetch
const { body } = await snekfetch .get('https://en.wikipedia.org/w/api.php')
.get('https://en.wikipedia.org/w/api.php') .query({
.query({ action: 'query',
action: 'query', prop: 'extracts',
prop: 'extracts', format: 'json',
format: 'json', titles: query,
titles: query, exintro: '',
exintro: '', explaintext: '',
explaintext: '', redirects: '',
redirects: '', formatversion: 2
formatversion: 2 });
}); if (body.query.pages[0].missing) {
if (body.query.pages[0].missing) throw new Error('No Results.'); return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0xE7E7E7)
.setTitle(body.query.pages[0].title)
.setAuthor('Wikipedia', 'https://i.imgur.com/a4eeEhh.png')
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
return msg.embed(embed);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
} }
const embed = new RichEmbed()
.setColor(0xE7E7E7)
.setTitle(body.query.pages[0].title)
.setAuthor('Wikipedia', 'https://i.imgur.com/a4eeEhh.png')
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
return msg.embed(embed);
} }
}; };

Some files were not shown because too many files have changed in this diff Show More