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
+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.');
}
}