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