From a4d9d86dfe797846d22d5f3d3f42fb7b0920a6aa Mon Sep 17 00:00:00 2001 From: Neko Life Date: Mon, 28 Jun 2021 18:45:36 +0900 Subject: [PATCH] epic2 --- Main.js | 6 ++++++ cmds/fun/say.js | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Main.js b/Main.js index 2fc9e04..f386fa9 100644 --- a/Main.js +++ b/Main.js @@ -21,6 +21,7 @@ const { join } = require('path'); const getColor = require("./resources/getColor"); const { timestampAt } = require("./resources/debug"); const requireAll = require("require-all"); +const { chatAnswer } = require("./resources/shaChat"); const lgr = requireAll({ dirname: join(__dirname, "resources/eventsLogger"), recursive: true }); client.functions = requireAll({ dirname: join(__dirname, "resources"), recursive: true }); @@ -58,6 +59,11 @@ client.on("message", async msg => { if (!msg.author.dbLoaded && !msg.author.bot) await msg.author.dbLoad(); lgr.message.letsChat(msg); + if (msg.mentions.has(client.user) && !msg.isCommand && msg.cleanContent?.length > 0) { + const u = msg.cleanContent.replace(new RegExp(" ?<@!?" + client.user.id + ">"), "").trim(); + trySend(client, msg, await chatAnswer(u)); + } + if (!msg.guild) { //console.log(`(${msg.channel.recipient.id}) ${msg.channel.recipient.tag}: (${msg.author.id}) ${msg.author.tag}: ${msg.content}`); } else { diff --git a/cmds/fun/say.js b/cmds/fun/say.js index 293ffc9..361f48f 100644 --- a/cmds/fun/say.js +++ b/cmds/fun/say.js @@ -16,12 +16,12 @@ module.exports = class say extends commando.Command { async run(msg, args) { if (!args) args = '​'; args = emoteMessage(this.client, args); - const sendThis = {content:args, disableMentions:"all"}; + const sendThis = { content: args, disableMentions: "all" }; if (msg.member?.hasPermission('MENTION_EVERYONE')) { - sendThis.disableMentions = "none"; + sendThis.disableMentions = "none"; } const sent = await trySend(this.client, msg, sendThis); - if (args != '​' && msg.channel.guild && msg.member.hasPermission("MANAGE_MESSAGES")) { + if (args != '​' && msg.channel.guild && msg.member.hasPermission("MANAGE_MESSAGES") && !/^<@\!?\d{17,19}>\s.+/.test(msg.content)) { tryDelete(msg); } ranLog(msg, sent.content);