mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-30 13:47:54 +00:00
made custom commands case insensitive
This commit is contained in:
@@ -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>',
|
||||
|
@@ -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' ]
|
||||
])
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user