From e8d682d52797f68c75acab0932e686f3fca3e878 Mon Sep 17 00:00:00 2001 From: Pouria Ezzati Date: Fri, 6 Oct 2017 21:49:33 +0330 Subject: [PATCH] Custom commands now start with ! --- handlers/messages/runCustomCmd.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/handlers/messages/runCustomCmd.js b/handlers/messages/runCustomCmd.js index 4a55b17..13e58f0 100644 --- a/handlers/messages/runCustomCmd.js +++ b/handlers/messages/runCustomCmd.js @@ -6,13 +6,12 @@ const { getCommand } = require('../../stores/command'); const runCustomCmdHandler = async (ctx, next) => { const { message, state } = ctx; const { isAdmin, isMaster } = state; - const isCommand = message.entities && - message.entities.filter(entity => entity.type === 'bot_command'); - if (!isCommand || !isCommand.length) { + const isCommand = /^!\w+/.test(message.text); + if (!isCommand) { return next(); } - const commandName = message.text.split(' ')[0].replace('/', ''); + const commandName = message.text.split(' ')[0].replace('!', ''); const command = await getCommand({ isActive: true, name: commandName }); if (!command) {