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 BanCommand extends Command {
constructor(client) {
@@ -34,7 +34,7 @@ module.exports = class BanCommand 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 ban yourself...');
if (!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
@@ -48,7 +48,7 @@ module.exports = class BanCommand 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, 'banned')
.replace(/{{moderator}}/gi, msg.author.tag)
.replace(/{{server}}/gi, msg.guild.name);
@@ -64,7 +64,7 @@ module.exports = class BanCommand extends Command {
reason: `${msg.author.tag}: ${reason}`
});
await msg.say(`Successfully banned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
if (!modlogs) {
return msg.say('Could not log the ban to the mod logs.');
} else if (modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
const embed = new MessageEmbed()
+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 KickCommand extends Command {
constructor(client) {
@@ -34,7 +34,7 @@ module.exports = class KickCommand 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 kick yourself...');
if (!member.kickable) return msg.say('This member is not kickable. Perhaps they have a higher role than me?');
@@ -48,7 +48,7 @@ module.exports = class KickCommand 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, 'kicked')
.replace(/{{moderator}}/gi, msg.author.tag)
.replace(/{{server}}/gi, msg.guild.name);
@@ -61,7 +61,7 @@ module.exports = class KickCommand extends Command {
}
await member.kick(`${msg.author.tag}: ${reason}`);
await msg.say(`Successfully kicked ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
if (!modlogs) {
return msg.say('Could not log the kick to the mod logs.');
} else if (modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
const embed = new MessageEmbed()
+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 SoftbanCommand extends Command {
constructor(client) {
@@ -34,7 +34,7 @@ module.exports = class SoftbanCommand 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 softban yourself...');
if (!member.bannable) return msg.say('This member is not softbannable. Perhaps they have a higher role than me?');
@@ -48,7 +48,7 @@ module.exports = class SoftbanCommand 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, 'softbanned')
.replace(/{{moderator}}/gi, msg.author.tag)
.replace(/{{server}}/gi, msg.guild.name);
@@ -65,7 +65,7 @@ module.exports = class SoftbanCommand extends Command {
});
await msg.guild.unban(member.user, 'Softban');
await msg.say(`Successfully softbanned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
if (!modlogs) {
return msg.say('Could not log the softban to the mod logs.');
} else if (modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
const embed = new MessageEmbed()
+2 -2
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const { stripIndents } = require('common-tags');
const { parseTopic } = require('../../structures/Util');
const { filterTopics } = require('../../structures/Util');
module.exports = class UnbanCommand extends Command {
constructor(client) {
@@ -34,7 +34,7 @@ module.exports = class UnbanCommand 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 { id, reason } = args;
const bans = await msg.guild.fetchBans();
if (!bans.has(id)) return msg.say('This ID is not in the Guild Banlist.');
+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()
@@ -1,11 +1,11 @@
const Command = require('../../structures/Command');
const { parseTopic } = require('../../structures/Util');
const { filterTopics } = require('../../structures/Util');
module.exports = class PortalSendCommand extends Command {
constructor(client) {
super(client, {
name: 'portal-send',
group: 'random',
group: 'text-edit',
memberName: 'portal-send',
description: 'Send a message to a random channel that has a portal open.',
guildOnly: true,
@@ -27,7 +27,7 @@ module.exports = class PortalSendCommand extends Command {
async run(msg, args) {
const { message } = args;
const channels = this.client.channels.filter(c => c.type === 'text' && c.guild.id !== msg.guild.id);
const channel = parseTopic(channels, 'portal', this.client.user).random();
const channel = filterTopics(channels, 'portal').random();
if (!channel) return msg.say('Aww... No channel has an open portal...');
try {
await channel.send(`**${msg.author.tag} (${msg.guild.name}):** ${message}`);