Skip to content

Conversation

achyu-dev
Copy link
Contributor

📌 Description

This PR adds a new feature, where in, if any command is found within either a triple or single code block, it's ignored and the bot does not trigger the message that is instead triggered if its not within codeblocks

ℹ️ **Fixes **
Fixes: #412


🧱 Type of Change

  • 🐛 Bug fix – Non-breaking fix for a functional/logic error
  • ✨ New feature – Adds functionality without breaking existing commands or APIs
  • ⚠️ Breaking change – Backward-incompatible change (commands, bot behavior, etc.)
  • 🧪 Test suite change – Adds/updates unit, integration, or manual tests

🧪 How Has This Been Tested?

  • Unit Tests (test/commands.test.ts)
  • Manual testing in Discord

Test Environment:

  • OS: Windows 11

✅ Checklist

  • My code follows repo CONTRIBUTING.md guidelines
  • Self-review completed
  • Added/updated comments and docstrings
  • Updated relevant docs (README, help text, etc.)
  • No new warnings or errors introduced
  • Added/updated tests
  • All tests pass locally
  • Ran prettier (npm run prettier)
  • Docker image builds and runs
  • Changes are backwards compatible (if applicable)

🛠️ Affected Bot Areas

  • Commands (e.g., !su, !docs)

📸 Screenshots / Demos (if applicable)

image

🧠 Additional Notes

Copy link

what-the-diff bot commented Oct 1, 2025

PR Summary

  • Introduction of escapeRegex Utility Function
    This update includes a new utility function called escapeRegex. Its role is to help manage special characters in a string that's used in search patterns, making the search operation more reliable and predictable.

  • Addition of shouldTriggerCommand Function
    A new function named shouldTriggerCommand has been included. This function verifies if a command term is present in a message while overlooking the words situated inside the code sections written in Markdown language. This feature improves the function's precision by focusing only on relevant text sections.

  • Revision of Command Handling Logic
    The logic responsible for managing commands has been enhanced in several ways:

    • It quickly disregards messages that don't start with a '!', making command processing more efficient.
    • It fetches a possible command and matches it to the corresponding command feature in a more efficient way.
    • Lastly, it performs a thorough validation to guarantee that the command is not found within a code section. This final check, though resource-intensive, ensures a clean execution of commands.
  • Integration with Existing Command Process Flow
    The new logic has been well integrated into the existing command process flow. The updates prioritize certain checks to enhance performance, thereby reducing unnecessary computations and further optimizing the process flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

text in code blocks is treated as commands
1 participant