2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-30 13:47:54 +00:00

Custom commands now start with !

This commit is contained in:
Pouria Ezzati 2017-10-06 21:49:33 +03:30
parent 70b28b7b53
commit e8d682d527

View File

@ -6,13 +6,12 @@ const { getCommand } = require('../../stores/command');
const runCustomCmdHandler = async (ctx, next) => { const runCustomCmdHandler = async (ctx, next) => {
const { message, state } = ctx; const { message, state } = ctx;
const { isAdmin, isMaster } = state; const { isAdmin, isMaster } = state;
const isCommand = message.entities && const isCommand = /^!\w+/.test(message.text);
message.entities.filter(entity => entity.type === 'bot_command'); if (!isCommand) {
if (!isCommand || !isCommand.length) {
return next(); return next();
} }
const commandName = message.text.split(' ')[0].replace('/', ''); const commandName = message.text.split(' ')[0].replace('!', '');
const command = await getCommand({ isActive: true, name: commandName }); const command = await getCommand({ isActive: true, name: commandName });
if (!command) { if (!command) {