Fix Everything

This commit is contained in:
Daniel Odendahl Jr
2017-06-01 18:31:20 +00:00
parent 66706d9c7b
commit 4e1f83a30f
85 changed files with 721 additions and 851 deletions
+137
View File
@@ -0,0 +1,137 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2017
},
"rules": {
"no-compare-neg-zero": "error",
"no-extra-parens": ["warn", "all", {
"nestedBinaryExpressions": false
}],
"no-template-curly-in-string": "error",
"no-unsafe-negation": "error",
"accessor-pairs": "warn",
"array-callback-return": "error",
"complexity": "warn",
"consistent-return": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"dot-notation": "error",
"eqeqeq": "error",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-lone-blocks": "error",
"no-multi-spaces": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-new": "error",
"no-octal-escape": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": "warn",
"prefer-promise-reject-errors": "error",
"require-await": "warn",
"wrap-iife": "error",
"yoda": "error",
"no-label-var": "error",
"no-shadow": "error",
"no-undef-init": "error",
"callback-return": "error",
"handle-callback-err": "error",
"no-mixed-requires": "error",
"no-new-require": "error",
"no-path-concat": "error",
"no-console": 0,
"array-bracket-spacing": "error",
"block-spacing": "error",
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"capitalized-comments": ["error", "always", { "ignoreConsecutiveComments": true }],
"comma-dangle": "error",
"comma-spacing": "error",
"comma-style": "error",
"computed-property-spacing": "error",
"consistent-this": "error",
"eol-last": "error",
"func-names": "error",
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
"indent": ["error", 4, { "SwitchCase": 1 }],
"key-spacing": "error",
"keyword-spacing": ["error", {
"overrides": {
"if": { "after": true },
"for": { "after": true },
"while": { "after": true },
"catch": { "after": true },
"switch": { "after": true }
}
}],
"max-depth": ["error", 6],
"max-len": ["error", 120, 2],
"max-nested-callbacks": ["error", { "max": 4 }],
"max-statements-per-line": ["error", { "max": 2 }],
"new-cap": "error",
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 5 }],
"no-array-constructor": "error",
"no-bitwise": "warn",
"no-inline-comments": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
"no-new-object": "error",
"no-spaced-func": "error",
"no-trailing-spaces": "error",
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "error",
"object-curly-spacing": ["error", "always"],
"operator-assignment": "error",
"operator-linebreak": ["error", "after"],
"padded-blocks": ["error", "never"],
"quote-props": ["error", "as-needed"],
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
"semi-spacing": "error",
"semi": "error",
"space-before-blocks": "error",
"space-before-function-paren": ["error", "never"],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"template-tag-spacing": "error",
"unicode-bom": "error",
"arrow-body-style": "error",
"arrow-parens": ["error", "always"],
"arrow-spacing": "error",
"no-duplicate-imports": "error",
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"rest-spread-spacing": "error",
"template-curly-spacing": "error",
"yield-star-spacing": "error"
}
}
+1 -3
View File
@@ -1,6 +1,4 @@
const { ShardingManager } = require('discord.js');
const { TOKEN } = process.env;
const Manager = new ShardingManager('./XiaoBot.js', {
token: TOKEN
});
const Manager = new ShardingManager('./XiaoBot.js', { token: TOKEN });
Manager.spawn(2);
+13 -18
View File
@@ -52,14 +52,10 @@ client.on('warn', console.warn);
client.on('commandError', (command, err) => console.error(command.name, err));
client.dispatcher.addInhibitor(msg => {
if (msg.channel.type === 'dm') {
return false;
}
client.dispatcher.addInhibitor((msg) => {
if (msg.channel.type === 'dm') return false;
const role = msg.guild.settings.get('singleRole');
if (!msg.guild.roles.has(role) || msg.member.hasPermission('ADMINISTRATOR')) {
return false;
}
if (!msg.guild.roles.has(role) || msg.member.hasPermission('ADMINISTRATOR')) return false;
if (!msg.member.roles.has(role)) {
return ['singleRole', msg.reply(`Only the ${msg.guild.roles.get(role).name} role may use commands.`)];
} else {
@@ -71,10 +67,9 @@ client.on('message', (msg) => {
if (!msg.guild || !msg.guild.settings.get('inviteGuard')) return;
if (/(discord(\.gg\/|app\.com\/invite\/|\.me\/))/gi.test(msg.content)) {
if (msg.author.bot || msg.member.hasPermission('ADMINISTRATOR')) return;
if (msg.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) {
msg.delete();
return msg.reply('Invites are prohibited from being posted here.');
}
if (!msg.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) return;
msg.delete();
msg.reply('Invites are prohibited from being posted here.');
}
});
@@ -83,13 +78,13 @@ client.on('messageReactionAdd', (reaction, user) => {
const { message } = reaction;
const channel = message.guild.channels.get(message.guild.settings.get('starboard'));
if (!channel) return;
if (!message.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) return;
if (user.id === message.author.id) {
if (message.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) {
reaction.remove(user);
return message.reply('You cannot star your own messages, baka.');
} else return;
reaction.remove(user);
message.reply('You cannot star your own messages, baka.');
return;
}
return client.registry.resolveCommand('random:star').run(message, { id: message.id }, true);
client.registry.resolveCommand('random:star').run(message, { id: message.id }, true);
});
client.on('guildMemberAdd', (member) => {
@@ -103,7 +98,7 @@ client.on('guildMemberAdd', (member) => {
.replace(/(<user>)/gi, member.user.username)
.replace(/(<server>)/gi, member.guild.name)
.replace(/(<mention>)/gi, member);
return channel.send(msg);
channel.send(msg);
});
client.on('guildMemberRemove', (member) => {
@@ -113,7 +108,7 @@ client.on('guildMemberRemove', (member) => {
.replace(/(<user>)/gi, member.user.username)
.replace(/(<server>)/gi, member.guild.name)
.replace(/(<mention>)/gi, member);
return channel.send(msg);
channel.send(msg);
});
client.on('guildCreate', async (guild) => {
+1 -3
View File
@@ -32,9 +32,7 @@ module.exports = class YearsCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(856, 569);
const ctx = canvas.getContext('2d');
+1 -3
View File
@@ -32,9 +32,7 @@ module.exports = class BeautifulCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(500, 532);
const ctx = canvas.getContext('2d');
+1 -3
View File
@@ -32,9 +32,7 @@ module.exports = class BobRossCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(600, 775);
const ctx = canvas.getContext('2d');
+5 -11
View File
@@ -35,20 +35,14 @@ module.exports = class CardCommand extends Command {
async run(msg, args) {
const member = args.member || msg.member;
const avatarURL = member.user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const cardID = Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000;
let rarity;
if (cardID < 5000) {
rarity = 'C';
} else if (cardID < 8000) {
rarity = 'U';
} else {
rarity = 'R';
}
if (cardID < 5000) rarity = 'C';
else if (cardID < 8000) rarity = 'U';
else rarity = 'R';
const Image = Canvas.Image;
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' });
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' }); // eslint-disable-line max-len
const canvas = new Canvas(390, 544);
const ctx = canvas.getContext('2d');
const base = new Image();
+1 -3
View File
@@ -31,9 +31,7 @@ module.exports = class ChallengerCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(500, 500);
const ctx = canvas.getContext('2d');
+1 -3
View File
@@ -31,9 +31,7 @@ module.exports = class DexterCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(744, 554);
const ctx = canvas.getContext('2d');
+1 -3
View File
@@ -29,9 +29,7 @@ module.exports = class GreyscaleCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(256, 256);
const ctx = canvas.getContext('2d');
+1 -3
View File
@@ -28,9 +28,7 @@ module.exports = class InvertCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(256, 256);
const ctx = canvas.getContext('2d');
+1 -3
View File
@@ -32,9 +32,7 @@ module.exports = class RIPCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(507, 338);
const ctx = canvas.getContext('2d');
+1 -3
View File
@@ -31,9 +31,7 @@ module.exports = class SimbaCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(500, 281);
const ctx = canvas.getContext('2d');
+2 -4
View File
@@ -31,11 +31,9 @@ module.exports = class SteamCardCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 512);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) 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' });
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' }); // eslint-disable-line max-len
const canvas = new Canvas(494, 568);
const ctx = canvas.getContext('2d');
const base = new Image();
+2 -6
View File
@@ -31,9 +31,7 @@ module.exports = class TriggeredCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 512);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(320, 371);
const ctx = canvas.getContext('2d');
@@ -45,9 +43,7 @@ module.exports = class TriggeredCommand extends Command {
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]);
}
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);
};
+1 -3
View File
@@ -31,9 +31,7 @@ module.exports = class WantedCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 512);
if (!avatarURL) {
return msg.say('The User Provided has No Avatar.');
}
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const Image = Canvas.Image;
const canvas = new Canvas(741, 1000);
const ctx = canvas.getContext('2d');
+70 -118
View File
@@ -22,17 +22,11 @@ module.exports = class BattleCommand extends Command {
this.fighting = new Set();
}
async run(msg, args) {
async run(msg, args) { // eslint-disable-line complexity
const { opponent } = args;
if (opponent.bot) {
return msg.say('Bots cannot be fought.');
}
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.');
}
if (opponent.bot) return msg.say('Bots cannot be fought.');
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);
await msg.say(`**${opponent.username}**, do you accept this challenge? **__Y__es** or **No**?`);
try {
@@ -41,117 +35,75 @@ module.exports = class BattleCommand extends Command {
time: 15000,
errors: ['time']
});
if (['yes', 'y'].includes(verify.first().content.toLowerCase())) {
let userHP = 500;
let oppoHP = 500;
let userTurn = true;
let guard = false;
let userCure = true;
let oppoCure = true;
while (userHP > 0 && oppoHP > 0) {
const username = userTurn ? msg.author.username : opponent.username;
await msg.say(stripIndents`
**${username}**, do you **fight**, **guard**, **special**, **cure**, or **run**?
**${msg.author.username}**: ${userHP}HP
**${opponent.username}**: ${oppoHP}HP
`);
try {
const turn = await msg.channel.awaitMessages((res) => res.author.id === (userTurn ? msg.author.id : opponent.id), {
max: 1,
time: 15000,
errors: ['time']
});
const choice = turn.first().content.toLowerCase();
if (choice === 'fight') {
const damage = Math.floor(Math.random() * (guard ? 10 : 100)) + 1;
await msg.say(`**${username}** deals **${damage}** damage!`);
if (userTurn) {
oppoHP = oppoHP - damage;
userTurn = false;
} else {
userHP = userHP - damage;
userTurn = true;
}
if (guard) {
guard = false;
}
} else if (choice === 'guard') {
await msg.say(`**${username}** guards!`);
guard = true;
if (userTurn) {
userTurn = false;
} else {
userTurn = true;
}
} else if (choice === 'special') {
const hit = Math.floor(Math.random() * 4) + 1;
if (hit === 1) {
const damage = Math.floor(Math.random() * ((guard ? 300 : 150) - 100 + 1) + 100);
await msg.say(`**${username}** deals **${damage}** damage!`);
if (userTurn) {
oppoHP = oppoHP - damage;
userTurn = false;
} else {
userHP = userHP - damage;
userTurn = true;
}
if (guard) {
guard = false;
}
} else {
await msg.say(`**${username}**'s attack missed!`);
if (userTurn) {
userTurn = false;
} else {
userTurn = true;
}
if (guard) {
guard = false;
}
}
} else if (choice === 'cure') {
if (userTurn ? userCure : oppoCure) {
await msg.say(`**${username}** regains **250** health!`);
if (userTurn) {
userHP = userHP + 250;
userCure = false;
userTurn = false;
} else {
oppoHP = oppoHP + 250;
oppoCure = false;
userTurn = true;
}
if (guard) {
guard = false;
}
} else {
await msg.say('You have already cured!');
}
} else if (choice === 'run') {
await msg.say(`**${username}** flees!`);
if (userTurn) {
userHP = 0;
} else {
oppoHP = 0;
}
} else {
await msg.say('I do not understand what you want to do.');
}
} catch (err) {
await msg.say('Time!');
break;
}
}
this.fighting.delete(msg.guild.id);
return msg.say(stripIndents`
The match is over!
**Winner: ${userHP > oppoHP ? `${msg.author.username}** (${userHP}HP)` : `${opponent.username}** (${oppoHP}HP)`}
**Loser: ${userHP > oppoHP ? `${opponent.username}** (${oppoHP}HP)` : `${msg.author.username}** (${userHP}HP)`}
`);
} else {
if (!['yes', 'y'].includes(verify.first().content.toLowerCase())) {
this.fighting.delete(msg.guild.id);
return msg.say('Guess that was a no then...');
}
let userHP = 500;
let oppoHP = 500;
let userTurn = false;
let guard = false;
const reset = () => {
if (userTurn) userTurn = false;
else userTurn = true;
if (guard) guard = false;
};
const dealDamage = (damage) => {
if (userTurn) userHP += damage;
else oppoHP += damage;
};
while (userHP > 0 && oppoHP > 0) { // eslint-disable-line no-unmodified-loop-condition
const username = userTurn ? msg.author.username : opponent.username;
const id = userTurn ? msg.author.id : opponent.id;
await msg.say(stripIndents`
**${username}**, do you **fight**, **guard**, **special**, or **run**?
**${msg.author.username}**: ${userHP}HP
**${opponent.username}**: ${oppoHP}HP
`);
try {
const turn = await msg.channel.awaitMessages((res) => res.author.id === id, {
max: 1,
time: 15000,
errors: ['time']
});
const choice = turn.first().content.toLowerCase();
if (choice === 'fight') {
const damage = Math.floor(Math.random() * (guard ? 10 : 100)) + 1;
await msg.say(`**${username}** deals **${damage}** damage!`);
dealDamage(damage);
reset();
} else if (choice === 'guard') {
await msg.say(`**${username}** guards!`);
reset();
guard = true;
} else if (choice === 'special') {
const hit = Math.floor(Math.random() * 4) + 1;
if (hit === 1) {
const damage = Math.floor(Math.random() * ((guard ? 300 : 150) - 100 + 1) + 100);
await msg.say(`**${username}** deals **${damage}** damage!`);
dealDamage(damage);
reset();
} else {
await msg.say(`**${username}**'s attack missed!`);
reset();
}
} else if (choice === 'run') {
await msg.say(`**${username}** flees!`);
dealDamage(500 - (userTurn ? userHP : oppoHP));
} else {
await msg.say('I do not understand what you want to do.');
}
} catch (err) {
await msg.say('Time!');
break;
}
}
this.fighting.delete(msg.guild.id);
return msg.say(stripIndents`
The match is over!
**Winner:** ${userHP > oppoHP ? msg.author.username : opponent.username}
**Loser:** ${userHP > oppoHP ? opponent.username : msg.author.username}
`);
} catch (err) {
this.fighting.delete(msg.guild.id);
return msg.say('Looks like they declined...');
+2 -5
View File
@@ -12,10 +12,7 @@ module.exports = class LotteryCommand extends Command {
run(msg) {
const lottery = Math.floor(Math.random() * 100) + 1;
if (lottery === 1) {
return msg.say(`Wow ${msg.author.username}! You actually won! Great job!`);
} else {
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!`);
else return msg.say(`Nope, sorry ${msg.author.username}, you lost.`);
}
};
+8 -12
View File
@@ -17,11 +17,8 @@ module.exports = class MathGameCommand extends Command {
prompt: `What should the difficulty of the game be? One of: ${difficulties.join(', ')}`,
type: 'string',
validate: (difficulty) => {
if (difficulties.includes(difficulty.toLowerCase())) {
return true;
} else {
return `The difficulty must be one of: ${difficulties.join(', ')}`;
}
if (difficulties.includes(difficulty.toLowerCase())) return true;
else return `The difficulty must be one of: ${difficulties.join(', ')}`;
},
parse: (difficulty) => difficulty.toLowerCase()
}
@@ -32,8 +29,10 @@ module.exports = class MathGameCommand extends Command {
async run(msg, args) {
const { difficulty } = args;
const operation = operations[Math.floor(Math.random() * operations.length)];
const value = maxValues[difficulty];
const expression = `${Math.floor(Math.random() * value) + 1} ${operation} ${Math.floor(Math.random() * value) + 1}`;
const maxValue = maxValues[difficulty];
const value1 = Math.floor(Math.random() * maxValue) + 1;
const value2 = Math.floor(Math.random() * maxValue) + 1;
const expression = `${value1} ${operation} ${value2}`;
const answer = math.eval(expression).toString();
const embed = new RichEmbed()
.setTitle('You have 10 seconds to answer:')
@@ -45,11 +44,8 @@ module.exports = class MathGameCommand extends Command {
time: 10000,
errors: ['time']
});
if (collected.first().content !== answer) {
return msg.say(`Nope, sorry, it's ${answer}.`);
} else {
return msg.say('Nice job! 10/10! You deserve some cake!');
}
if (collected.first().content !== answer) return msg.say(`Nope, sorry, it's ${answer}.`);
else return msg.say('Nice job! 10/10! You deserve some cake!');
} catch (err) {
return msg.say(`Time! It was ${answer}, sorry!`);
}
+2 -5
View File
@@ -37,11 +37,8 @@ module.exports = class QuizCommand extends Command {
time: 15000,
errors: ['time']
});
if (collected.first().content.toLowerCase() !== answer) {
return msg.say(`Nope, sorry, it's ${answer}.`);
} else {
return msg.say('Nice job! 10/10! You deserve some cake!');
}
if (collected.first().content.toLowerCase() !== answer) return msg.say(`Nope, sorry, it's ${answer}.`);
else return msg.say('Nice job! 10/10! You deserve some cake!');
} catch (err) {
return msg.say(`Time! It was ${answer}, sorry!`);
}
+11 -28
View File
@@ -14,13 +14,6 @@ module.exports = class RockPaperScissorsCommand extends Command {
key: 'choice',
prompt: '`Rock`, `Paper`, or `Scissors`?',
type: 'string',
validate: (choice) => {
if (choices.includes(choice.toLowerCase())) {
return true;
} else {
return 'Please enter either `rock`, `paper`, or `scissors`.';
}
},
parse: (choice) => choice.toLowerCase()
}
]
@@ -31,29 +24,19 @@ module.exports = class RockPaperScissorsCommand extends Command {
const { choice } = args;
const response = choices[Math.floor(Math.random() * choices.length)];
if (choice === 'rock') {
if (response === 'rock') {
return msg.say('Rock! Aw... A tie...');
} else if (response === 'paper') {
return msg.say('Paper! Yes! I win!');
} else if (response === 'scissors') {
return msg.say('Scissors! Aw... I lose...');
}
if (response === 'rock') return msg.say('Rock! Aw... A tie...');
else if (response === 'paper') return msg.say('Paper! Yes! I win!');
else return msg.say('Scissors! Aw... I lose...');
} else if (choice === 'paper') {
if (response === 'rock') {
return msg.say('Rock! Aw... I lose...');
} else if (response === 'paper') {
return msg.say('Paper! Aw... A tie...');
} else if (response === 'scissors') {
return msg.say('Scissors! Yes! I win!');
}
if (response === 'rock') return msg.say('Rock! Aw... I lose...');
else if (response === 'paper') return msg.say('Paper! Aw... A tie...');
else return msg.say('Scissors! Yes! I win!');
} else if (choice === 'scissors') {
if (response === 'rock') {
return msg.say('Rock! Yes! I win!');
} else if (response === 'paper') {
return msg.say('Paper! Aw... I lose...');
} else if (response === 'scissors') {
return msg.say('Scissors! Aw... A tie...');
}
if (response === 'rock') return msg.say('Rock! Yes! I win!');
else if (response === 'paper') return msg.say('Paper! Aw... I lose...');
else return msg.say('Scissors! Aw... A tie...');
} else {
return msg.say('I win by default, you little cheater.');
}
}
};
+4 -10
View File
@@ -16,11 +16,8 @@ module.exports = class TypingGameCommand extends Command {
prompt: `What should the difficulty of the game be? One of: ${difficulties.join(', ')}`,
type: 'string',
validate: (difficulty) => {
if (difficulties.includes(difficulty.toLowerCase())) {
return true;
} else {
return `The difficulty must be one of: ${difficulties.join(', ')}`;
}
if (difficulties.includes(difficulty.toLowerCase())) return true;
else return `The difficulty must be one of: ${difficulties.join(', ')}`;
},
parse: (difficulty) => difficulty.toLowerCase()
}
@@ -42,11 +39,8 @@ module.exports = class TypingGameCommand extends Command {
time: time,
errors: ['time']
});
if (collected.first().content !== sentence) {
return msg.say('Nope, sorry!');
} else {
return msg.say('Nice job! 10/10! You deserve some cake!');
}
if (collected.first().content !== sentence) return msg.say('Nope, sorry!');
else return msg.say('Nice job! 10/10! You deserve some cake!');
} catch (err) {
return msg.say('Time! Sorry!');
}
+3 -5
View File
@@ -12,10 +12,8 @@ module.exports = class EmojiCommand extends Command {
}
run(msg) {
const emoji = msg.guild.emojis;
if (!emoji.size) {
return msg.say('You have no Custom Emoji.');
}
return msg.say(emoji.map((e) => e).join(''));
const emojis = msg.guild.emojis;
if (!emojis.size) return msg.say('You have no Custom Emoji.');
return msg.say(emojis.map((emoji) => emoji).join(''));
}
};
+33 -41
View File
@@ -24,11 +24,8 @@ module.exports = class BanCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: (reason) => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
if (reason.length < 140) return true;
else return 'Reason must be under 140 characters.';
}
}
]
@@ -38,9 +35,7 @@ module.exports = class BanCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
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 {
await msg.say(`Are you sure you want to ban ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
@@ -48,43 +43,40 @@ module.exports = class BanCommand extends Command {
time: 15000,
errors: ['time']
});
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`
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Ban.');
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}
**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.');
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Ban.');
+31 -41
View File
@@ -23,12 +23,9 @@ module.exports = class KickCommand extends Command {
key: 'reason',
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
validate: (reason) => {
if (reason.length < 140) return true;
else return 'Reason must be under 140 characters.';
}
}
]
@@ -38,9 +35,7 @@ module.exports = class KickCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
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 {
await msg.say(`Are you sure you want to kick ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
@@ -48,42 +43,37 @@ module.exports = class KickCommand extends Command {
time: 15000,
errors: ['time']
});
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`
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Kick.');
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}
**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.');
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Kick.');
+3 -6
View File
@@ -18,11 +18,8 @@ module.exports = class LockdownCommand extends Command {
type: 'string',
default: 'start',
validate: (type) => {
if (['start', 'stop'].includes(type.toLowerCase())) {
return true;
} else {
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()
}
@@ -38,7 +35,7 @@ module.exports = class LockdownCommand extends Command {
Lockdown Started, users without Administrator can no longer post messages.
Please use \`lockdown stop\` to end the lockdown.
`);
} else if (type === 'stop') {
} else {
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: null });
return msg.say('Lockdown Ended.');
}
+2 -5
View File
@@ -21,11 +21,8 @@ module.exports = class PruneCommand extends Command {
prompt: 'How many messages do you want to delete? Limit of up to 99.',
type: 'integer',
validate: (count) => {
if (count < 100 && count > 0) {
return true;
} else {
return 'Invalid Count. Count must be from 1-99.';
}
if (count < 100 && count > 0) return true;
else return 'Count must be from 1-99.';
}
}
]
+34 -42
View File
@@ -24,11 +24,8 @@ module.exports = class SoftbanCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: (reason) => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
if (reason.length < 140) return true;
else return 'Reason must be under 140 characters.';
}
}
]
@@ -38,9 +35,7 @@ module.exports = class SoftbanCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
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 bannable. Perhaps they have a higher role than me?');
try {
await msg.say(`Are you sure you want to softban ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
@@ -48,44 +43,41 @@ module.exports = class SoftbanCommand extends Command {
time: 15000,
errors: ['time']
});
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`
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Softban.');
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}
**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.');
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Softban.');
+22 -30
View File
@@ -24,11 +24,8 @@ module.exports = class UnbanCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: (reason) => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
if (reason.length < 140) return true;
else return 'Reason must be under 140 characters.';
}
}
]
@@ -39,9 +36,7 @@ module.exports = class UnbanCommand extends Command {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
const { id, reason } = args;
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;
try {
await msg.say(`Are you sure you want to unban ${member.tag} (${member.id})?`);
@@ -50,32 +45,29 @@ module.exports = class UnbanCommand extends Command {
time: 15000,
errors: ['time']
});
if (['y', 'yes'].includes(collected.first().content.toLowerCase())) {
await msg.guild.unban(member, `${msg.author.tag}: ${reason}`);
await msg.say(`Successfully unbanned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user.has('SEND_MESSAGES'))) {
return msg.say('Could not log the unban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Unban.');
await msg.guild.unban(member, `${msg.author.tag}: ${reason}`);
await msg.say(`Successfully unbanned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user.has('SEND_MESSAGES'))) {
return msg.say('Could not log the unban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
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}
**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.');
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Unban.');
+28 -34
View File
@@ -23,11 +23,8 @@ module.exports = class WarnCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: (reason) => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
if (reason.length < 140) return true;
else return 'Invalid Reason. Reason must be under 140 characters.';
}
}
]
@@ -44,39 +41,36 @@ module.exports = class WarnCommand extends Command {
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`
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Warn.');
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}
**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.');
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Warn.');
+5 -13
View File
@@ -16,11 +16,8 @@ module.exports = class CurrencyCommand extends Command {
prompt: 'What currency code do you want to use as the base?',
type: 'string',
validate: (base) => {
if (codes.includes(base.toUpperCase())) {
return true;
} else {
return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.';
}
if (codes.includes(base.toUpperCase())) return true;
else return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.';
},
parse: (base) => base.toUpperCase()
},
@@ -29,11 +26,8 @@ module.exports = class CurrencyCommand extends Command {
prompt: 'What currency code do you want to convert to?',
type: 'string',
validate: (to) => {
if (codes.includes(to.toUpperCase())) {
return true;
} else {
return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.';
}
if (codes.includes(to.toUpperCase())) return true;
else return 'Invalid Currency Code. Use `help currency` to view a list of currency codes.';
},
parse: (to) => to.toUpperCase()
},
@@ -48,9 +42,7 @@ module.exports = class CurrencyCommand extends Command {
async run(msg, 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.`);
const { body } = await snekfetch
.get('http://api.fixer.io/latest')
.query({
+12 -29
View File
@@ -13,11 +13,8 @@ module.exports = class TemperatureCommand extends Command {
prompt: 'What temperature unit do you want to use as the base?',
type: 'string',
validate: (base) => {
if (['celsius', 'fahrenheit', 'kelvin'].includes(base.toLowerCase())) {
return true;
} else {
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
}
if (['celsius', 'fahrenheit', 'kelvin'].includes(base.toLowerCase())) return true;
else return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
},
parse: (base) => base.toLowerCase()
},
@@ -26,11 +23,8 @@ module.exports = class TemperatureCommand extends Command {
prompt: 'What temperature unit do you want to convert to?',
type: 'string',
validate: (to) => {
if (['celsius', 'fahrenheit', 'kelvin'].includes(to.toLowerCase())) {
return true;
} else {
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
}
if (['celsius', 'fahrenheit', 'kelvin'].includes(to.toLowerCase())) return true;
else return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
},
parse: (to) => to.toLowerCase()
},
@@ -45,27 +39,16 @@ module.exports = class TemperatureCommand extends Command {
run(msg, 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 (to === 'fahrenheit') {
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.`);
}
if (to === 'fahrenheit') return msg.say(`${amount}°C is ${(amount * 1.8) + 32}°F.`);
else return msg.say(`${amount}°C is ${amount + 273.15}°K.`);
} else if (base === 'fahrenheit') {
if (to === 'celsius') {
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') {
if (to === 'celsius') {
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.`);
}
if (to === 'celsius') return msg.say(`${amount}°F is ${(amount - 32) / 1.8}°C.`);
else return msg.say(`${amount}°F is ${(amount + 459.67) * (5 / 9)}°K.`);
} else {
if (to === 'celsius') return msg.say(`${amount}°K is ${amount - 273.15}°C.`);
else return msg.say(`${amount}°K is ${(amount * 1.8) - 459.67}°F.`);
}
}
};
+2 -5
View File
@@ -15,11 +15,8 @@ module.exports = class EasterEggCommand extends Command {
prompt: 'What easter egg do you want to view?',
type: 'string',
validate: (tag) => {
if (eastereggs[tag.toLowerCase()]) {
return true;
} else {
return 'Nope, that\'s not a valid easter egg. Try again!';
}
if (eastereggs[tag.toLowerCase()]) return true;
else return 'Nope, that\'s not a valid easter egg. Try again!';
},
parse: (tag) => tag.toLowerCase()
}
+2 -5
View File
@@ -18,11 +18,8 @@ module.exports = class HoroscopeCommand extends Command {
prompt: 'Which sign would you like to get the horoscope for?',
type: 'string',
validate: (sign) => {
if (signs.includes(sign.toLowerCase())) {
return true;
} else {
return 'Invalid sign. Use `help horoscope` for a list of signs.';
}
if (signs.includes(sign.toLowerCase())) return true;
else return 'Invalid sign. Use `help horoscope` for a list of signs.';
},
parse: (sign) => sign.toLowerCase()
}
+2 -5
View File
@@ -16,11 +16,8 @@ module.exports = class MemeCommand extends Command {
prompt: 'What meme type do you want to use?',
type: 'string',
validate: (type) => {
if (codes.includes(type.toLowerCase())) {
return true;
} else {
return 'Invalid meme type. Use `help meme` to view a list of meme types.';
}
if (codes.includes(type.toLowerCase())) return true;
else return 'Invalid meme type. Use `help meme` to view a list of meme types.';
},
parse: (type) => type.toLowerCase()
},
+8 -16
View File
@@ -23,11 +23,8 @@ module.exports = class SoundboardCommand extends Command {
prompt: 'What sound would you like to play?',
type: 'string',
validate: (sound) => {
if (names.includes(sound.toLowerCase())) {
return true;
} else {
return 'Invalid Sound. Use `help soundboard` for a list of sounds.';
}
if (names.includes(sound.toLowerCase())) return true;
else return 'Invalid Sound. Use `help soundboard` for a list of sounds.';
},
parse: (sound) => sound.toLowerCase()
}
@@ -37,17 +34,12 @@ module.exports = class SoundboardCommand extends Command {
async run(msg, args) {
const voiceChannel = msg.member.voiceChannel;
if (!voiceChannel) {
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.');
} else if (!voiceChannel.permissionsFor(this.client.user).has('SPEAK')) {
return msg.say('This Command requires the `SPEAK` Permission.');
} else if (!voiceChannel.joinable) {
return msg.say('This Voice Channel is not joinable.');
} else if (this.client.voiceConnections.get(voiceChannel.guild.id)) {
return msg.say('I am already playing a sound.');
if (!voiceChannel) return msg.say('Please enter a Voice Channel first.');
if (!voiceChannel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK'])) {
return msg.say('Missing the `CONNECT` or `SPEAK` Permission for the Voice Channel.');
}
if (!voiceChannel.joinable) return msg.say('This Voice Channel is not joinable.');
if (this.client.voiceConnections.get(voiceChannel.guild.id)) return msg.say('I am already playing a sound.');
const { sound } = args;
const connection = await voiceChannel.join();
msg.react('🔊');
@@ -55,7 +47,7 @@ module.exports = class SoundboardCommand extends Command {
dispatcher.on('end', () => {
voiceChannel.leave();
msg.react('✅');
return null;
});
return null;
}
};
+2 -5
View File
@@ -25,11 +25,8 @@ module.exports = class StarCommand extends Command {
async run(msg, args, reaction) {
const { id } = args;
const channel = msg.guild.channels.get(msg.guild.settings.get('starboard'));
if (!channel || this.starred.includes(id)) {
return null;
} else if (!channel.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('I do not have Permission to send the message.');
}
if (!channel || this.starred.includes(id)) return null;
if (!channel.permissionsFor(this.client.user).has('SEND_MESSAGES')) return null;
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.');
+6 -16
View File
@@ -1,5 +1,4 @@
const Command = require('../../structures/Command');
const { FriendlyError } = require('discord.js-commando');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
@@ -16,11 +15,8 @@ module.exports = class StrawpollCommand extends Command {
prompt: 'What would you like the title of the Strawpoll to be?',
type: 'string',
validate: (title) => {
if (title.length < 200) {
return true;
} else {
return 'Invalid Title. Title must be under 200 characters.';
}
if (title.length < 200) return true;
else return 'Title must be under 200 characters.';
}
},
{
@@ -29,11 +25,8 @@ module.exports = class StrawpollCommand extends Command {
type: 'string',
infinite: true,
validate: (choice) => {
if (choice.length < 160) {
return true;
} else {
return 'Invalid Choice. Choices must be under 140 characters each.';
}
if (choice.length < 160) return true;
else return 'Choices must be under 140 characters each.';
}
}
]
@@ -42,11 +35,8 @@ module.exports = class StrawpollCommand extends Command {
async run(msg, args) {
const { title, options } = args;
if (options.length < 2) {
throw new FriendlyError('You provided less than two choices.');
} else if (options.length > 31) {
throw new FriendlyError('You provided more than thirty choices.');
}
if (options.length < 2) return msg.say('You provided less than two choices.');
if (options.length > 31) return msg.say('You provided more than thirty choices.');
const { body } = await snekfetch
.post('https://strawpoll.me/api/v2/polls')
.send({ title, options });
+2 -5
View File
@@ -18,11 +18,8 @@ module.exports = class XKCDCommand extends Command {
type: 'string',
default: 'random',
validate: (type) => {
if (['today', 'random'].includes(type.toLowerCase())) {
return true;
} else {
return 'Please enter either `today` or `random`';
}
if (['today', 'random'].includes(type.toLowerCase())) return true;
else return 'Please enter either `today` or `random`';
}
}
]
+3 -6
View File
@@ -14,11 +14,8 @@ module.exports = class RandomNameCommand extends Command {
prompt: 'Which gender do you want to generate a name for?',
type: 'string',
validate: (gender) => {
if (['male', 'female'].includes(gender.toLowerCase())) {
return true;
} else {
return 'Please enter either `male` or `female`.';
}
if (['male', 'female'].includes(gender.toLowerCase())) return true;
else return 'Please enter either `male` or `female`.';
},
parse: (gender) => gender.toLowerCase()
}
@@ -32,7 +29,7 @@ module.exports = class RandomNameCommand extends Command {
if (gender === 'male') {
const name = maleNames[Math.floor(Math.random() * maleNames.length)];
return msg.say(`${name} ${lastName}`);
} else if (gender === 'female') {
} else {
const name = femaleNames[Math.floor(Math.random() * femaleNames.length)];
return msg.say(`${name} ${lastName}`);
}
+1 -3
View File
@@ -29,9 +29,7 @@ module.exports = class AnimeCommand extends Command {
try {
const { text } = await snekfetch
.get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/anime/search.xml`)
.query({
q: query
});
.query({ q: query });
const { anime } = await xml.parseStringAsync(text);
const synopsis = cleanXML(anime.entry[0].synopsis[0].substr(0, 2000));
const embed = new RichEmbed()
+1 -3
View File
@@ -26,9 +26,7 @@ module.exports = class BotSearchCommand extends Command {
try {
const { body } = await snekfetch
.get(`https://bots.discord.pw/api/bots/${bot.id}`)
.set({
Authorization: DBOTS_KEY
});
.set({ Authorization: DBOTS_KEY });
const embed = new RichEmbed()
.setColor(0x9797FF)
.setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg')
+1 -3
View File
@@ -35,9 +35,7 @@ module.exports = class BulbapediaCommand extends Command {
redirects: '',
formatversion: 2
});
if (body.query.pages[0].missing) {
return msg.say('No Results.');
}
if (body.query.pages[0].missing) return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0x3E7614)
.setTitle(body.query.pages[0].title)
+6 -4
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
module.exports = class DanbooruCommand extends Command {
@@ -28,9 +29,10 @@ module.exports = class DanbooruCommand extends Command {
tags: `${query ? `${query} ` : ''}order:random`,
limit: 1
});
if (!body.length || !body[0].file_url) {
return msg.say('No Results');
}
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https://danbooru.donmai.us${body[0].file_url}`);
if (!body.length || !body[0].file_url) return msg.say('No Results');
return msg.say(stripIndents`
${query ? `Result for ${query}:` : 'Random Image:'}
https://danbooru.donmai.us${body[0].file_url}
`);
}
};
+1 -3
View File
@@ -32,9 +32,7 @@ module.exports = class DefineCommand extends Command {
useCanonical: false,
api_key: WORDNIK_KEY
});
if (!body.length) {
return msg.say('No Results.');
}
if (!body.length) return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0x9797FF)
.setTitle(body[0].word)
+3 -6
View File
@@ -17,11 +17,8 @@ module.exports = class DiscrimCommand extends Command {
type: 'string',
default: '',
validate: (discrim) => {
if (/[0-9]+$/g.test(discrim) && discrim.length === 4) {
return true;
} else {
return 'Invalid Discriminator.';
}
if (/[0-9]+$/g.test(discrim) && discrim.length === 4) return true;
else return 'Invalid Discriminator.';
}
}
]
@@ -30,7 +27,7 @@ module.exports = class DiscrimCommand extends Command {
run(msg, args) {
const discrim = args.discrim || msg.author.discriminator;
const users = this.client.users.filter((u) => u.discriminator === discrim).map((u) => u.username);
const users = this.client.users.filter((user) => user.discriminator === discrim).map((user) => user.username);
const embed = new RichEmbed()
.setTitle(`${users.length} Users with the discriminator: ${discrim}`)
.setDescription(users.join(', '));
+38 -11
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const { RichEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
@@ -25,12 +26,10 @@ module.exports = class ForecastCommand extends Command {
const { body } = await snekfetch
.get('https://query.yahooapis.com/v1/public/yql')
.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}")`, // eslint-disable-line max-len
format: 'json'
});
if (!body.query.count) {
return msg.say('Location Not Found.');
}
if (!body.query.count) return msg.say('Location Not Found.');
const forecasts = body.query.results.channel.item.forecast;
const embed = new RichEmbed()
.setColor(0x0000FF)
@@ -38,19 +37,47 @@ module.exports = class ForecastCommand extends Command {
.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}`)
stripIndents`
**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}`)
stripIndents`
**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}`)
stripIndents`
**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}`)
stripIndents`
**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}`)
stripIndents`
**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}`)
stripIndents`
**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}`);
stripIndents`
**High:** ${forecasts[6].high}°F
**Low:** ${forecasts[6].low}°F
**Condition:** ${forecasts[6].text}
`);
return msg.embed(embed);
}
};
+16 -14
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js'));
@@ -23,19 +24,20 @@ module.exports = class GelbooruCommand extends Command {
async run(msg, args) {
const { query } = args;
const { text } = await snekfetch
.get('https://gelbooru.com/index.php')
.query({
page: 'dapi',
s: 'post',
q: 'index',
tags: query,
limit: 1
});
const { posts } = await xml.parseStringAsync(text);
if (posts.$.count === '0') {
return msg.say('No Results.');
}
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
const { text } = await snekfetch
.get('https://gelbooru.com/index.php')
.query({
page: 'dapi',
s: 'post',
q: 'index',
tags: query,
limit: 1
});
const { posts } = await xml.parseStringAsync(text);
if (posts.$.count === '0') return msg.say('No Results.');
return msg.say(stripIndents`
Result for ${query}:
https:${posts.post[0].$.file_url}
`);
}
};
+1 -3
View File
@@ -28,9 +28,7 @@ module.exports = class GiphyCommand extends Command {
api_key: GIPHY_KEY,
rating: msg.channel.nsfw ? 'r' : 'pg'
});
if (!body.data.length) {
return msg.say('No Results.');
}
if (!body.data.length) return msg.say('No Results.');
const random = Math.floor(Math.random() * body.data.length);
return msg.say(body.data[random].images.original.url);
}
+2 -6
View File
@@ -25,14 +25,10 @@ module.exports = class GoogleCommand extends Command {
const message = await msg.say('Searching...');
const { text } = await snekfetch
.get('https://www.google.com/search')
.query({
q: query
});
.query({ q: query });
const $ = cheerio.load(text);
let href = $('.r').first().find('a').first().attr('href');
if (!href) {
return msg.say('No Results.');
}
if (!href) return msg.say('No Results.');
href = querystring.parse(href.replace('/url?', ''));
return message.edit(href.q);
}
+6 -4
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
module.exports = class KonachanCommand extends Command {
@@ -28,9 +29,10 @@ module.exports = class KonachanCommand extends Command {
tags: `${query ? `${query} ` : ''}order:random`,
limit: 1
});
if (!body.length) {
return msg.say('No Results.');
}
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https:${body[0].file_url}`);
if (!body.length) return msg.say('No Results.');
return msg.say(stripIndents`
${query ? `Result for ${query}:` : 'Random Image:'}
https:${body[0].file_url}
`);
}
};
+1 -3
View File
@@ -29,9 +29,7 @@ module.exports = class MangaCommand extends Command {
try {
const { text } = await snekfetch
.get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/manga/search.xml`)
.query({
q: query
});
.query({ q: query });
const { manga } = await xml.parseStringAsync(text);
const synopsis = cleanXML(manga.entry[0].synopsis[0].substr(0, 2000));
const embed = new RichEmbed()
+2 -5
View File
@@ -17,11 +17,8 @@ module.exports = class MapCommand extends Command {
prompt: 'What would you like the zoom level for the map to be? Limit 1-20.',
type: 'integer',
validate: (zoom) => {
if (zoom < 21 && zoom > 0) {
return true;
} else {
return 'Please enter a zoom value from 1-20';
}
if (zoom < 21 && zoom > 0) return true;
else return 'Please enter a zoom value from 1-20';
}
},
{
+1 -3
View File
@@ -30,9 +30,7 @@ module.exports = class NeopetCommand extends Command {
});
const $ = cheerio.load(text);
const link = $('textarea').first().text();
if (!link.includes('cp')) {
return msg.say('Invalid Pet Name.');
}
if (!link.includes('cp')) return msg.say('Invalid Pet Name.');
return msg.say(link);
}
};
+1 -3
View File
@@ -30,9 +30,7 @@ module.exports = class OsuCommand extends Command {
u: query,
type: 'string'
});
if (!body.length) {
return msg.say('No Results.');
}
if (!body.length) return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0xFF66AA)
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
+6 -4
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const snekfetch = require('snekfetch');
const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js'));
@@ -33,9 +34,10 @@ module.exports = class Rule34Command extends Command {
limit: 1
});
const { posts } = await xml.parseStringAsync(text);
if (posts.$.count === '0') {
return msg.say('No Results.');
}
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
if (posts.$.count === '0') return msg.say('No Results.');
return msg.say(stripIndents`
Result for ${query}:
https:${posts.post[0].$.file_url}
`);
}
};
+1 -3
View File
@@ -29,9 +29,7 @@ module.exports = class SoundCloudCommand extends Command {
q: query,
client_id: SOUNDCLOUD_KEY
});
if (!body.length) {
return msg.say('No Results.');
}
if (!body.length) return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0xF15A22)
.setAuthor('SoundCloud', 'https://i.imgur.com/lFIz7RU.png')
+2 -6
View File
@@ -24,12 +24,8 @@ module.exports = class UrbanCommand extends Command {
const { query } = args;
const { body } = await snekfetch
.get('http://api.urbandictionary.com/v0/define')
.query({
term: query
});
if (!body.list.length) {
return msg.say('No Results.');
}
.query({ term: query });
if (!body.list.length) return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0x32a8f0)
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
+2 -6
View File
@@ -30,12 +30,8 @@ module.exports = class WattpadCommand extends Command {
query,
limit: 1
})
.set({
Authorization: `Basic ${WATTPAD_KEY}`
});
if (!body.stories.length) {
return msg.say('No Results.');
}
.set({ Authorization: `Basic ${WATTPAD_KEY}` });
if (!body.stories.length) return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0xF89C34)
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
+2 -4
View File
@@ -25,12 +25,10 @@ module.exports = class WeatherCommand extends Command {
const { body } = await snekfetch
.get('https://query.yahooapis.com/v1/public/yql')
.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}")`, // eslint-disable-line max-len
format: 'json'
});
if (!body.query.count) {
return msg.say('Location Not Found.');
}
if (!body.query.count) return msg.say('Location Not Found.');
const embed = new RichEmbed()
.setColor(0x0000FF)
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
+1 -3
View File
@@ -34,9 +34,7 @@ module.exports = class WikipediaCommand extends Command {
redirects: '',
formatversion: 2
});
if (body.query.pages[0].missing) {
return msg.say('No Results.');
}
if (body.query.pages[0].missing) return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0xE7E7E7)
.setTitle(body.query.pages[0].title)
+1 -3
View File
@@ -32,9 +32,7 @@ module.exports = class YouTubeCommand extends Command {
q: query,
key: GOOGLE_KEY
});
if (!body.items.length) {
return msg.say('No Results.');
}
if (!body.items.length) return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0xDD2825)
.setTitle(body.items[0].snippet.title)
+1 -3
View File
@@ -25,9 +25,7 @@ module.exports = class YuGiOhCommand extends Command {
const { query } = args;
const { body } = await snekfetch
.get(`http://yugiohprices.com/api/card_data/${query}`);
if (body.status === 'fail') {
return msg.say('No Results.');
}
if (body.status === 'fail') return msg.say('No Results.');
const embed = new RichEmbed()
.setColor(0xBE5F1F)
.setTitle(body.data.name)
+2 -5
View File
@@ -16,11 +16,8 @@ module.exports = class ClearSettingCommand extends Command {
prompt: 'What setting do you want to clear?',
type: 'string',
validate: (setting) => {
if (settings.includes(setting)) {
return true;
} else {
return `Please enter one of the following: ${settings.join(', ')}.`;
}
if (settings.includes(setting)) return true;
else return `Please enter one of the following: ${settings.join(', ')}.`;
}
}
]
+5 -11
View File
@@ -17,11 +17,8 @@ module.exports = class MemberMsgCommand extends Command {
prompt: 'Which message would you like to change? Please enter either `joinMsg` or `leaveMsg`.',
type: 'string',
validate: (type) => {
if (['joinMsg', 'leaveMsg'].includes(type)) {
return true;
} else {
return 'Please enter either `joinMsg` or `leaveMsg`.';
}
if (['joinMsg', 'leaveMsg'].includes(type)) return true;
else return 'Please enter either `joinMsg` or `leaveMsg`.';
}
},
{
@@ -29,11 +26,8 @@ module.exports = class MemberMsgCommand extends Command {
prompt: 'What should be sent to the channel? Use <user>, <server>, and <mention> as placeholders.',
type: 'string',
validate: (message) => {
if (message.length < 150) {
return true;
} else {
return 'Invalid Message. Message must be under 150 characters.';
}
if (message.length < 150) return true;
else return 'Invalid Message. Message must be under 150 characters.';
}
}
]
@@ -45,7 +39,7 @@ module.exports = class MemberMsgCommand extends Command {
if (type === 'joinMsg') {
msg.guild.settings.set('joinMsg', message);
return msg.say(`Join Message set to "${message}".`);
} else if (type === 'leaveMsg') {
} else {
msg.guild.settings.set('leaveMsg', message);
return msg.say(`Leave Message set to "${message}".`);
}
+10 -10
View File
@@ -13,21 +13,21 @@ module.exports = class SettingListCommand extends Command {
}
run(msg) {
const modLog = msg.guild.settings.get('modLog', false);
const memberLog = msg.guild.settings.get('memberLog', false);
const singleRole = msg.guild.settings.get('singleRole', false);
const joinRole = msg.guild.settings.get('joinRole', false);
const starboard = msg.guild.settings.get('starboard', false);
const modLog = msg.guild.channels.get(msg.guild.settings.get('modLog'));
const memberLog = msg.guild.channels.get(msg.guild.settings.get('memberLog'));
const singleRole = msg.guild.roles.get(msg.guild.settings.get('singleRole'));
const joinRole = msg.guild.roles.get(msg.guild.settings.get('joinRole'));
const starboard = msg.guild.channels.get(msg.guild.settings.get('starboard'));
return msg.say(stripIndents`
**Prefix:** ${msg.guild.commandPrefix}
**Invite Guard:** ${msg.guild.settings.get('inviteGuard', false)}
**Mod Channel:** ${modLog ? msg.guild.channels.has(modLog) ? msg.guild.channels.get(modLog).name : 'Missing' : 'None'}
**Starboard:** ${starboard ? msg.guild.channels.has(starboard) ? msg.guild.channels.get(starboard).name : 'Missing' : 'None'}
**Join Role:** ${joinRole ? msg.guild.roles.has(joinRole) ? msg.guild.roles.get(joinRole).name : 'Missing' : 'None'}
**Member Channel:** ${memberLog ? msg.guild.channels.has(memberLog) ? msg.guild.channels.get(memberLog).name : 'Missing' : 'None'}
**Mod Channel:** ${modLog ? modLog.name : 'None'}
**Starboard:** ${starboard ? starboard.name : 'None'}
**Join Role:** ${joinRole ? joinRole.name : 'None'}
**Member Channel:** ${memberLog ? memberLog.name : 'None'}
**Join Message:** ${msg.guild.settings.get('joinMsg', 'Welcome <user>! (Default)')}
**Leave Message:** ${msg.guild.settings.get('leaveMsg', 'Bye <user>... (Default)')}
**Single Role:** ${singleRole ? msg.guild.roles.has(singleRole) ? msg.guild.roles.get(singleRole).name : 'Missing' : 'None'}
**Single Role:** ${singleRole ? singleRole.name : 'None'}
`);
}
};
+5 -8
View File
@@ -13,13 +13,9 @@ module.exports = class BinaryCommand extends Command {
prompt: 'What text would you like to convert to binary?',
type: 'string',
validate: (text) => {
if (this.binary(text).length < 2000) {
return true;
} else {
return 'Your text is too long.';
}
},
parse: (text) => this.binary(text)
if (this.binary(text).length < 2000) return true;
else return 'Your text is too long.';
}
}
]
});
@@ -27,7 +23,8 @@ module.exports = class BinaryCommand extends Command {
run(msg, args) {
const { text } = args;
return msg.say(text);
const converted = this.binary(text);
return msg.say(converted);
}
binary(text) {
+2 -5
View File
@@ -14,11 +14,8 @@ module.exports = class CowsayCommand extends Command {
prompt: 'What text would you like the cow to say?',
type: 'string',
validate: (text) => {
if (text.length < 1500) {
return true;
} else {
return 'Invalid Text. Text must be under 1500 characters.';
}
if (text.length < 1500) return true;
else return 'Invalid Text. Text must be under 1500 characters.';
}
}
]
+32
View File
@@ -0,0 +1,32 @@
const Command = require('../../structures/Command');
module.exports = class MockingCommand extends Command {
constructor(client) {
super(client, {
name: 'mocking',
group: 'textedit',
memberName: 'mocking',
description: 'I aM a caT, I LIkE To DrInK mILK.',
clientPermissions: ['USE_EXTERNAL_EMOJIS'],
args: [
{
key: 'text',
prompt: 'WHaT tEXt WoUlD yOu LiKE to COnvErt?',
type: 'string',
validate: (text) => {
if (text.length < 1950) return true;
else return 'Invalid Text. Text must be under 1950 characters.';
},
parse: (text) => text.split('')
}
]
});
}
run(msg, args) {
const { text } = args;
for (let i = 0; i < text.length; i += Math.floor(Math.random() * 4)) text[i] = text[i].toUpperCase();
return msg.say(`\u180E${text.join('')} <:sponge:318612443398144000>`);
}
};
+5 -8
View File
@@ -15,13 +15,9 @@ module.exports = class MorseCommand extends Command {
prompt: 'What text would you like to convert to morse?',
type: 'string',
validate: (text) => {
if (letterTrans(text, dictionary, ' ').length < 1999) {
return true;
} else {
return 'Your text is too long.';
}
},
parse: (text) => letterTrans(text.toLowerCase(), dictionary, ' ')
if (letterTrans(text, dictionary, ' ').length < 1999) return true;
else return 'Your text is too long.';
}
}
]
});
@@ -29,6 +25,7 @@ module.exports = class MorseCommand extends Command {
run(msg, args) {
const { text } = args;
return msg.say(text);
const converted = letterTrans(text.toLowerCase(), dictionary, ' ');
return msg.say(converted);
}
};
+5 -8
View File
@@ -15,13 +15,9 @@ module.exports = class PirateCommand extends Command {
prompt: 'What text would you like to convert to pirate?',
type: 'string',
validate: (text) => {
if (wordTrans(text, dictionary).length < 1999) {
return true;
} else {
return 'Your text is too long.';
}
},
parse: (text) => wordTrans(text, dictionary)
if (wordTrans(text, dictionary).length < 1999) return true;
else return 'Your text is too long.';
}
}
]
});
@@ -29,6 +25,7 @@ module.exports = class PirateCommand extends Command {
run(msg, args) {
const { text } = args;
return msg.say(`\u180E${text}`);
const converted = wordTrans(text, dictionary);
return msg.say(`\u180E${converted}`);
}
};
+3 -3
View File
@@ -11,8 +11,7 @@ module.exports = class RepeatCommand extends Command {
{
key: 'text',
prompt: 'What text would you like to repeat over and over and over and over?',
type: 'string',
parse: (text) => text.repeat(2000).substr(0, 1999)
type: 'string'
}
]
});
@@ -20,6 +19,7 @@ module.exports = class RepeatCommand extends Command {
run(msg, args) {
const { text } = args;
return msg.say(`\u180E${text}`);
const converted = text.repeat(2000).substr(0, 1999);
return msg.say(`\u180E${converted}`);
}
};
+3 -3
View File
@@ -11,8 +11,7 @@ module.exports = class ReverseCommand extends Command {
{
key: 'text',
prompt: 'What text would you like to reverse?',
type: 'string',
parse: (text) => text.split('').reverse().join('')
type: 'string'
}
]
});
@@ -20,6 +19,7 @@ module.exports = class ReverseCommand extends Command {
run(msg, args) {
const { text } = args;
return msg.say(`\u180E${text}`);
const converted = text.split('').reverse().join('');
return msg.say(`\u180E${converted}`);
}
};
+23 -26
View File
@@ -3,32 +3,29 @@ const { wordTrans } = require('custom-translate');
const dictionary = require('../../assets/json/temmie');
module.exports = class TemmieCommand extends Command {
constructor(client) {
super(client, {
name: 'temmie',
group: 'textedit',
memberName: 'temmie',
description: 'Translate text to Temmie speak.',
args: [
{
key: 'text',
prompt: 'What text would you like to convert to Temmie speak?',
type: 'string',
validate: (text) => {
if (wordTrans(text, dictionary).length < 1999) {
return true;
} else {
return 'Your text is too long.';
}
},
parse: (text) => wordTrans(text, dictionary)
}
constructor(client) {
super(client, {
name: 'temmie',
group: 'textedit',
memberName: 'temmie',
description: 'Translate text to Temmie speak.',
args: [
{
key: 'text',
prompt: 'What text would you like to convert to Temmie speak?',
type: 'string',
validate: (text) => {
if (wordTrans(text, dictionary).length < 1999) return true;
else return 'Your text is too long.';
}
}
]
});
}
});
}
run(msg, args) {
const { text } = args;
return msg.say(`\u180E${text}`);
}
run(msg, args) {
const { text } = args;
const converted = wordTrans(text, dictionary);
return msg.say(`\u180E${converted}`);
}
};
+4 -10
View File
@@ -24,11 +24,8 @@ module.exports = class TranslateCommand extends Command {
prompt: 'Which language is being translated to?',
type: 'string',
validate: (to) => {
if (codes[to.toLowerCase()]) {
return true;
} else {
return 'Invalid Language Code. Use `help translate` for a list of codes.';
}
if (codes[to.toLowerCase()]) return true;
else return 'Invalid Language Code. Use `help translate` for a list of codes.';
},
parse: (to) => to.toLowerCase()
},
@@ -38,11 +35,8 @@ module.exports = class TranslateCommand extends Command {
type: 'string',
default: '',
validate: (from) => {
if (codes[from.toLowerCase()]) {
return true;
} else {
return 'Invalid Language Code. Use `help translate` for a list of codes.';
}
if (codes[from.toLowerCase()]) return true;
else return 'Invalid Language Code. Use `help translate` for a list of codes.';
},
parse: (from) => from.toLowerCase()
}
+3 -3
View File
@@ -14,8 +14,7 @@ module.exports = class UpsideDownCommand extends Command {
{
key: 'text',
prompt: 'What text would you like to flip upside-down?',
type: 'string',
parse: (text) => letterTrans(text, dictionary)
type: 'string'
}
]
});
@@ -23,6 +22,7 @@ module.exports = class UpsideDownCommand extends Command {
run(msg, args) {
const { text } = args;
return msg.say(text);
const converted = letterTrans(text, dictionary);
return msg.say(converted);
}
};
+5 -8
View File
@@ -14,13 +14,9 @@ module.exports = class ZalgoCommand extends Command {
prompt: 'What text would you like to convert to zalgo?',
type: 'string',
validate: (text) => {
if (text.length < 500) {
return true;
} else {
return 'Invalid Text. Text must be under 500 characters.';
}
},
parse: (text) => zalgo(text)
if (text.length < 500) return true;
else return 'Invalid Text. Text must be under 500 characters.';
}
}
]
});
@@ -28,6 +24,7 @@ module.exports = class ZalgoCommand extends Command {
run(msg, args) {
const { text } = args;
return msg.say(`\u180E${text}`);
const converted = zalgo(text);
return msg.say(`\u180E${converted}`);
}
};
+4 -4
View File
@@ -2,10 +2,10 @@ const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js');
const moment = require('moment');
const statuses = {
online: "<:online:313956277808005120> Online",
idle: "<:away:313956277220802560> Idle",
dnd: "<:dnd:313956276893646850> Do Not Disturb",
offline: "<:offline:313956277237710868> Offline"
online: '<:online:313956277808005120> Online',
idle: '<:away:313956277220802560> Idle',
dnd: '<:dnd:313956276893646850> Do Not Disturb',
offline: '<:offline:313956277237710868> Offline'
};
const colors = {
online: 0x00AE86,
+5 -5
View File
@@ -38,18 +38,18 @@ module.exports = class HelpCommand extends Command {
${commands[0].details || ''}
`);
} else {
return msg.say(`Could not identify command. Use \`${msg.usage(null)}\` to view a list of commands you can use.`);
return msg.say(`Could not identify command. Use \`${msg.usage(null)}\` to view a list of commands.`);
}
} else {
const embed = new RichEmbed()
.setTitle(!showAll ? `Commands Available in ${msg.guild ? msg.guild.name : 'this DM'}` : 'All Commands')
.setDescription(`Use \`${msg.usage('<command>')}\` to view detailed information about a specific command.`)
.setDescription(`Use \`${msg.usage('<command>')}\` to view detailed information about a command.`)
.setColor(0x00AE86);
for (const group of this.client.registry.groups.values()) {
embed.addField(` ${group.name}`,
showAll
? group.commands.map((c) => c.name).join(', ')
: group.commands.filter((c) => c.isUsable(msg)).map((c) => c.name).join(', ') || 'None Available');
showAll ?
group.commands.map((c) => c.name).join(', ') :
group.commands.filter((c) => c.isUsable(msg)).map((c) => c.name).join(', ') || 'None');
}
try {
await msg.direct({ embed });
+3 -3
View File
@@ -19,7 +19,7 @@ module.exports = class InfoCommand extends Command {
async run(msg) {
const guilds = await this.client.shard.fetchClientValues('guilds.size');
const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)');
const memory = await this.client.shard.broadcastEval('process.memoryUsage().heapUsed');
const embed = new RichEmbed()
.setColor(0x00AE86)
.setFooter('©2017 dragonfire535#8081')
@@ -32,7 +32,7 @@ module.exports = class InfoCommand extends Command {
.addField(' Source Code',
'[View Here](https://github.com/dragonfire535/xiaobot)', true)
.addField(' Memory Usage',
`${memory.reduce((prev, val) => prev + val, 0)}MB`, true)
`${Math.round(memory.reduce((prev, val) => prev + val, 0)) / 1024 / 1024}MB`, true)
.addField(' Uptime',
moment.duration(this.client.uptime).format('d[d]h[h]m[m]s[s]'), true)
.addField(' Version',
@@ -40,7 +40,7 @@ module.exports = class InfoCommand extends Command {
.addField(' Node Version',
process.version, true)
.addField(' Library',
'[discord.js](https://github.com/hydrabolt/discord.js)[-commando](https://github.com/Gawdl3y/discord.js-commando)', true);
'[discord.js](https://discord.js.org)[-commando](https://github.com/Gawdl3y/discord.js-commando)', true); // eslint-disable-line max-len
return msg.embed(embed);
}
};
+4 -7
View File
@@ -19,11 +19,8 @@ module.exports = class ShardInfoCommand extends Command {
prompt: 'Which Shard would you like to get data for?',
type: 'integer',
validate: (shard) => {
if (shard < this.client.options.shardCount && shard > -1) {
return true;
} else {
return 'Invalid Shard ID';
}
if (shard < this.client.options.shardCount && shard > -1) return true;
else return 'Invalid Shard ID';
}
}
]
@@ -32,7 +29,7 @@ module.exports = class ShardInfoCommand extends Command {
async run(msg, args) {
const { shard } = args;
const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)');
const memory = await this.client.shard.broadcastEval('process.memoryUsage().heapUsed');
const uptime = await this.client.shard.fetchClientValues('uptime');
const guilds = await this.client.shard.fetchClientValues('guilds.size');
const embed = new RichEmbed()
@@ -41,7 +38,7 @@ module.exports = class ShardInfoCommand extends Command {
.addField(' Servers',
guilds[shard], true)
.addField(' Memory Usage',
`${memory[shard]}MB`, true)
`${Math.round(memory[shard]) / 1024 / 1024}MB`, true)
.addField(' Uptime',
moment.duration(uptime[shard]).format('d[d]h[h]m[m]s[s]'), true);
return msg.embed(embed);
+1 -1
View File
@@ -14,6 +14,6 @@ module.exports = class UptimeCommand extends Command {
}
run(msg) {
return msg.say(`I've been active on this shard for: **${moment.duration(this.client.uptime).format('d[ days], h[ hours], m[ minutes, and ]s[ seconds]')}**!`);
return msg.say(moment.duration(this.client.uptime).format('d[ days], h[ hours], m[ minutes, and ]s[ seconds]'));
}
};
+15 -36
View File
@@ -1,3 +1,5 @@
/* eslint-disable indent */
const { SettingProvider } = require('discord.js-commando');
const Sequelize = require('sequelize');
@@ -110,16 +112,12 @@ class SequelizeProvider extends SettingProvider {
this.setupGuildGroup(client.guilds.get(guild), group, settings);
}
});
for (const [event, listener] of this.listeners) {
client.on(event, listener);
}
for (const [event, listener] of this.listeners) client.on(event, listener);
}
destroy() {
// Remove all listeners from the client
for (const [event, listener] of this.listeners) {
this.client.removeListener(event, listener);
}
for (const [event, listener] of this.listeners) this.client.removeListener(event, listener);
this.listeners.clear();
}
@@ -141,18 +139,14 @@ class SequelizeProvider extends SettingProvider {
{ guild: guild !== 'global' ? guild : '0', settings: JSON.stringify(settings) },
{ where: { guild: guild !== 'global' ? guild : '0' } }
);
if (guild === 'global') {
this.updateOtherShards(key, val);
}
if (guild === 'global') this.updateOtherShards(key, val);
return val;
}
async remove(guild, key) {
guild = this.constructor.getGuildID(guild);
const settings = this.settings.get(guild);
if (!settings || typeof settings[key] === 'undefined') {
return undefined;
}
if (!settings || typeof settings[key] === 'undefined') return undefined;
const val = settings[key];
settings[key] = undefined;
@@ -160,9 +154,7 @@ class SequelizeProvider extends SettingProvider {
{ guild: guild !== 'global' ? guild : '0', settings: JSON.stringify(settings) },
{ where: { guild: guild !== 'global' ? guild : '0' } }
);
if (guild === 'global') {
this.updateOtherShards(key, undefined);
}
if (guild === 'global') this.updateOtherShards(key, undefined);
return val;
}
@@ -180,27 +172,18 @@ class SequelizeProvider extends SettingProvider {
* @private
*/
setupGuild(guild, settings) {
if (typeof guild !== 'string') {
throw new TypeError('The guild must be a guild ID or "global".');
}
if (typeof guild !== 'string') throw new TypeError('The guild must be a guild ID or "global".');
guild = this.client.guilds.get(guild) || null;
// Load the command prefix
if (typeof settings.prefix !== 'undefined') {
if (guild) {
guild._commandPrefix = settings.prefix;
} else {
this.client._commandPrefix = settings.prefix;
}
if (guild) guild._commandPrefix = settings.prefix;
else this.client._commandPrefix = settings.prefix;
}
// Load all command/group statuses
for (const command of this.client.registry.commands.values()) {
this.setupGuildCommand(guild, command, settings);
}
for (const group of this.client.registry.groups.values()) {
this.setupGuildGroup(guild, group, settings);
}
for (const command of this.client.registry.commands.values()) this.setupGuildCommand(guild, command, settings);
for (const group of this.client.registry.groups.values()) this.setupGuildGroup(guild, group, settings);
}
/**
@@ -213,9 +196,7 @@ class SequelizeProvider extends SettingProvider {
setupGuildCommand(guild, command, settings) {
if (typeof settings[`cmd-${command.name}`] === 'undefined') return;
if (guild) {
if (!guild._commandsEnabled) {
guild._commandsEnabled = {};
}
if (!guild._commandsEnabled) guild._commandsEnabled = {};
guild._commandsEnabled[command.name] = settings[`cmd-${command.name}`];
} else {
command._globalEnabled = settings[`cmd-${command.name}`];
@@ -232,9 +213,7 @@ class SequelizeProvider extends SettingProvider {
setupGuildGroup(guild, group, settings) {
if (typeof settings[`grp-${group.id}`] === 'undefined') return;
if (guild) {
if (!guild._groupsEnabled) {
guild._groupsEnabled = {};
}
if (!guild._groupsEnabled) guild._groupsEnabled = {};
guild._groupsEnabled[group.id] = settings[`grp-${group.id}`];
} else {
group._globalEnabled = settings[`grp-${group.id}`];
@@ -252,7 +231,7 @@ class SequelizeProvider extends SettingProvider {
key = JSON.stringify(key);
val = typeof val !== 'undefined' ? JSON.stringify(val) : 'undefined';
this.client.shard.broadcastEval(`
if (this.shard.id !== ${this.client.shard.id} && this.provider && this.provider.settings) {
if(this.shard.id !== ${this.client.shard.id} && this.provider && this.provider.settings) {
this.provider.settings.global[${key}] = ${val};
}
`);
+14 -14
View File
@@ -3,21 +3,21 @@ const { DATABASE_URL } = process.env;
const database = new Sequelize(DATABASE_URL, { logging: false });
class Database {
static get db() {
return database;
}
static get db() {
return database;
}
static start() {
database.authenticate()
.then(() => console.log('[DATABASE] Connection has been established successfully.'))
.then(() => console.log('[DATABASE] Synchronizing...'))
.then(() => database.sync()
.then(() => console.log('[DATABASE] Synchronizing complete!'))
.catch(err => console.error(`[DATABASE] Error synchronizing: ${err}`))
)
.then(() => console.log('[DATABASE] Ready!'))
.catch(err => console.error(`[DATABASE] Unable to connect: ${err}`));
}
static start() {
database.authenticate()
.then(() => console.log('[DATABASE] Connection has been established successfully.'))
.then(() => console.log('[DATABASE] Synchronizing...'))
.then(() => database.sync()
.then(() => console.log('[DATABASE] Synchronizing complete!'))
.catch((err) => console.error(`[DATABASE] Error synchronizing: ${err}`))
)
.then(() => console.log('[DATABASE] Ready!'))
.catch((err) => console.error(`[DATABASE] Unable to connect: ${err}`));
}
}
module.exports = Database;
+4 -8
View File
@@ -5,14 +5,10 @@ class Stats {
static dBots(count, id) {
snekfetch
.post(`https://bots.discord.pw/api/bots/${id}/stats`)
.set({
Authorization: DBOTS_KEY
})
.send({
server_count: count
})
.set({ Authorization: DBOTS_KEY })
.send({ server_count: count })
.then(() => console.log('[CARBON] Successfully posted to Carbon.'))
.catch(err => console.error(`[CARBON] Failed to post to Carbon. ${err}`));
.catch((err) => console.error(`[CARBON] Failed to post to Carbon. ${err}`));
}
static carbon(count) {
@@ -23,7 +19,7 @@ class Stats {
servercount: count
})
.then(() => console.log('[DBOTS] Successfully posted to Discord Bots.'))
.catch(err => console.error(`[DBOTS] Failed to post to Discord Bots. ${err}`));
.catch((err) => console.error(`[DBOTS] Failed to post to Discord Bots. ${err}`));
}
}