Softban, Server Staff Role

This commit is contained in:
Daniel Odendahl Jr
2017-04-30 14:40:19 +00:00
parent cade00cce8
commit 64e2344a85
7 changed files with 73 additions and 7 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ module.exports = class BanCommand extends Command {
}
hasPermission(msg) {
return msg.member.permissions.has('BAN_MEMBERS');
return msg.member.permissions.has('BAN_MEMBERS') || msg.member.roles.exists('name', 'Server Staff');
}
async run(message, args) {
+1 -1
View File
@@ -28,7 +28,7 @@ module.exports = class KickCommand extends Command {
}
hasPermission(msg) {
return msg.member.permissions.has('KICK_MEMBERS');
return msg.member.permissions.has('KICK_MEMBERS') || msg.member.roles.exists('name', 'Server Staff');
}
async run(message, args) {
+1 -1
View File
@@ -26,7 +26,7 @@ module.exports = class PruneCommand extends Command {
}
hasPermission(msg) {
return msg.member.permissions.has('MANAGE_MESSAGES');
return msg.member.permissions.has('MANAGE_MESSAGES') || msg.member.roles.exists('name', 'Server Staff');
}
async run(message, args) {
+66
View File
@@ -0,0 +1,66 @@
const { Command } = require('discord.js-commando');
const { RichEmbed } = require('discord.js');
module.exports = class SoftbanCommand extends Command {
constructor(client) {
super(client, {
name: 'softban',
group: 'moderation',
memberName: 'softban',
description: 'Kicks a user and deletes their messages, and logs the softban to the mod_logs.',
guildOnly: true,
args: [{
key: 'member',
prompt: 'What member do you want to softban?',
type: 'member'
}, {
key: 'reason',
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) {
return true;
}
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
}
}]
});
}
hasPermission(msg) {
return msg.member.permissions.has('KICK_MEMBERS') || msg.member.roles.exists('name', 'Server Staff');
}
async run(message, args) {
if (!message.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
return message.say('This Command requires the `Ban Members` Permission.');
if (!message.channel.permissionsFor(this.client.user).has('KICK_MEMBERS'))
return message.say('This Command requires the `Kick Members` Permission.');
const modlogs = message.guild.channels.find('name', message.guild.settings.get('modLog', 'mod_logs'));
if (!modlogs)
return message.say('This Command requires a channel named `mod_logs` or one custom set with the `modchannel` command.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return message.say('This Command requires the `Embed Links` Permission.');
const { member, reason } = args;
if (!member.bannable)
return message.say('This member is not bannable. Perhaps they have a higher role than me?');
try {
try {
await member.send(`You were softbanned from ${message.guild.name}!\nReason: ${reason}.`);
} catch (err) {
await message.say('Failed to send DM to user.');
}
await member.ban(7);
await message.guild.unban(member.user);
await message.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(message.author.tag, message.author.displayAvatarURL)
.setColor(0xFF0000)
.setTimestamp()
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Ban\n**Reason:** ${reason}`);
return modlogs.send({embed});
} catch (err) {
return message.say('An Unknown Error Occurred.');
}
}
};
+2 -2
View File
@@ -35,7 +35,7 @@ module.exports = class UnbanCommand extends Command {
}
hasPermission(msg) {
return msg.member.permissions.has('BAN_MEMBERS');
return msg.member.permissions.has('BAN_MEMBERS') || msg.member.roles.exists('name', 'Server Staff');
}
async run(message, args) {
@@ -50,7 +50,7 @@ module.exports = class UnbanCommand extends Command {
const bans = await message.guild.fetchBans();
if (!bans.has(id))
return message.say('This ID is not in the Guild Banlist.');
const member = await bans.get(id);
const member = bans.get(id);
try {
await message.guild.unban(member);
await message.say(':ok_hand:');
+1 -1
View File
@@ -27,7 +27,7 @@ module.exports = class WarnCommand extends Command {
}
hasPermission(msg) {
return msg.member.permissions.has('KICK_MEMBERS');
return msg.member.permissions.has('KICK_MEMBERS') || msg.member.roles.exists('name', 'Server Staff');
}
async run(message, args) {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "17.0.1",
"version": "17.1.0",
"description": "A Discord Bot",
"main": "shardingmanager.js",
"scripts": {