Finish text filtering and add some filters

master
Kit Kasune 4 years ago
parent 45b97bfb7e
commit 0fbe54a598
  1. 4
      commands/response.js
  2. 1
      events/message.js
  3. 7
      util/response/filterresponse.js
  4. 10
      util/response/sendresponse.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]));}
}
};

@ -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;};};

@ -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;
};

@ -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<options.fieldnames.length;i++) {responseEmbed.addField(options.fieldnames[i], options.fieldtexts[i]);}}
var responseEmbed = new Discord.MessageEmbed().setTitle(options.title).setDescription(await filterResponse(message.member, client, options.description));
if (options.fieldnames && options.fieldnames.length) {let i; for (i=0;i<options.fieldnames.length;i++) {responseEmbed.addField(options.fieldnames[i], await filterResponse(message.member, client, options.fieldtexts[i]));}}
if (options.color) {responseEmbed.setColor(options.color);}
if (options.image) {responseEmbed.setImage(options.image);}
if (options.thumbnail) {responseEmbed.setThumbnail(options.thumbnail);}
}
if (channel.permissionsFor(client.user.id).has("SEND_MESSAGES")) {return channel.send(
options.message ? options.text : responseEmbed
options.message ? await filterResponse(message.member, client, options.text) : responseEmbed
);}
}
} catch {}

Loading…
Cancel
Save