diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index a819df7f..4c86990d 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -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; diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 18c923c6..7bbcb583 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -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; diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index ae096bc2..6ad7a4a5 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -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; diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index a5845ed4..67216fa9 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -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; diff --git a/commands/util/memberchannel.js b/commands/util/memberchannel.js new file mode 100644 index 00000000..6467417f --- /dev/null +++ b/commands/util/memberchannel.js @@ -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); + } +}; diff --git a/commands/util/modchannel.js b/commands/util/modchannel.js new file mode 100644 index 00000000..d0d77407 --- /dev/null +++ b/commands/util/modchannel.js @@ -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); + } +}; diff --git a/index.js b/index.js index f984bdad..860e0d58 100644 --- a/index.js +++ b/index.js @@ -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}...`); diff --git a/package.json b/package.json index 1d5e4860..6280822a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "16.1.0", + "version": "16.2.0", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": { diff --git a/structures/PostgreSQL.js b/structures/PostgreSQL.js index 300378f0..c82f5b9b 100644 --- a/structures/PostgreSQL.js +++ b/structures/PostgreSQL.js @@ -20,4 +20,4 @@ class Database { } } -module.exports = Database; \ No newline at end of file +module.exports = Database;