From 965f75595ba9a3335b243603c083c4a47d7692d1 Mon Sep 17 00:00:00 2001 From: litruv Date: Tue, 11 Jun 2019 02:56:59 +1000 Subject: [PATCH] Added ambiguous prefix, between mention and db --- index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9607dac..903f34f 100644 --- a/index.js +++ b/index.js @@ -151,11 +151,21 @@ function doPMCommand(msg, prefix) { function doCommand(msg, prefix) { var message = msg.cleanContent - if (!message.startsWith(prefix)) return + + if (msg.mentions.members.get(client.user.id) == undefined) + if (!message.startsWith(prefix)) return //Split into command + args - const command = message.substring(prefix.length).split(/[ \n]/)[0].trim().toLowerCase() - msg.suffix = message.substring(prefix.length + command.length).trim() + if (message.startsWith(prefix)) { + var command = message.substring(prefix.length).split(/[ \n]/)[0].trim().toLowerCase() + msg.suffix = message.substring(prefix.length + command.length).trim() + } + else { + var command = message.replace("@" + msg.guild.me.displayName, "").trim().split(" ", 1)[0]; + msg.suffix = message.replace("@" + msg.guild.me.displayName, "").replace(command, "").trim() + } + + var cmds = client.cachedcommands.filter(cmd => cmd.alias == command); if (cmds.length > 0) {