This commit is contained in:
Daniel Odendahl Jr
2017-06-01 08:44:02 +00:00
parent 7802bb49cb
commit 14f85f94bd
129 changed files with 1915 additions and 1720 deletions
+53 -31
View File
@@ -13,7 +13,6 @@ module.exports = class BanCommand extends Command {
guildOnly: true,
clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['BAN_MEMBERS'],
allowStaff: true,
args: [
{
key: 'member',
@@ -24,9 +23,12 @@ module.exports = class BanCommand extends Command {
key: 'reason',
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) return true;
return 'Invalid Reason. Reason must be under 140 characters.';
validate: (reason) => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
}
}
]
@@ -35,37 +37,57 @@ module.exports = class BanCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { member, reason } = args;
if (!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
if (!member.bannable) {
return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
}
try {
try {
await member.user.send(stripIndents`
You were banned from ${msg.guild.name}!
Reason: ${reason}.
`);
} catch (err) {
await msg.say('Failed to Send DM.');
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, {
max: 1,
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`
**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF0000)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Ban.');
}
await member.ban({ days: 7, reason });
msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF0000)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}
`);
modlogs.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
return msg.say('Aborting Ban.');
}
}
};
+52 -30
View File
@@ -6,13 +6,13 @@ module.exports = class KickCommand extends Command {
constructor(client) {
super(client, {
name: 'kick',
aliases: ['kickke'],
group: 'moderation',
memberName: 'kick',
description: 'Kicks a user and logs the kick to the mod logs.',
guildOnly: true,
clientPermissions: ['KICK_MEMBERS'],
userPermissions: ['KICK_MEMBERS'],
allowStaff: true,
args: [
{
key: 'member',
@@ -24,8 +24,11 @@ module.exports = class KickCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) return true;
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.';
}
}
}
]
@@ -34,37 +37,56 @@ module.exports = class KickCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { member, reason } = args;
if (!member.kickable) return msg.say('This member is not kickable. Perhaps they have a higher role than me?');
if (!member.kickable) {
return msg.say('This member is not kickable. Perhaps they have a higher role than me?');
}
try {
try {
await member.user.send(stripIndents`
You were kicked from ${msg.guild.name}!
Reason: ${reason}.
`);
} catch (err) {
await msg.say('Failed to Send DM.');
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, {
max: 1,
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`
**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFA500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Kick.');
}
await member.kick({ reason });
msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFA500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}
`);
modlogs.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
return msg.say('Aborting Kick.');
}
}
};
+16 -25
View File
@@ -7,22 +7,24 @@ module.exports = class LockdownCommand extends Command {
name: 'lockdown',
group: 'moderation',
memberName: 'lockdown',
description: 'Locks down the current channel or removes a lockdown, which prevents non-administrator members from speaking.',
description: 'Locks down the current channel or removes a lockdown.',
guildOnly: true,
clientPermissions: ['ADMINISTRATOR'],
userPermissions: ['ADMINISTRATOR'],
allowStaff: true,
args: [
{
key: 'type',
prompt: 'Please enter either `start` or `stop`.',
type: 'string',
validate: type => {
if (['start', 'stop'].includes(type.toLowerCase())) return true;
return 'Please enter either `start` or `stop`.';
default: 'start',
validate: (type) => {
if (['start', 'stop'].includes(type.toLowerCase())) {
return true;
} else {
return 'Please enter either `start` or `stop`.';
}
},
parse: type => type.toLowerCase(),
default: 'start'
parse: (type) => type.toLowerCase()
}
]
});
@@ -31,25 +33,14 @@ module.exports = class LockdownCommand extends Command {
async run(msg, args) {
const { type } = args;
if (type === 'start') {
try {
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false });
const staffRole = msg.guild.settings.get('staffRole');
if (staffRole && !msg.channel.permissionOverwrites.has(staffRole))
await msg.channel.overwritePermissions(msg.guild.roles.get(staffRole), { SEND_MESSAGES: true });
return msg.say(stripIndents`
Lockdown Started, users without Administrator ${staffRole ? 'or the Staff Role ' : ''}can no longer post messages.
Please use \`lockdown stop\` to end the lockdown.
`);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
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.
`);
} else if (type === 'stop') {
try {
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: null });
return msg.say('Lockdown Ended.');
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: null });
return msg.say('Lockdown Ended.');
}
}
};
+8 -5
View File
@@ -6,7 +6,7 @@ module.exports = class PruneCommand extends Command {
name: 'prune',
group: 'moderation',
memberName: 'prune',
description: 'Deletes a specified number of messages from the current channel, up to 99.',
description: 'Deletes messages from the current channel, up to 99.',
guildOnly: true,
throttling: {
usages: 1,
@@ -14,21 +14,24 @@ module.exports = class PruneCommand extends Command {
},
clientPermissions: ['READ_MESSAGE_HISTORY', 'MANAGE_MESSAGES'],
userPermissions: ['MANAGE_MESSAGES'],
allowStaff: true,
args: [
{
key: 'count',
label: 'amount of messages',
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;
return 'Invalid Count. Count must be from 1-99.';
validate: (count) => {
if (count < 100 && count > 0) {
return true;
} else {
return 'Invalid Count. Count must be from 1-99.';
}
}
}
]
});
}
async run(msg, args) {
const { count } = args;
try {
+54 -32
View File
@@ -13,7 +13,6 @@ module.exports = class SoftbanCommand extends Command {
guildOnly: true,
clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['KICK_MEMBERS'],
allowStaff: true,
args: [
{
key: 'member',
@@ -24,9 +23,12 @@ module.exports = class SoftbanCommand extends Command {
key: 'reason',
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) return true;
return 'Invalid Reason. Reason must be under 140 characters.';
validate: (reason) => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
}
}
]
@@ -35,38 +37,58 @@ module.exports = class SoftbanCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { member, reason } = args;
if (!member.bannable) return msg.say('This member is not softbannable. Perhaps they have a higher role than me?');
if (!member.bannable) {
return msg.say('This member is not softbannable. Perhaps they have a higher role than me?');
}
try {
try {
await member.user.send(stripIndents`
You were softbanned from ${msg.guild.name}!
Reason: ${reason}.
`);
} catch (err) {
await msg.say('Failed to Send DM.');
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, {
max: 1,
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`
**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF4500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Softban.');
}
await member.ban({ days: 7, reason });
await msg.guild.unban(member.user);
msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF4500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}
`);
modlogs.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
return msg.say('Aborting Softban.');
}
}
};
+44 -25
View File
@@ -13,20 +13,22 @@ module.exports = class UnbanCommand extends Command {
guildOnly: true,
clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['BAN_MEMBERS'],
allowStaff: true,
args: [
{
key: 'id',
prompt: 'What member do you want to unban? Please enter the ID of the user.',
prompt: 'What is the id of the member you want to unban?',
type: 'string'
},
{
key: 'reason',
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) return true;
return 'Invalid Reason. Reason must be under 140 characters.';
validate: (reason) => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
}
}
]
@@ -35,31 +37,48 @@ module.exports = class UnbanCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { id, reason } = args;
const 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.guild.unban(member, reason);
msg.say(':ok_hand:');
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}
`);
modlogs.send({ embed });
return null;
await msg.say(`Are you sure you want to unban ${member.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
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`
**Member:** ${member.tag} (${member.id})
**Action:** Unban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0x00AE86)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.tag} (${member.id})
**Action:** Unban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Unban.');
}
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
return msg.say('Aborting Unban.');
}
}
};
+48 -27
View File
@@ -6,11 +6,11 @@ module.exports = class WarnCommand extends Command {
constructor(client) {
super(client, {
name: 'warn',
aliases: ['warnne'],
group: 'moderation',
memberName: 'warn',
description: 'Warns a user and logs the warn to the mod logs.',
guildOnly: true,
allowStaff: true,
userPermissions: ['KICK_MEMBERS'],
args: [
{
@@ -22,9 +22,12 @@ module.exports = class WarnCommand extends Command {
key: 'reason',
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) return true;
return 'Invalid Reason. Reason must be under 140 characters.';
validate: (reason) => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
}
}
]
@@ -33,32 +36,50 @@ module.exports = class WarnCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { member, reason } = args;
if (!member.kickable) return msg.say('This member is not warnable. Perhaps they have a higher role than me?');
try {
await member.user.send(stripIndents`
You were warned in ${msg.guild.name}!
Reason: ${reason}.
`);
await msg.say(`Are you sure you want to warn ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (['y', 'yes'].includes(collected.first().content.toLowerCase())) {
try {
await member.user.send(stripIndents`
You were warned in ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await msg.say(`Successfully warned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user.has('SEND_MESSAGES'))) {
return msg.say('Could not log the warn to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Warn.');
}
} catch (err) {
await msg.say('Failed to Send DM.');
return msg.say('Aborting Warn.');
}
msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
`);
await modlogs.send({ embed });
return null;
}
};