mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-31 06:05:22 +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) {
|
if (!command) {
|
||||||
return reply(
|
return reply(
|
||||||
'ℹ️ <b>Command couldn\'t be found.</b>',
|
'ℹ️ <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(
|
return reply(
|
||||||
`✅ <code>!${commandName}</code> ` +
|
`✅ <code>!${commandName}</code> ` +
|
||||||
'<b>has been removed successfully.</b>',
|
'<b>has been removed successfully.</b>',
|
||||||
|
@@ -45,7 +45,7 @@ const addCustomCmdHandler = async ({ chat, message, reply, state }, next) => {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await getCommand({ isActive: true, name: text })) {
|
if (await getCommand({ isActive: true, name: text.toLowerCase() })) {
|
||||||
reply(
|
reply(
|
||||||
'ℹ️ <b>This command already exists.</b>\n\n' +
|
'ℹ️ <b>This command already exists.</b>\n\n' +
|
||||||
'/commands - to see the list of commands.\n' +
|
'/commands - to see the list of commands.\n' +
|
||||||
@@ -56,7 +56,7 @@ const addCustomCmdHandler = async ({ chat, message, reply, state }, next) => {
|
|||||||
);
|
);
|
||||||
return 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([
|
reply('Who can use this command?', Markup.keyboard([
|
||||||
[ 'Master', 'Admins', 'Everyone' ]
|
[ 'Master', 'Admins', 'Everyone' ]
|
||||||
])
|
])
|
||||||
|
@@ -11,7 +11,10 @@ const runCustomCmdHandler = async (ctx, next) => {
|
|||||||
return 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 });
|
const command = await getCommand({ isActive: true, name: commandName });
|
||||||
|
|
||||||
if (!command) {
|
if (!command) {
|
||||||
|
Reference in New Issue
Block a user