Make Code Prettier

This commit is contained in:
Daniel Odendahl Jr
2017-05-04 02:40:56 +00:00
parent e5f93b63cb
commit cf87f126d6
71 changed files with 354 additions and 343 deletions
+5 -5
View File
@@ -22,12 +22,12 @@ module.exports = class YearsCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
if(!avatarURL) return msg.say('This user has no avatar.');
let images = [];
images.push(Jimp.read(avatarURL));
images.push(Jimp.read('https://i.imgur.com/eScwGFS.png'));
@@ -35,8 +35,8 @@ module.exports = class YearsCommand extends Command {
avatar.resize(200, 200);
az.composite(avatar, 461, 127);
az.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]})
if(err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({ files: [{ attachment: buff, name: 'az.png' }] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
});
}
+5 -5
View File
@@ -22,12 +22,12 @@ module.exports = class BeautifulCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
if(!avatarURL) return msg.say('This user has no avatar.');
let images = [];
images.push(Jimp.read(avatarURL));
images.push(Jimp.read('https://i.imgur.com/71qLwPf.png'));
@@ -36,8 +36,8 @@ module.exports = class BeautifulCommand extends Command {
grunkle.composite(avatar, 341, 35);
grunkle.composite(avatar, 342, 301);
grunkle.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]})
if(err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({ files: [{ attachment: buff, name: 'beautiful.png' }] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
});
}
+5 -5
View File
@@ -22,12 +22,12 @@ module.exports = class BobRossCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
if(!avatarURL) return msg.say('This user has no avatar.');
const blank = new Jimp(600, 775, 0xFFFFFFFF);
let images = [];
images.push(Jimp.read(avatarURL));
@@ -38,8 +38,8 @@ module.exports = class BobRossCommand extends Command {
blank.composite(avatar, 44, 85);
blank.composite(bob, 0, 0);
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]})
if(err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({ files: [{ attachment: buff, name: 'bobross.png' }] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
});
}
+5 -5
View File
@@ -19,17 +19,17 @@ module.exports = class GreyscaleCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
if(!avatarURL) return msg.say('This user has no avatar.');
const avatar = await Jimp.read(avatarURL);
avatar.greyscale();
avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]})
if(err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({ files: [{ attachment: buff, name: 'greyscale.png' }] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
});
}
+5 -5
View File
@@ -19,17 +19,17 @@ module.exports = class InvertCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
if(!avatarURL) return msg.say('This user has no avatar.');
const avatar = await Jimp.read(avatarURL);
avatar.invert();
avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]})
if(err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({ files: [{ attachment: buff, name: 'invert.png' }] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
});
}
+5 -5
View File
@@ -23,12 +23,12 @@ module.exports = class RIPCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
if(!avatarURL) return msg.say('This user has no avatar.');
let images = [];
images.push(Jimp.read(avatarURL));
images.push(Jimp.read('https://i.imgur.com/KriteWm.jpg'));
@@ -37,8 +37,8 @@ module.exports = class RIPCommand extends Command {
avatar.resize(200, 200);
grave.composite(avatar, 158, 51);
grave.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]})
if(err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({ files: [{ attachment: buff, name: 'rip.png' }] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
});
}
+5 -5
View File
@@ -22,13 +22,13 @@ module.exports = class SteamCardCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const username = msg.guild ? msg.guild.member(user).displayName : user.username;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
if(!avatarURL) return msg.say('This user has no avatar.');
const blank = new Jimp(494, 568, 0xFFFFFFFF);
let images = [];
images.push(Jimp.read(avatarURL));
@@ -40,8 +40,8 @@ module.exports = class SteamCardCommand extends Command {
blank.composite(card, 0, 0);
blank.print(font, 38, 20, username);
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]})
if(err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({ files: [{ attachment: buff, name: 'steamcard.png' }] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
});
}
+5 -5
View File
@@ -19,12 +19,12 @@ module.exports = class TriggeredCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
if(!avatarURL) return msg.say('This user has no avatar.');
const blank = new Jimp(320, 371, 0xFFFFFFFF);
let images = [];
images.push(Jimp.read(avatarURL));
@@ -34,8 +34,8 @@ module.exports = class TriggeredCommand extends Command {
blank.composite(avatar, 0, 0);
blank.composite(triggered, 0, 0);
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]})
if(err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({ files: [{ attachment: buff, name: 'triggered.png' }] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
});
}
+5 -5
View File
@@ -19,12 +19,12 @@ module.exports = class WantedCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args;
const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.');
if(!avatarURL) return msg.say('This user has no avatar.');
let images = [];
images.push(Jimp.read(avatarURL));
images.push(Jimp.read('https://i.imgur.com/ca09TG5.jpg'));
@@ -32,8 +32,8 @@ module.exports = class WantedCommand extends Command {
avatar.resize(500, 500);
wanted.composite(avatar, 189, 438);
wanted.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]})
if(err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({ files: [{ attachment: buff, name: 'wanted.png' }] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
});
}
+1 -2
View File
@@ -12,8 +12,7 @@ module.exports = class LotteryCommand extends Command {
run(msg) {
const lottery = Math.floor(Math.random() * 100) + 1;
if (lottery < 99)
return msg.say(`Nope, sorry ${msg.author.username}, you lost.`);
if(lottery < 99) return msg.say(`Nope, sorry ${msg.author.username}, you lost.`);
return msg.say(`Wow ${msg.author.username}! You actually won! Great job!`);
}
};
+6 -6
View File
@@ -17,7 +17,7 @@ module.exports = class MathGameCommand extends Command {
prompt: 'What should the difficulty of the math game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?',
type: 'string',
validate: difficulty => {
if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase()))
if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase()))
return true;
return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.';
},
@@ -28,13 +28,13 @@ module.exports = class MathGameCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { difficulty } = args;
const operation = operations[Math.floor(Math.random() * operations.length)];
let value;
switch (difficulty) {
switch(difficulty) {
case 'easy':
value = 10;
break;
@@ -63,13 +63,13 @@ module.exports = class MathGameCommand extends Command {
time: 10000,
errors: ['time']
});
if (collected.first().content !== solved)
if(collected.first().content !== solved)
return msg.say(stripIndents`
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) {
} catch(err) {
return msg.say(stripIndents`
Aw... Too bad, try again next time!
The correct answer is: ${solved}
+5 -5
View File
@@ -17,8 +17,8 @@ module.exports = class QuizCommand extends Command {
}
async run(msg) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
try {
const { body } = await request
@@ -37,16 +37,16 @@ module.exports = class QuizCommand extends Command {
time: 15000,
errors: ['time']
});
if (collected.first().content.toLowerCase() !== answer)
if(collected.first().content.toLowerCase() !== answer)
return msg.say(`The correct answer is: ${answer}`);
return msg.say(`Perfect! The correct answer is: ${answer}`);
} catch (err) {
} catch(err) {
return msg.say(stripIndents`
Aw... Too bad, try again next time!
The Correct Answer was: ${answer}
`);
}
} catch (err) {
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+13 -13
View File
@@ -17,7 +17,7 @@ module.exports = class RockPaperScissorsCommand extends Command {
prompt: '`Rock`, `Paper`, or `Scissors`?',
type: 'string',
validate: choice => {
if (['rock', 'paper', 'scissors'].includes(choice.toLowerCase()))
if(['rock', 'paper', 'scissors'].includes(choice.toLowerCase()))
return true;
return 'Please enter either `rock`, `paper`, or `scissors`.';
},
@@ -30,26 +30,26 @@ module.exports = class RockPaperScissorsCommand extends Command {
run(msg, args) {
const { choice } = args;
const response = responses[Math.floor(Math.random() * responses.length)];
if (choice === 'rock') {
if (response === 'Rock')
if(choice === 'rock') {
if(response === 'Rock')
return msg.say('Rock! Aw, it\'s a tie!');
if (response === 'Paper')
if(response === 'Paper')
return msg.say('Paper! Yes! I win!');
if (response === 'Scissors')
if(response === 'Scissors')
return msg.say('Scissors! Aw... I lose...');
} else if (choice === 'paper') {
if (response === 'Rock')
} else if(choice === 'paper') {
if(response === 'Rock')
return msg.say('Rock! Aw... I lose...');
if (response === 'Paper')
if(response === 'Paper')
return msg.say('Paper! Aw, it\'s a tie!');
if (response === 'Scissors')
if(response === 'Scissors')
return msg.say('Scissors! Yes! I win!');
} else if (choice === 'scissors') {
if (response === 'Rock')
} else if(choice === 'scissors') {
if(response === 'Rock')
return msg.say('Rock! Yes! I win!');
if (response === 'Paper')
if(response === 'Paper')
return msg.say('Paper! Aw... I lose...');
if (response === 'Scissors')
if(response === 'Scissors')
return msg.say('Scissors! Aw, it\'s a tie!');
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ module.exports = class SlotsCommand extends Command {
const slotOne = slotThing[Math.floor(Math.random() * slotThing.length)];
const slotTwo = slotThing[Math.floor(Math.random() * slotThing.length)];
const slotThree = slotThing[Math.floor(Math.random() * slotThing.length)];
if (slotOne === slotTwo && slotOne === slotThree)
if(slotOne === slotTwo && slotOne === slotThree)
return msg.say(stripIndents`
${slotOne}|${slotTwo}|${slotThree}
Wow! You won! Great job... er... luck!
+6 -6
View File
@@ -15,7 +15,7 @@ module.exports = class TypingGameCommand extends Command {
prompt: 'What should the difficulty of the typing game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?',
type: 'string',
validate: difficulty => {
if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase()))
if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase()))
return true;
return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.';
},
@@ -26,13 +26,13 @@ module.exports = class TypingGameCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { difficulty } = args;
const sentence = sentences[Math.floor(Math.random() * sentences.length)];
let time;
switch (difficulty) {
switch(difficulty) {
case 'easy':
time = 25000;
break;
@@ -59,10 +59,10 @@ module.exports = class TypingGameCommand extends Command {
time: time,
errors: ['time']
});
if (collected.first().content !== sentence)
if(collected.first().content !== sentence)
return msg.say('Nope, your sentence does not match the original. Try again next time!');
return msg.say(`Good Job! You won!`);
} catch (err) {
} catch(err) {
return msg.say('Aw... Too bad, try again next time!');
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ module.exports = class GuildInfoCommand extends Command {
}
run(msg) {
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const embed = new RichEmbed()
.setColor(0x00AE86)
+6 -6
View File
@@ -15,7 +15,7 @@ module.exports = class MemeCommand extends Command {
prompt: 'What meme type do you want to use?',
type: 'string',
validate: type => {
if (codes.includes(type.toLowerCase()))
if(codes.includes(type.toLowerCase()))
return true;
return `${type.toLowerCase()} is not a valid meme type. Use \`help meme\` to view a list of types.`;
},
@@ -26,7 +26,7 @@ module.exports = class MemeCommand extends Command {
prompt: 'What should the top row of the meme to be?',
type: 'string',
validate: top => {
if (/[a-zA-Z0-9.,!?'\s]+$/g.test(top) && top.length < 100)
if(/[a-zA-Z0-9.,!?'\s]+$/g.test(top) && top.length < 100)
return true;
return `Please do not use special characters and keep the rows under 100 characters each, top row has ${top.length}.`;
},
@@ -37,7 +37,7 @@ module.exports = class MemeCommand extends Command {
prompt: 'What should the bottom row of the meme to be?',
type: 'string',
validate: bottom => {
if (/[a-zA-Z0-9.,!?'\s]+$/g.test(bottom) && bottom.length < 100)
if(/[a-zA-Z0-9.,!?'\s]+$/g.test(bottom) && bottom.length < 100)
return true;
return `Please do not use special characters and keep the rows under 100 characters each, bottom row has ${bottom.length}.`;
},
@@ -48,11 +48,11 @@ module.exports = class MemeCommand extends Command {
}
run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { type, top, bottom } = args;
return msg.channel.send({files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`]})
return msg.channel.send({ files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
}
};
+9 -12
View File
@@ -24,7 +24,7 @@ module.exports = class BanCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) {
if(reason.length < 140) {
return true;
}
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
@@ -39,15 +39,15 @@ module.exports = class BanCommand extends Command {
}
async run(msg, args) {
if (!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
return msg.say('This Command requires the `Ban Members` Permission.');
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs)
if(!modlogs)
return msg.say('This Command requires a channel set with the `modchannel` command.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { member, reason } = args;
if (!member.bannable)
if(!member.bannable)
return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
try {
try {
@@ -55,13 +55,10 @@ module.exports = class BanCommand extends Command {
You were banned from ${msg.guild.name}!
Reason: ${reason}.
`);
} catch (err) {
} catch(err) {
await msg.say('Failed to send DM to user.');
}
await member.ban({
days: 7,
reason
});
await member.ban({ days: 7, reason });
await msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
@@ -72,8 +69,8 @@ module.exports = class BanCommand extends Command {
**Action:** Ban
**Reason:** ${reason}
`);
return modlogs.send({embed});
} catch (err) {
return modlogs.send({ embed });
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+9 -11
View File
@@ -21,7 +21,7 @@ module.exports = class KickCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) {
if(reason.length < 140) {
return true;
}
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
@@ -36,15 +36,15 @@ module.exports = class KickCommand extends Command {
}
async run(msg, args) {
if (!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS'))
if(!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS'))
return msg.say('This Command requires the `Kick Members` Permission.');
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs)
if(!modlogs)
return msg.say('This Command requires a channel set with the `modchannel` command.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { member, reason } = args;
if (!member.kickable)
if(!member.kickable)
return msg.say('This member is not kickable. Perhaps they have a higher role than me?');
try {
try {
@@ -52,12 +52,10 @@ module.exports = class KickCommand extends Command {
You were kicked from ${msg.guild.name}!
Reason: ${reason}.
`);
} catch (err) {
} catch(err) {
await msg.say('Failed to send DM.');
}
await member.kick({
reason
});
await member.kick({ reason });
await msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
@@ -68,8 +66,8 @@ module.exports = class KickCommand extends Command {
**Action:** Kick
**Reason:** ${reason}
`);
return modlogs.send({embed});
} catch (err) {
return modlogs.send({ embed });
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+13 -13
View File
@@ -1,4 +1,5 @@
const { Command } = require('discord.js-commando');
const { stripIndents } = require('common-tags');
module.exports = class LockdownCommand extends Command {
constructor(client) {
@@ -14,7 +15,7 @@ module.exports = class LockdownCommand extends Command {
prompt: 'Please enter either `start` or `stop`.',
type: 'string',
validate: type => {
if (['start', 'stop'].includes(type.toLowerCase()))
if(['start', 'stop'].includes(type.toLowerCase()))
return true;
return 'Please enter either `start` or `stop`.';
},
@@ -29,25 +30,24 @@ module.exports = class LockdownCommand extends Command {
}
async run(msg, args) {
if (!msg.channel.permissionsFor(this.client.user).has('ADMINISTRATOR'))
if(!msg.channel.permissionsFor(this.client.user).has('ADMINISTRATOR'))
return msg.say('This Command requires the `Administrator` Permission.');
const { type } = args;
if (type === 'start') {
if(type === 'start') {
try {
await msg.channel.overwritePermissions(msg.guild.defaultRole, {
SEND_MESSAGES: false
});
return msg.say('Lockdown Started, users without Administrator can no longer post messages. Please use `;lockdown stop` to end the lockdown.');
} catch (err) {
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false });
return msg.say(stripIndents`
Lockdown Started, users without Administrator can no longer post messages.
Please use \`;lockdown stop\` to end the lockdown.
`);
} catch(err) {
return msg.say('Something went wrong!');
}
} else if (type === 'stop') {
} else if(type === 'stop') {
try {
await msg.channel.overwritePermissions(msg.guild.defaultRole, {
SEND_MESSAGES: true
});
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: true });
return msg.say('Lockdown Ended, users without Administrator can now post messages.');
} catch (err) {
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+5 -7
View File
@@ -19,7 +19,7 @@ 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)
if(count < 100 && count > 0)
return true;
return `${count} is not a valid amount of messages. Limit 1-99.`;
}
@@ -33,18 +33,16 @@ module.exports = class PruneCommand extends Command {
}
async run(msg, args) {
if (!msg.channel.permissionsFor(this.client.user).has('READ_MESSAGE_HISTORY'))
if(!msg.channel.permissionsFor(this.client.user).has('READ_MESSAGE_HISTORY'))
return msg.say('This Command requires the `Read Message History` Permission.');
if (!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES'))
if(!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES'))
return msg.say('This Command requires the `Manage Messages` Permission.');
const { count } = args;
try {
const messages = await msg.channel.fetchMessages({
limit: count + 1
});
const messages = await msg.channel.fetchMessages({ limit: count + 1 });
await msg.channel.bulkDelete(messages, true);
return null;
} catch (err) {
} catch(err) {
return msg.say('There are no messages younger than two weeks that can be deleted.');
}
}
+10 -13
View File
@@ -21,7 +21,7 @@ module.exports = class SoftbanCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) {
if(reason.length < 140) {
return true;
}
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
@@ -36,17 +36,17 @@ module.exports = class SoftbanCommand extends Command {
}
async run(msg, args) {
if (!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
return msg.say('This Command requires the `Ban Members` Permission.');
if (!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS'))
if(!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS'))
return msg.say('This Command requires the `Kick Members` Permission.');
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs)
if(!modlogs)
return msg.say('This Command requires a channel set with the `modchannel` command.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { member, reason } = args;
if (!member.bannable)
if(!member.bannable)
return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
try {
try {
@@ -54,13 +54,10 @@ module.exports = class SoftbanCommand extends Command {
You were softbanned from ${msg.guild.name}!
Reason: ${reason}.
`);
} catch (err) {
} catch(err) {
await msg.say('Failed to send DM to user.');
}
await member.ban({
days: 7,
reason
});
await member.ban({ days: 7, reason });
await msg.guild.unban(member.user);
await msg.say(':ok_hand:');
const embed = new RichEmbed()
@@ -72,8 +69,8 @@ module.exports = class SoftbanCommand extends Command {
**Action:** Softban
**Reason:** ${reason}
`);
return modlogs.send({embed});
} catch (err) {
return modlogs.send({ embed });
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+8 -8
View File
@@ -19,7 +19,7 @@ module.exports = class UnbanCommand extends Command {
prompt: 'What member do you want to unban? Please enter the ID of the user.',
type: 'string',
validate: id => {
if (id.length === 18)
if(id.length === 18)
return true;
return `${id} is not a valid ID. Please enter the user you wish to unban's ID.`;
}
@@ -29,7 +29,7 @@ module.exports = class UnbanCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140)
if(reason.length < 140)
return true;
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
}
@@ -43,16 +43,16 @@ module.exports = class UnbanCommand extends Command {
}
async run(msg, args) {
if (!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
return msg.say('This Command requires the `Ban Members` Permission.');
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs'));
if (!modlogs)
if(!modlogs)
return msg.say('This Command requires a channel set with the `modchannel` command.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { id, reason } = args;
const bans = await msg.guild.fetchBans();
if (!bans.has(id))
if(!bans.has(id))
return msg.say('This ID is not in the Guild Banlist.');
const member = bans.get(id);
try {
@@ -67,8 +67,8 @@ module.exports = class UnbanCommand extends Command {
**Action:** Unban
**Reason:** ${reason}
`);
return modlogs.send({embed});
} catch (err) {
return modlogs.send({ embed });
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+5 -5
View File
@@ -21,7 +21,7 @@ module.exports = class WarnCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140)
if(reason.length < 140)
return true;
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
}
@@ -36,9 +36,9 @@ module.exports = class WarnCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs'));
if (!modlogs)
if(!modlogs)
return msg.say('This Command requires a channel set with the `modchannel` command.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { member, reason } = args;
try {
@@ -52,8 +52,8 @@ module.exports = class WarnCommand extends Command {
**Action:** Warn
**Reason:** ${reason}
`);
return modlogs.send({embed});
} catch (err) {
return modlogs.send({ embed });
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ module.exports = class EasterEggCommand extends Command {
prompt: 'What easter egg do you want to view?',
type: 'string',
validate: tag => {
if (eastereggs[tag.toLowerCase()])
if(eastereggs[tag.toLowerCase()])
return true;
return 'Nope, that\'s not a valid easter egg. Try again!';
},
+1 -1
View File
@@ -24,7 +24,7 @@ module.exports = class MathCommand extends Command {
const solved = math.eval(expression);
return msg.say(solved)
.catch(() => msg.say('Invalid statement.'));
} catch (err) {
} catch(err) {
return msg.say('Invalid statement.');
}
}
+3 -3
View File
@@ -13,12 +13,12 @@ module.exports = class NitroCommand extends Command {
}
run(msg) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const embed = new RichEmbed()
.setAuthor('Discord Nitro')
.setThumbnail('https://pbs.twimg.com/profile_images/814184180649197568/y2eZcVMq.jpg')
.setThumbnail('https://i.imgur.com/wzhMMnl.jpg')
.setColor(0x748BD9)
.setURL('https://discordapp.com/nitro')
.setDescription(stripIndents`
+3 -3
View File
@@ -11,10 +11,10 @@ module.exports = class SpamCommand extends Command {
}
run(msg) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
return msg.channel.send({files: ['https://i.imgur.com/2JFu5xE.jpg']})
return msg.channel.send({ files: ['https://i.imgur.com/2JFu5xE.jpg'] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
}
};
+6 -9
View File
@@ -15,7 +15,7 @@ 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)
if(title.length < 200)
return true;
return `Please keep your title under 200 characters, you have ${title.length}.`;
}
@@ -26,7 +26,7 @@ module.exports = class StrawpollCommand extends Command {
type: 'string',
infinite: true,
validate: choice => {
if (choice.length < 160)
if(choice.length < 160)
return true;
return `Please keep your options under 160 characters each, you have ${choice.length}.`;
}
@@ -37,22 +37,19 @@ module.exports = class StrawpollCommand extends Command {
async run(msg, args) {
const { title, options } = args;
if (options.length < 2)
if(options.length < 2)
return msg.say('You provided less than two choices.');
if (options.length > 31)
if(options.length > 31)
return msg.say('You provided more than thirty choices.');
try {
const { body } = await request
.post('https://strawpoll.me/api/v2/polls')
.send({
title,
options
});
.send({ title, options });
return msg.say(stripIndents`
${body.title}
http://strawpoll.me/${body.id}
`);
} catch (err) {
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+3 -3
View File
@@ -13,8 +13,8 @@ module.exports = class TodayCommand extends Command {
}
async run(msg) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
try {
const { text } = await request
@@ -30,7 +30,7 @@ module.exports = class TodayCommand extends Command {
.setTimestamp()
.setDescription(`${events[random].year}: ${events[random].text}`);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+3 -3
View File
@@ -16,8 +16,8 @@ module.exports = class WouldYouRatherCommand extends Command {
}
async run(msg) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
try {
const { body } = await request
@@ -28,7 +28,7 @@ module.exports = class WouldYouRatherCommand extends Command {
.setColor(0x9797FF)
.setDescription(`${body.choicea} OR ${body.choiceb}?`);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+4 -4
View File
@@ -15,15 +15,15 @@ module.exports = class CatCommand extends Command {
}
async run(msg) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
try {
const { body } = await request
.get('http://random.cat/meow');
return msg.channel.send({files: [body.file]})
return msg.channel.send({ files: [body.file] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
} catch (err) {
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+4 -4
View File
@@ -12,15 +12,15 @@ module.exports = class DogCommand extends Command {
}
async run(msg) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
try {
const { body } = await request
.get('https://random.dog/woof.json');
return msg.channel.send({files: [body.url]})
return msg.channel.send({ files: [body.url] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
} catch (err) {
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+3 -3
View File
@@ -15,11 +15,11 @@ module.exports = class XiaoCommand extends Command {
}
run(msg) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const xiao = xiaos[Math.floor(Math.random() * xiaos.length)];
return msg.channel.send({files: [xiao]})
return msg.channel.send({ files: [xiao] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
}
};
+3 -3
View File
@@ -14,7 +14,7 @@ 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()))
if(['male', 'female'].includes(gender.toLowerCase()))
return true;
return 'Please enter either `male` or `female`.';
},
@@ -27,10 +27,10 @@ module.exports = class RandomNameCommand extends Command {
run(msg, args) {
const { gender } = args;
const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
if (gender === 'male') {
if(gender === 'male') {
const name = maleNames[Math.floor(Math.random() * maleNames.length)];
return msg.say(`${name} ${lastName}`);
} else if (gender === 'female') {
} else if(gender === 'female') {
const name = femaleNames[Math.floor(Math.random() * femaleNames.length)];
return msg.say(`${name} ${lastName}`);
}
+6 -8
View File
@@ -20,21 +20,19 @@ module.exports = class BotSearchCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { bot } = args;
try {
const { body } = await request
.get(`https://bots.discord.pw/api/bots/${bot.id}`)
.set({
'Authorization': process.env.DISCORD_BOTS_KEY
});
.set({ 'Authorization': process.env.DISCORD_BOTS_KEY });
const embed = new RichEmbed()
.setColor(0x9797FF)
.setAuthor('Discord Bots', 'https://cdn.discordapp.com/icons/110373943822540800/47336ad0631ac7aac0a48a2ba6246c65.jpg')
.setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg')
.setTitle(body.name)
.setURL('https://bots.discord.pw/')
.setURL(`https://bots.discord.pw/bots/${bot.id}`)
.setDescription(body.description)
.addField('**Library:**',
body.library, true)
@@ -43,7 +41,7 @@ module.exports = class BotSearchCommand extends Command {
.addField('**Prefix:**',
body.prefix, true);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The bot may not have been found.');
}
}
+3 -3
View File
@@ -21,8 +21,8 @@ module.exports = class DefineCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
@@ -33,7 +33,7 @@ module.exports = class DefineCommand extends Command {
.setTitle(body[0].word)
.setDescription(body[0].text);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The word may not have been found.');
}
}
+3 -3
View File
@@ -18,7 +18,7 @@ module.exports = class DiscrimCommand extends Command {
prompt: 'Which discriminator would you like to search for?',
type: 'string',
validate: discrim => {
if (/[0-9]+$/g.test(discrim) && discrim.length === 4)
if(/[0-9]+$/g.test(discrim) && discrim.length === 4)
return true;
return `${discrim} is not a valid discriminator.`;
}
@@ -28,8 +28,8 @@ module.exports = class DiscrimCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { discrim } = args;
const users = await this.client.users.filter(u => u.discriminator === discrim).map(u => u.username).sort();
+3 -3
View File
@@ -20,8 +20,8 @@ module.exports = class ForecastCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
@@ -48,7 +48,7 @@ module.exports = class ForecastCommand extends Command {
.addField(`**${forecasts[6].day} - ${forecasts[6].date}:**`,
`**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The location may not have been found.');
}
}
+2 -2
View File
@@ -29,10 +29,10 @@ module.exports = class GoogleCommand extends Command {
.get(`https://www.google.com/search?q=${query}`);
const $ = cheerio.load(text);
let href = $('.r').first().find('a').first().attr('href');
if (!href) throw new Error('No Results');
if(!href) throw new Error('No Results');
href = querystring.parse(href.replace('/url?', ''));
return message.edit(href.q);
} catch (err) {
} catch(err) {
return message.edit('No Results Found.');
}
}
+4 -4
View File
@@ -21,8 +21,8 @@ module.exports = class IMDBCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
@@ -30,7 +30,7 @@ module.exports = class IMDBCommand extends Command {
.get(`http://www.omdbapi.com/?t=${query}&plot=full`);
const embed = new RichEmbed()
.setColor(0xDBA628)
.setAuthor('IMDB', 'http://static.wixstatic.com/media/c65cbf_31901b544fe24f1890134553bf40c8be.png')
.setAuthor('IMDB', 'https://i.imgur.com/sXwwIQs.png')
.setURL(`http://www.imdb.com/title/${body.imdbID}`)
.setTitle(`${body.Title} (${body.imdbRating} Score)`)
.setDescription(body.Plot.substr(0, 2000))
@@ -49,7 +49,7 @@ module.exports = class IMDBCommand extends Command {
.addField('**Actors:**',
body.Actors);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The film may not have been found.');
}
}
+5 -5
View File
@@ -15,7 +15,7 @@ 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)
if(zoom < 21 && zoom > 0)
return true;
return 'Please enter a zoom value from 1-20';
}
@@ -31,16 +31,16 @@ module.exports = class MapCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { zoom, query } = args;
try {
const { body } = await request
.get(`https://maps.googleapis.com/maps/api/staticmap?center=${query}&zoom=${zoom}&size=500x500&key=${process.env.GOOGLE_KEY}`);
return msg.channel.send({files: [{attachment: body}]})
return msg.channel.send({ files: [{attachment: body}] })
.catch(err => msg.say(`An Error Occurred: ${err}`));
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The location may not have been found.');
}
}
+2 -2
View File
@@ -27,10 +27,10 @@ module.exports = class NeopetCommand extends Command {
.get(`http://www.sunnyneo.com/petimagefinder.php?name=${query}&size=5&mood=1`);
const $ = cheerio.load(text);
const link = $('textarea').first().text();
if (!link.includes('cp'))
if(!link.includes('cp'))
return msg.say('This is not a valid pet name.');
return msg.say(link);
} catch (err) {
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+4 -4
View File
@@ -21,8 +21,8 @@ module.exports = class OsuCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
@@ -30,7 +30,7 @@ module.exports = class OsuCommand extends Command {
.get(`https://osu.ppy.sh/api/get_user?k=${process.env.OSU_KEY}&u=${query}&type=string`);
const embed = new RichEmbed()
.setColor(0xFF66AA)
.setAuthor('osu!', 'http://vignette3.wikia.nocookie.net/osugame/images/c/c9/Logo.png/revision/latest?cb=20151219073209')
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
.setURL('https://osu.ppy.sh/')
.addField('**Username:**',
body[0].username, true)
@@ -57,7 +57,7 @@ module.exports = class OsuCommand extends Command {
.addField('**A:**',
body[0].count_rank_a, true);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The user may not have been found.');
}
}
+4 -4
View File
@@ -21,8 +21,8 @@ module.exports = class SoundCloudCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
@@ -30,7 +30,7 @@ module.exports = class SoundCloudCommand extends Command {
.get(`https://api.soundcloud.com/tracks?q=${query}&client_id=${process.env.SOUNDCLOUD_KEY}`);
const embed = new RichEmbed()
.setColor(0xF15A22)
.setAuthor(body[0].title, 'http://icons.iconarchive.com/icons/danleech/simple/1024/soundcloud-icon.png')
.setAuthor(body[0].title, 'https://i.imgur.com/lFIz7RU.png')
.setURL(body[0].permalink_url)
.setThumbnail(body[0].artwork_url)
.addField('**Artist:**',
@@ -44,7 +44,7 @@ module.exports = class SoundCloudCommand extends Command {
.addField('**Favorited Count:**',
body[0].favoritings_count, true);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The song may not have been found.');
}
}
+4 -4
View File
@@ -21,8 +21,8 @@ module.exports = class UrbanCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
@@ -30,14 +30,14 @@ module.exports = class UrbanCommand extends Command {
.get(`http://api.urbandictionary.com/v0/define?term=${query}`);
const embed = new RichEmbed()
.setColor(0x32a8f0)
.setAuthor('Urban Dictionary', 'http://a1.mzstatic.com/eu/r30/Purple71/v4/66/54/68/6654683f-cacd-4a55-1784-f14257f77874/icon175x175.png')
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
.setURL(body.list[0].permalink)
.setTitle(body.list[0].word)
.setDescription(body.list[0].definition.substr(0, 2000))
.addField('**Example:**',
body.list[0].example.substr(0, 2000) || 'None');
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The word may not have been found.');
}
}
+5 -7
View File
@@ -21,19 +21,17 @@ module.exports = class WattpadCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
const { body } = await request
.get(`https://api.wattpad.com:443/v4/stories?query=${query}&limit=1`)
.set({
'Authorization': `Basic ${process.env.WATTPAD_KEY}`
});
.set({ 'Authorization': `Basic ${process.env.WATTPAD_KEY}` });
const embed = new RichEmbed()
.setColor(0xF89C34)
.setAuthor('Wattpad', 'http://www.selfpubtoolbox.com/wp-content/uploads/2015/05/a6044fd3a88acd5043860484db972ca6.png')
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
.setURL(body.stories[0].url)
.setTitle(body.stories[0].title)
.setDescription(body.stories[0].description.substr(0, 2000))
@@ -50,7 +48,7 @@ module.exports = class WattpadCommand extends Command {
.addField('**Comments:**',
body.stories[0].commentCount, true);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The book may not have been found.');
}
}
+3 -3
View File
@@ -20,8 +20,8 @@ module.exports = class WeatherCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
@@ -57,7 +57,7 @@ module.exports = class WeatherCommand extends Command {
.addField('**Wind Speed:**',
body.query.results.channel.wind.speed, true);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The location may not have been found.');
}
}
+4 -4
View File
@@ -21,8 +21,8 @@ module.exports = class WikipediaCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
@@ -32,10 +32,10 @@ module.exports = class WikipediaCommand extends Command {
.setColor(0xE7E7E7)
.setTitle(body.query.pages[0].title)
.setURL(`https://en.wikipedia.org/wiki/${query}`)
.setAuthor('Wikipedia', 'https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1122px-Wikipedia-logo-v2.svg.png')
.setAuthor('Wikipedia', 'https://i.imgur.com/a4eeEhh.png')
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The page may not have been found.');
}
}
+4 -4
View File
@@ -21,8 +21,8 @@ module.exports = class YouTubeCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
@@ -32,11 +32,11 @@ module.exports = class YouTubeCommand extends Command {
.setColor(0xDD2825)
.setTitle(body.items[0].snippet.title)
.setDescription(body.items[0].snippet.description)
.setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`, 'https://cdn3.iconfinder.com/data/icons/social-icons-5/607/YouTube_Play.png')
.setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`, 'https://i.imgur.com/hkUafwu.png')
.setURL(`https://www.youtube.com/watch?v=${body.items[0].id.videoId}`)
.setThumbnail(body.items[0].snippet.thumbnails.default.url);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The video may not have been found.');
}
}
+6 -6
View File
@@ -21,19 +21,19 @@ module.exports = class YuGiOhCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { query } = args;
try {
const { body } = await request
.get(`http://yugiohprices.com/api/card_data/${query}`);
if (body.data.card_type === 'monster') {
if(body.data.card_type === 'monster') {
const embed = new RichEmbed()
.setColor(0xBE5F1F)
.setTitle(body.data.name)
.setDescription(body.data.text)
.setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558')
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
.addField('**Card Type:**',
'Monster', true)
.addField('**Type:**',
@@ -52,11 +52,11 @@ module.exports = class YuGiOhCommand extends Command {
.setColor(0xBE5F1F)
.setTitle(body.data.name)
.setDescription(body.data.text)
.setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558')
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
.addField('**Card Type:**',
body.data.card_type, true);
return msg.embed(embed);
} catch (err) {
} catch(err) {
return msg.say('An Error Occurred. The card may not have been found.');
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ module.exports = class BinaryCommand extends Command {
prompt: 'What text would you like to convert to binary?',
type: 'string',
validate: text => {
if (binary(text).length < 2000)
if(binary(text).length < 2000)
return true;
return 'Your message content is too long.';
},
+1 -1
View File
@@ -14,7 +14,7 @@ module.exports = class CowsayCommand extends Command {
prompt: 'What text would you like the cow to say?',
type: 'string',
validate: text => {
if (text.length < 1500)
if(text.length < 1500)
return true;
return `Please keep your content under 1500 characters, you have ${text.length}.`;
}
+2 -2
View File
@@ -19,8 +19,8 @@ module.exports = class EmbedCommand extends Command {
}
run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { text } = args;
const embed = new RichEmbed()
+1 -1
View File
@@ -15,7 +15,7 @@ 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)
if(letterTrans(text, dictionary, ' ').length < 1999)
return true;
return 'Your message content is too long.';
},
+1 -1
View File
@@ -15,7 +15,7 @@ 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)
if(wordTrans(text, dictionary).length < 1999)
return true;
return 'Your message content is too long.';
},
+1 -1
View File
@@ -24,7 +24,7 @@ module.exports = class SayCommand extends Command {
}
run(msg, args) {
if (!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES'))
if(!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES'))
return msg.say('This Command requires the `Manage Messages` Permission.');
const { text } = args;
msg.delete();
+1 -1
View File
@@ -15,7 +15,7 @@ module.exports = class TemmieCommand extends Command {
prompt: 'What text would you like to convert to Temmie speak?',
type: 'string',
validate: text => {
if (wordTrans(text, dictionary).length < 1999)
if(wordTrans(text, dictionary).length < 1999)
return true;
return 'Your message content is too long.';
},
+3 -3
View File
@@ -28,16 +28,16 @@ module.exports = class WebhookCommand extends Command {
}
async run(msg, args) {
if (!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES'))
if(!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES'))
return msg.say('This Command requires the `Manage Messages` Permission.');
const { content } = args;
try {
msg.delete();
await request
.post(process.env.WEBHOOK_URL)
.send({content});
.send({ content });
return null;
} catch (err) {
} catch(err) {
return msg.say('An Unknown Error Occurred.');
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ module.exports = class ZalgoCommand extends Command {
prompt: 'What text would you like to convert to zalgo?',
type: 'string',
validate: text => {
if (text.length < 500) {
if(text.length < 500) {
return true;
}
return `Please keep your text under 500 characters, you have ${text.length}.`;
+4 -4
View File
@@ -28,14 +28,14 @@ module.exports = class UserInfoCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { user } = args;
const member = await msg.guild.fetchMember(user);
const member = msg.guild.member(user);
let stat;
let color;
switch (user.presence.status) {
switch(user.presence.status) {
case 'online':
stat = '<:vpOnline:212789758110334977> Online';
color = 0x00AE86;
+1 -1
View File
@@ -14,7 +14,7 @@ module.exports = class ClearSettingCommand extends Command {
prompt: 'What setting do you want to clear? `modLog`, `memberLog`, or `staffRole`?',
type: 'string',
validate: setting => {
if (['modLog', 'memberLog', 'staffRole'].includes(setting))
if(['modLog', 'memberLog', 'staffRole'].includes(setting))
return true;
return 'Please enter either `modLog`, `memberLog`, or `staffRole`.';
}
+7 -9
View File
@@ -28,8 +28,8 @@ module.exports = class HelpCommand extends Command {
const { command } = args;
const commands = this.client.registry.findCommands(command, false, msg);
const showAll = command && command.toLowerCase() === 'all';
if (command && !showAll) {
if (commands.length === 1) {
if(command && !showAll) {
if(commands.length === 1) {
return msg.say(stripIndents`
__Command **${commands[0].name}**:__ *${commands[0].description}*
${commands[0].guildOnly ? 'Usable Only in Servers' : 'Usable in Servers and DM'}
@@ -38,17 +38,15 @@ module.exports = class HelpCommand extends Command {
**Group:** ${commands[0].group.name}
${commands[0].details || ''}
`);
} else if (commands.length > 1) {
} else if(commands.length > 1) {
return msg.say('Multiple Commands Found. Please be more specific.');
} else {
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.`);
return msg.say(`Could not identify command. Use ${msg.usage(null)} to view a list of commands you can use.`);
}
} else {
const embed = new RichEmbed()
.setTitle(!showAll ? `Commands Available in ${msg.guild ? msg.guild.name : 'this DM'}` : 'All Commands')
.setDescription(`Use ${this.usage('<command>', null, null)} to view detailed information about a specific command.`)
.setDescription(`Use ${msg.usage('<command>')} to view detailed information about a specific command.`)
.setColor(0x00AE86);
for (const group of this.client.registry.groups.array()) {
embed.addField(group.name,
@@ -57,9 +55,9 @@ module.exports = class HelpCommand extends Command {
group.commands.map(c => `\`${c.name}\``).join(', '));
}
try {
await msg.author.send({embed});
await msg.author.send({ embed });
return msg.say(':mailbox_with_mail: Sent you a DM with information.');
} catch (err) {
} catch(err) {
return msg.say('Failed to send DM. You probably have DMs disabled.');
}
}
+43 -5
View File
@@ -1,5 +1,6 @@
const { Command } = require('discord.js-commando');
const { RichEmbed } = require('discord.js');
const { oneLine } = require('common-tags');
const { version } = require('../../package');
const moment = require('moment');
require('moment-duration-format');
@@ -18,14 +19,18 @@ module.exports = class InfoCommand extends Command {
}
async run(msg) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const guilds = await this.client.shard.fetchClientValues('guilds.size');
const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)');
const embed = new RichEmbed()
.setColor(0x00AE86)
.setFooter(`©2017 dragonfire535 | Version ${version} | Created ${moment.duration(Date.now() - this.client.user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago!`)
.setFooter(oneLine`
©2017 dragonfire535 |
Version ${version} |
Created ${moment.duration(Date.now() - this.client.user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago!
`)
.addField('Servers',
`${this.client.guilds.size} / ${guilds.reduce((prev, val) => prev + val, 0)}`, true)
.addField('Shards',
@@ -45,9 +50,42 @@ module.exports = class InfoCommand extends Command {
.addField('Library',
'[discord.js](https://discord.js.org/#/)', true)
.addField('Modules',
'[commando](https://github.com/Gawdl3y/discord.js-commando), [zalgoize](https://github.com/clux/zalgolize), [superagent](https://github.com/visionmedia/superagent), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/), [sequelize](http://docs.sequelizejs.com/en/v3/), [pg](https://github.com/brianc/node-postgres)')
oneLine`
[commando](https://github.com/Gawdl3y/discord.js-commando),
[zalgoize](https://github.com/clux/zalgolize),
[superagent](https://github.com/visionmedia/superagent),
[mathjs](http://mathjs.org/),
[moment](http://momentjs.com),
[moment-duration-format](https://github.com/jsmreese/moment-duration-format),
[jimp](https://github.com/oliver-moran/jimp),
[cheerio](https://cheerio.js.org/),
[sequelize](http://docs.sequelizejs.com/en/v3/),
[pg](https://github.com/brianc/node-postgres)
`
)
.addField('APIs',
'[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io/), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com/), [Yahoo Weather](https://developer.yahoo.com/weather/), [Wikipedia](https://en.wikipedia.org/w/api.php), [Google Static Maps](https://developers.google.com/maps/documentation/static-maps/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [rrrather](http://www.rrrather.com/botapi), [SoundCloud](https://developers.soundcloud.com/), [random.cat](http://random.cat/), [random.dog](https://random.dog/)');
oneLine`
[Wattpad](https://developer.wattpad.com/docs/api),
[Wordnik](http://developer.wordnik.com/docs.html),
[osu!](https://osu.ppy.sh/p/api),
[memegen.link](https://memegen.link/),
[Yugioh Prices](http://docs.yugiohprices.apiary.io/#),
[YouTube Data](https://developers.google.com/youtube/v3/),
[Discord Bots](https://bots.discord.pw/api),
[Today in History](http://history.muffinlabs.com/#api),
[jService](http://jservice.io/),
[Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation),
[OMDB](http://www.omdbapi.com/),
[Yahoo Weather](https://developer.yahoo.com/weather/),
[Wikipedia](https://en.wikipedia.org/w/api.php),
[Google Static Maps](https://developers.google.com/maps/documentation/static-maps/),
[Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API),
[rrrather](http://www.rrrather.com/botapi),
[SoundCloud](https://developers.soundcloud.com/),
[random.cat](http://random.cat/),
[random.dog](https://random.dog/)
`
);
return msg.embed(embed);
}
};
+3 -3
View File
@@ -24,11 +24,11 @@ module.exports = class ShardInfoCommand extends Command {
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
if(msg.channel.type !== 'dm')
if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { shard } = args;
if (shard > this.client.options.shardCount - 1 || shard < 0)
if(shard > this.client.options.shardCount - 1 || shard < 0)
return msg.say('The Shard ID is not valid.');
const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)');
const uptime = await this.client.shard.fetchClientValues('uptime');
+9 -11
View File
@@ -32,22 +32,20 @@ client.registry
['roleplay', 'Roleplay']
])
.registerDefaultGroups()
.registerDefaultCommands({
help: false
})
.registerDefaultCommands({ help: false })
.registerCommandsIn(path.join(__dirname, 'commands'));
client.on('guildMemberAdd', (member) => {
const channel = member.guild.channels.get(member.guild.settings.get('memberLog'));
if (!channel) return;
if (!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
if(!channel) return;
if(!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
channel.send(`Welcome ${member.user.username}!`);
});
client.on('guildMemberRemove', (member) => {
const channel = member.guild.channels.get(member.guild.settings.get('memberLog'));
if (!channel) return;
if (!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
if(!channel) return;
if(!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
channel.send(`Bye ${member.user.username}...`);
});
@@ -59,13 +57,13 @@ client.on('guildCreate', async(guild) => {
try {
await carbon(count);
console.log(`[Carbon] Successfully posted to Carbon.`);
} catch (err) {
} catch(err) {
console.log(`[Carbon] Failed to post to Carbon. ${err}`);
}
try {
await discordBots(count, client.user.id);
console.log(`[Discord Bots] Successfully posted to Discord Bots.`);
} catch (err) {
} catch(err) {
console.log(`[Discord Bots] Failed to post to Discord Bots. ${err}`);
}
});
@@ -78,13 +76,13 @@ client.on('guildDelete', async(guild) => {
try {
await carbon(count);
console.log(`[Carbon] Successfully posted to Carbon.`);
} catch (err) {
} catch(err) {
console.log(`[Carbon] Failed to post to Carbon. ${err}`);
}
try {
await discordBots(count, client.user.id);
console.log(`[Discord Bots] Successfully posted to Discord Bots.`);
} catch (err) {
} catch(err) {
console.log(`[Discord Bots] Failed to post to Discord Bots. ${err}`);
}
});
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "18.0.0",
"version": "18.0.1",
"description": "A Discord Bot",
"main": "shardingmanager.js",
"scripts": {
@@ -35,7 +35,7 @@
"cheerio": "^0.22.0",
"custom-translate": "dragonfire535/custom-translate",
"discord.js": "hydrabolt/discord.js",
"discord.js-commando": "dragonfire535/discord.js-commando",
"discord.js-commando": "gawdl3y/discord.js-commando",
"jimp": "^0.2.27",
"mathjs": "^3.12.2",
"moment": "^2.18.1",
+20 -20
View File
@@ -76,7 +76,7 @@ class SequelizeProvider extends SettingProvider {
let settings;
try {
settings = JSON.parse(row.dataValues.settings);
} catch (err) {
} catch(err) {
client.emit('warn', `PostgreSQLProvider couldn't parse the settings stored for guild ${row.dataValues.guild}.`);
continue;
}
@@ -84,7 +84,7 @@ class SequelizeProvider extends SettingProvider {
const guild = row.dataValues.guild !== '0' ? row.dataValues.guild : 'global';
this.settings.set(guild, settings);
if (guild !== 'global' && !client.guilds.has(row.dataValues.guild)) continue;
if(guild !== 'global' && !client.guilds.has(row.dataValues.guild)) continue;
this.setupGuild(guild, settings);
}
@@ -95,18 +95,18 @@ class SequelizeProvider extends SettingProvider {
.set('groupStatusChange', (guild, group, enabled) => this.set(guild, `grp-${group.id}`, enabled))
.set('guildCreate', guild => {
const settings = this.settings.get(guild.id);
if (!settings) return;
if(!settings) return;
this.setupGuild(guild.id, settings);
})
.set('commandRegister', command => {
for (const [guild, settings] of this.settings) {
if (guild !== 'global' && !client.guilds.has(guild)) continue;
if(guild !== 'global' && !client.guilds.has(guild)) continue;
this.setupGuildCommand(client.guilds.get(guild), command, settings);
}
})
.set('groupRegister', group => {
for (const [guild, settings] of this.settings) {
if (guild !== 'global' && !client.guilds.has(guild)) continue;
if(guild !== 'global' && !client.guilds.has(guild)) continue;
this.setupGuildGroup(client.guilds.get(guild), group, settings);
}
});
@@ -127,32 +127,32 @@ class SequelizeProvider extends SettingProvider {
async set(guild, key, val) {
guild = this.constructor.getGuildID(guild);
let settings = this.settings.get(guild);
if (!settings) {
if(!settings) {
settings = {};
this.settings.set(guild, settings);
}
settings[key] = val;
await this.model.upsert({ guild: guild !== 'global' ? guild : '0', settings: JSON.stringify(settings) }, { where: { guild: guild !== 'global' ? guild : '0' } }); // eslint-disable-line max-len
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;
await this.model.upsert({ guild: guild !== 'global' ? guild : '0', settings: JSON.stringify(settings) }, { where: { guild: guild !== 'global' ? guild : '0' } }); // eslint-disable-line max-len
if (guild === 'global') this.updateOtherShards(key, undefined);
if(guild === 'global') this.updateOtherShards(key, undefined);
return val;
}
async clear(guild) {
guild = this.constructor.getGuildID(guild);
if (!this.settings.has(guild)) return;
if(!this.settings.has(guild)) return;
this.settings.delete(guild);
await this.model.destroy({ where: { guild: guild !== 'global' ? guild : '0' } });
}
@@ -164,12 +164,12 @@ 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;
if(typeof settings.prefix !== 'undefined') {
if(guild) guild._commandPrefix = settings.prefix;
else this.client._commandPrefix = settings.prefix;
}
@@ -186,9 +186,9 @@ class SequelizeProvider extends SettingProvider {
* @private
*/
setupGuildCommand(guild, command, settings) {
if (typeof settings[`cmd-${command.name}`] === 'undefined') return;
if (guild) {
if (!guild._commandsEnabled) guild._commandsEnabled = {};
if(typeof settings[`cmd-${command.name}`] === 'undefined') return;
if(guild) {
if(!guild._commandsEnabled) guild._commandsEnabled = {};
guild._commandsEnabled[command.name] = settings[`cmd-${command.name}`];
} else {
command._globalEnabled = settings[`cmd-${command.name}`];
@@ -203,9 +203,9 @@ class SequelizeProvider extends SettingProvider {
* @private
*/
setupGuildGroup(guild, group, settings) {
if (typeof settings[`grp-${group.id}`] === 'undefined') return;
if (guild) {
if (!guild._groupsEnabled) guild._groupsEnabled = {};
if(typeof settings[`grp-${group.id}`] === 'undefined') return;
if(guild) {
if(!guild._groupsEnabled) guild._groupsEnabled = {};
guild._groupsEnabled[group.id] = settings[`grp-${group.id}`];
} else {
group._globalEnabled = settings[`grp-${group.id}`];
@@ -219,7 +219,7 @@ class SequelizeProvider extends SettingProvider {
* @private
*/
updateOtherShards(key, val) {
if (!this.client.shard) return;
if(!this.client.shard) return;
key = JSON.stringify(key);
val = typeof val !== 'undefined' ? JSON.stringify(val) : 'undefined';
this.client.shard.broadcastEval(`
+1 -3
View File
@@ -1,7 +1,5 @@
const { ShardingManager } = require('discord.js');
const Manager = new ShardingManager('./index.js', {
token: process.env.TOKEN
});
const Manager = new ShardingManager('./index.js', { token: process.env.TOKEN });
Manager.spawn();
process.on('unhandledRejection', console.error);
+4 -2
View File
@@ -1,7 +1,7 @@
const Sequelize = require('sequelize');
const database = new Sequelize(process.env.DATABASE_URL, { logging: false });
module.exports = class Database {
class Database {
static get db() {
return database;
}
@@ -17,4 +17,6 @@ module.exports = class Database {
.then(() => console.log('[Database] Ready!'))
.catch(err => console.error(`[Database] Unable to connect: ${err}`));
}
};
}
module.exports = Database;
+9 -14
View File
@@ -1,27 +1,22 @@
const request = require('superagent');
module.exports = class Stats {
class Stats {
constructor() {
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
}
static discordBots(count, userID) {
static discordBots(server_count, userID) {
return request
.post(`https://bots.discord.pw/api/bots/${userID}/stats`)
.set({
'Authorization': process.env.DISCORD_BOTS_KEY
})
.send({
server_count: count
});
.set({ 'Authorization': process.env.DISCORD_BOTS_KEY })
.send({ server_count });
}
static carbon(count) {
static carbon(servercount) {
return request
.post('https://www.carbonitex.net/discord/data/botdata.php')
.send({
key: process.env.CARBON_KEY,
servercount: count
});
.send({ key: process.env.CARBON_KEY, servercount });
}
};
}
module.exports = Stats;