2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-30 05:37:59 +00:00

made custom commands case insensitive

This commit is contained in:
Pouria Ezzati 2017-11-20 13:29:33 +03:30
parent 631f5732a0
commit ff5eca49e7
3 changed files with 8 additions and 5 deletions

View File

@ -26,7 +26,7 @@ const removeCommandHandler = async ({ chat, message, reply, state }) => {
);
}
const command = await getCommand({ name: commandName });
const command = await getCommand({ name: commandName.toLowerCase() });
if (!command) {
return reply(
' <b>Command couldn\'t be found.</b>',
@ -42,7 +42,7 @@ const removeCommandHandler = async ({ chat, message, reply, state }) => {
);
}
await removeCommand({ name: commandName });
await removeCommand({ name: commandName.toLowerCase() });
return reply(
`✅ <code>!${commandName}</code> ` +
'<b>has been removed successfully.</b>',

View File

@ -45,7 +45,7 @@ const addCustomCmdHandler = async ({ chat, message, reply, state }, next) => {
return next();
}
if (await getCommand({ isActive: true, name: text })) {
if (await getCommand({ isActive: true, name: text.toLowerCase() })) {
reply(
' <b>This command already exists.</b>\n\n' +
'/commands - to see the list of commands.\n' +
@ -56,7 +56,7 @@ const addCustomCmdHandler = async ({ chat, message, reply, state }, next) => {
);
return next();
}
await updateCommand({ id, name: text, state: 'role' });
await updateCommand({ id, name: text.toLowerCase(), state: 'role' });
reply('Who can use this command?', Markup.keyboard([
[ 'Master', 'Admins', 'Everyone' ]
])

View File

@ -11,7 +11,10 @@ const runCustomCmdHandler = async (ctx, next) => {
return next();
}
const commandName = message.text.split(' ')[0].replace('!', '');
const commandName = message.text
.split(' ')[0]
.replace('!', '')
.toLowerCase();
const command = await getCommand({ isActive: true, name: commandName });
if (!command) {