match user prompts exactly not partially (#2245)

This commit is contained in:
Mr Simon C 2024-09-09 22:40:06 +01:00 committed by GitHub
parent 9aa77dfb8d
commit cf6928fd5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,7 +25,10 @@ async function grepCommand(message, user = null) {
// Allows multiple commands in one message
let updatedMessage = message;
for (const preset of userPresets) {
const regex = new RegExp(preset.command, "g");
const regex = new RegExp(
`(?:\\b\\s|^)(${preset.command})(?:\\b\\s|$)`,
"g"
);
updatedMessage = updatedMessage.replace(regex, preset.prompt);
}