Settings for modLog and memberLog

This commit is contained in:
Daniel Odendahl Jr
2017-04-27 02:57:52 +00:00
parent 0b42286c2d
commit 0be6029572
9 changed files with 66 additions and 12 deletions
+2 -2
View File
@@ -37,9 +37,9 @@ module.exports = class BanCommand extends Command {
async run(message, args) {
if (!message.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
return message.say('This Command requires the `Ban Members` Permission.');
const modlogs = message.guild.channels.find('name', 'mod_logs');
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`.');
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;
+2 -2
View File
@@ -34,9 +34,9 @@ module.exports = class KickCommand extends Command {
async run(message, args) {
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', 'mod_logs');
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`.');
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;
+2 -2
View File
@@ -41,9 +41,9 @@ module.exports = class UnbanCommand extends Command {
async run(message, args) {
if (!message.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
return message.say('This Command requires the `Ban Members` Permission.');
const modlogs = message.guild.channels.find('name', 'mod_logs');
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`.');
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 { memberID, reason } = args;
+2 -2
View File
@@ -31,9 +31,9 @@ module.exports = class WarnCommand extends Command {
}
async run(message, args) {
const modlogs = message.guild.channels.find('name', 'mod_logs');
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`.');
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;
+27
View File
@@ -0,0 +1,27 @@
const { Command } = require('discord.js-commando');
module.exports = class MemberLogCommand extends Command {
constructor(client) {
super(client, {
name: 'memberchannel',
group: 'util',
memberName: 'memberchannel',
description: 'Sets the channel for the member logs to be sent.',
guildOnly: true,
args: [{
key: 'channel',
prompt: 'What is the channel you want to send logs to?',
type: 'channel'
}]
});
}
hasPermission(msg) {
return msg.member.permissions.has('ADMINISTRATOR');
}
run(message, args) {
const { channel } = args;
return message.guild.settings.set('memberLog', channel.name);
}
};
+27
View File
@@ -0,0 +1,27 @@
const { Command } = require('discord.js-commando');
module.exports = class ModChannelCommand extends Command {
constructor(client) {
super(client, {
name: 'modchannel',
group: 'util',
memberName: 'modchannel',
description: 'Sets the channel for the mod logs to be sent.',
guildOnly: true,
args: [{
key: 'channel',
prompt: 'What is the channel you want to send logs to?',
type: 'channel'
}]
});
}
hasPermission(msg) {
return msg.member.permissions.has('ADMINISTRATOR');
}
run(message, args) {
const { channel } = args;
return message.guild.settings.set('modLog', channel.name);
}
};
+2 -2
View File
@@ -35,14 +35,14 @@ client.registry
.registerCommandsIn(path.join(__dirname, 'commands'));
client.on('guildMemberAdd', (member) => {
const channel = member.guild.channels.find('name', 'member_logs');
const channel = member.guild.channels.find('name', member.guild.settings.get('memberLog', 'member_logs'));
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.find('name', 'member_logs');
const channel = member.guild.channels.find('name', member.guild.settings.get('memberLog', 'member_logs'));
if (!channel) return;
if (!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
channel.send(`Bye ${member.user.username}...`);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "16.1.0",
"version": "16.2.0",
"description": "A Discord Bot",
"main": "shardingmanager.js",
"scripts": {
+1 -1
View File
@@ -20,4 +20,4 @@ class Database {
}
}
module.exports = Database;
module.exports = Database;