From 0fbe54a598b82a15afe0271ebeeed8002c99e2cc Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Thu, 29 Oct 2020 01:10:28 -0600 Subject: [PATCH] Finish text filtering and add some filters --- commands/response.js | 4 ++-- events/message.js | 1 - util/response/filterresponse.js | 7 +++++++ util/response/sendresponse.js | 10 ++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 util/response/filterresponse.js diff --git a/commands/response.js b/commands/response.js index cab0c61..5bddf7c 100644 --- a/commands/response.js +++ b/commands/response.js @@ -22,8 +22,8 @@ module.exports = { if (args.length < 1) {return message.reply("You have to tell me what I'm supposed to find or save!");} - if (['q', 'quick'].includes(args[0].toLowerCase())) {return await sendResponse(message.channel, 'quick', client, await parseResponse(message, client, args));} + if (['q', 'quick'].includes(args[0].toLowerCase())) {return await sendResponse(message, message.channel, 'quick', client, await parseResponse(message, client, args));} if (['n', 'new', 's', 'save'].includes(args[0].toLowerCase())) {return await saveResponse(await parseResponse(message, client, args), message);} - if (['t', 'test', 'send'].includes(args[0].toLowerCase())) {return await sendResponse(message.channel, 'quick', client, await getResponse(message, args[1]));} + if (['t', 'test', 'send'].includes(args[0].toLowerCase())) {return await sendResponse(message, message.channel, 'quick', client, await getResponse(message, args[1]));} } }; \ No newline at end of file diff --git a/events/message.js b/events/message.js index 772bdcb..e3b5939 100644 --- a/events/message.js +++ b/events/message.js @@ -6,7 +6,6 @@ const UserData = require('../models/user'); module.exports = async (client, message) => { if (message.author.bot) {return undefined;} - if (message.channel.type === 'dm') /*{var dmch = true;} else {var dmch = false};*/ {return undefined;} if (message.channel.type !== 'text' && message.channel.type !== 'dm') {return undefined;} //if (message.channel.type == "text") {if (settings[message.guild.id]) {prefix = settings[message.guild.id].prefix;};}; diff --git a/util/response/filterresponse.js b/util/response/filterresponse.js new file mode 100644 index 0000000..6501ea3 --- /dev/null +++ b/util/response/filterresponse.js @@ -0,0 +1,7 @@ +module.exports = async (member, client, text) => { + text = text + .replace(/(?:{{member}}|{{m}})/gm, member.displayName) + .replace(/(?:{{membercount}}|{{mc}})/gm, `${member.guild.members.cache.size}`) + .replace(/(?:{{owner}}|{{o}})/gm, member.guild.owner.displayName); + return text; +}; \ No newline at end of file diff --git a/util/response/sendresponse.js b/util/response/sendresponse.js index 9bd0ac7..a22d597 100644 --- a/util/response/sendresponse.js +++ b/util/response/sendresponse.js @@ -1,19 +1,21 @@ const Discord = require('discord.js'); -module.exports = async(channel, mode, client, options) => { +const filterResponse = require('./filterresponse'); + +module.exports = async(message, channel, mode, client, options) => { if (!options) {return;} if (options.channel && options.channel.length) {channel = channel.guild.channels.cache.get(options.channel.slice(options.channel.search(/\d/), options.channel.search('>')));} try { if (mode === "welcome") {} else if (mode === "leave") {} else { if (options.embed) { - var responseEmbed = new Discord.MessageEmbed().setTitle(options.title).setDescription(options.description); - if (options.fieldnames && options.fieldnames.length) {let i; for (i=0;i