Invite Guard, Topic Parsing Changes

This commit is contained in:
Daniel Odendahl Jr
2017-08-03 22:08:52 +00:00
parent 128a87f40b
commit 104ab19bc5
9 changed files with 36 additions and 40 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const { stripIndents } = require('common-tags');
const { parseTopic, parseTopicMsg } = require('../../structures/Util');
const { filterTopics, parseTopic } = require('../../structures/Util');
module.exports = class WarnCommand extends Command {
constructor(client) {
@@ -33,7 +33,7 @@ module.exports = class WarnCommand extends Command {
}
async run(msg, args) {
const modlogs = parseTopic(msg.guild.channels, 'modlog', this.client.user).first();
const modlogs = filterTopics(msg.guild.channels, 'modlog').first();
const { member, reason } = args;
if (member.id === msg.author.id) return msg.say('I don\'t think you want to warn yourself...');
if (!member.kickable) return msg.say('This member is not warnable. Perhaps they have a higher role than me?');
@@ -47,7 +47,7 @@ module.exports = class WarnCommand extends Command {
});
if (!msgs.size || !['y', 'yes'].includes(msgs.first().content.toLowerCase())) return msg.say('Aborting.');
try {
const message = parseTopicMsg(modlogs.topic, 'modmessage')
const message = parseTopic(modlogs.topic, 'modmessage')
.replace(/{{action}}/gi, 'warned')
.replace(/{{moderator}}/gi, msg.author.tag)
.replace(/{{server}}/gi, msg.guild.name);
@@ -59,7 +59,7 @@ module.exports = class WarnCommand extends Command {
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')) {
if (!modlogs) {
return msg.say('Could not log the warn to the mod logs.');
} else if (modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
const embed = new MessageEmbed()