Minor Code Improvements

This commit is contained in:
Daniel Odendahl Jr
2017-05-03 01:03:59 +00:00
parent b18241f7bc
commit 74fa836044
16 changed files with 96 additions and 29 deletions
+8 -2
View File
@@ -63,10 +63,16 @@ module.exports = class MathGameCommand extends Command {
errors: ['time']
});
if (collected.first().content !== solved)
return msg.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`);
return msg.say(
`Aw... Too bad, try again next time!
The correct answer is: ${solved}`
);
return msg.say(`Good Job! You won! ${solved} is the correct answer!`);
} catch (err) {
return msg.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`);
return msg.say(
`Aw... Too bad, try again next time!
The correct answer is: ${solved}`
);
}
}
};
+8 -2
View File
@@ -25,7 +25,10 @@ module.exports = class QuizCommand extends Command {
const answer = body[0].answer.toLowerCase().replace(/(<i>|<\/i>)/g, '');
const embed = new RichEmbed()
.setTitle('You have **15** seconds to answer this question:')
.setDescription(`**Category: ${body[0].category.title}**\n${body[0].question}`);
.setDescription(
`**Category: ${body[0].category.title}**
${body[0].question}`
);
await msg.embed(embed);
try {
const collected = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
@@ -37,7 +40,10 @@ module.exports = class QuizCommand extends Command {
return msg.say(`The correct answer is: ${answer}`);
return msg.say(`Perfect! The correct answer is: ${answer}`);
} catch (err) {
return msg.say(`Aw... Too bad, try again next time!\nThe Correct Answer was: ${answer}`);
return msg.say(
`Aw... Too bad, try again next time!
The Correct Answer was: ${answer}`
);
}
} catch (err) {
return msg.say('An Unknown Error Occurred.');
+8 -2
View File
@@ -16,7 +16,13 @@ module.exports = class SlotsCommand extends Command {
const slotTwo = slotThing[Math.floor(Math.random() * slotThing.length)];
const slotThree = slotThing[Math.floor(Math.random() * slotThing.length)];
if (slotOne === slotTwo && slotOne === slotThree)
return msg.say(`${slotOne}|${slotTwo}|${slotThree}\nWow! You won! Great job... er... luck!`);
return msg.say(`${slotOne}|${slotTwo}|${slotThree}\nAww... You lost... Guess it's just bad luck, huh?`);
return msg.say(
`${slotOne}|${slotTwo}|${slotThree}
Wow! You won! Great job... er... luck!`
);
return msg.say(
`${slotOne}|${slotTwo}|${slotThree}
Aww... You lost... Guess it's just bad luck, huh?`
);
}
};
+2 -1
View File
@@ -30,7 +30,8 @@ module.exports = class GuildInfoCommand extends Command {
.addField('**ID:**',
msg.guild.id, true)
.addField('**Created On:**',
`${msg.guild.createdAt}\n${moment.duration(Date.now() - msg.guild.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.`, true)
`${msg.guild.createdAt}
${moment.duration(Date.now() - msg.guild.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.`, true)
.addField('**Default Channel:**',
msg.guild.defaultChannel, true)
.addField('**Region:**',
+9 -2
View File
@@ -50,7 +50,10 @@ module.exports = class BanCommand extends Command {
return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
try {
try {
await member.send(`You were banned from ${msg.guild.name}!\nReason: ${reason}.`);
await member.send(
`You were banned from ${msg.guild.name}!
Reason: ${reason}.`
);
} catch (err) {
await msg.say('Failed to send DM to user.');
}
@@ -63,7 +66,11 @@ module.exports = class BanCommand extends Command {
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF0000)
.setTimestamp()
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Ban\n**Reason:** ${reason}`);
.setDescription(
`**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}`
);
return modlogs.send({embed});
} catch (err) {
return msg.say('An Unknown Error Occurred.');
+9 -2
View File
@@ -47,7 +47,10 @@ module.exports = class KickCommand extends Command {
return msg.say('This member is not kickable. Perhaps they have a higher role than me?');
try {
try {
await member.send(`You were kicked from ${msg.guild.name}!\nReason: ${reason}.`);
await member.send(
`You were kicked from ${msg.guild.name}!
Reason: ${reason}.`
);
} catch (err) {
await msg.say('Failed to send DM.');
}
@@ -59,7 +62,11 @@ module.exports = class KickCommand extends Command {
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFA500)
.setTimestamp()
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Kick\n**Reason:** ${reason}`);
.setDescription(
`**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}`
);
return modlogs.send({embed});
} catch (err) {
return msg.say('An Unknown Error Occurred.');
+9 -2
View File
@@ -49,7 +49,10 @@ module.exports = class SoftbanCommand extends Command {
return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
try {
try {
await member.send(`You were softbanned from ${msg.guild.name}!\nReason: ${reason}.`);
await member.send(
`You were softbanned from ${msg.guild.name}!
Reason: ${reason}.`
);
} catch (err) {
await msg.say('Failed to send DM to user.');
}
@@ -63,7 +66,11 @@ module.exports = class SoftbanCommand extends Command {
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF4500)
.setTimestamp()
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Softban\n**Reason:** ${reason}`);
.setDescription(
`**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}`
);
return modlogs.send({embed});
} catch (err) {
return msg.say('An Unknown Error Occurred.');
+5 -1
View File
@@ -61,7 +61,11 @@ module.exports = class UnbanCommand extends Command {
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0x00AE86)
.setTimestamp()
.setDescription(`**Member:** ${member.tag} (${member.id})\n**Action:** Unban\n**Reason:** ${reason}`);
.setDescription(
`**Member:** ${member.tag} (${member.id})
**Action:** Unban
**Reason:** ${reason}`
);
return modlogs.send({embed});
} catch (err) {
return msg.say('An Unknown Error Occurred.');
+5 -1
View File
@@ -46,7 +46,11 @@ module.exports = class WarnCommand extends Command {
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Warn\n**Reason:** ${reason}`);
.setDescription(
`**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}`
);
return modlogs.send({embed});
} catch (err) {
return msg.say('An Unknown Error Occurred.');
+4 -1
View File
@@ -47,7 +47,10 @@ module.exports = class StrawpollCommand extends Command {
title,
options
});
return msg.say(`${body.title}\nhttp://strawpoll.me/${body.id}`);
return msg.say(
`${body.title}
http://strawpoll.me/${body.id}`
);
} catch (err) {
return msg.say('An Unknown Error Occurred.');
}
+4 -1
View File
@@ -21,6 +21,9 @@ module.exports = class MagicBallCommand extends Command {
run(msg, args) {
const { question } = args;
const answer = answers[Math.floor(Math.random() * answers.length)];
return msg.say(`Question: ${question}\n:8ball: ${answer} :8ball:`);
return msg.say(
`Question: ${question}
:8ball: ${answer} :8ball:`
);
}
};
+8 -1
View File
@@ -24,6 +24,13 @@ module.exports = class CowsayCommand extends Command {
run(msg, args) {
const { text } = args;
return msg.code(null, `< ${text} >\n \\ ^__^\n \\ (oO)\\_______\n (__)\\ )\\/\\\n U ||----w |\n || ||`);
return msg.code(null,
`< ${text} >
\\ ^__^
\\ (oO)\\_______
(__)\\ )\\/\\
U ||----w |
|| ||`
);
}
};
+4 -2
View File
@@ -60,9 +60,11 @@ module.exports = class UserInfoCommand extends Command {
.addField('**ID:**',
user.id, true)
.addField('**Joined Discord On:**',
`${user.createdAt}\n${moment.duration(Date.now() - user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.`, true)
`${user.createdAt}
${moment.duration(Date.now() - user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.`, true)
.addField('**Joined Server On:**',
`${member.joinedAt}\n${moment.duration(Date.now() - member.joinedTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.`, true)
`${member.joinedAt}
${moment.duration(Date.now() - member.joinedTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.`, true)
.addField('**Status:**',
stat, true)
.addField('**Playing:**',
+6 -7
View File
@@ -1,5 +1,4 @@
const { Command } = require('discord.js-commando');
const { stripIndents } = require('common-tags');
const { RichEmbed } = require('discord.js');
module.exports = class HelpCommand extends Command {
@@ -30,18 +29,18 @@ module.exports = class HelpCommand extends Command {
const showAll = command && command.toLowerCase() === 'all';
if (command && !showAll) {
if (commands.length === 1) {
msg.say(stripIndents`
__Command **${commands[0].name}**:__ *${commands[0].description}*
return msg.say(
`__Command **${commands[0].name}**:__ *${commands[0].description}*
${commands[0].guildOnly ? 'Usable Only in Servers' : 'Usable in Server and DM'}
**Format:** ${msg.anyUsage(`${commands[0].name}${commands[0].format ? ` ${commands[0].format}` : ''}`)}
**Aliases:** ${commands[0].aliases.join(', ') || 'None'}
**Group:** ${commands[0].group.name}
${commands[0].details || ''}
`);
${commands[0].details || ''}`
);
} else if (commands.length > 1) {
msg.say('Multiple Commands Found. Please be more specific.');
return msg.say('Multiple Commands Found. Please be more specific.');
} else {
msg.say(
return msg.say(
`Could not identify command. Use ${msg.usage(
null, msg.channel.type === 'dm' ? null : undefined, msg.channel.type === 'dm' ? null : undefined
)} to view a list of commands you can use.`
+6 -1
View File
@@ -12,6 +12,11 @@ module.exports = class InviteCommand extends Command {
async run(msg) {
const invite = await this.client.generateInvite('1345846343');
return msg.say(`Add me to your server with this link:\n${invite}\nOr, come to my server with this link:\n${this.client.options.invite}`);
return msg.say(
`Add me to your server with this link:
${invite}
Or, come to my server with this link:
${this.client.options.invite}`
);
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "17.2.4",
"version": "17.2.5",
"description": "A Discord Bot",
"main": "shardingmanager.js",
"scripts": {