fac30sb / discord-chatbot-emma-egbie

0 stars 0 forks source link

Error the bot responses without having its name called #50

Closed blackNoir2 closed 7 months ago

blackNoir2 commented 7 months ago

Fix bot response behaviour to only trigger when mentioned by name

Previously, the bot would respond to messages indiscriminately (this was mainly because of a new feature added which was to listen and flag all messages the user typed that were in violation of OpenAi rules), even when its name wasn't mentioned. This commit addresses this issue by modifying the bot's message handling logic to respond only when explicitly mentioned by its name in the message . This ensures that the bot's responses are triggered purposefully by user interaction, improving the overall user experience.

Second removed the botManager.js file which was outside the src folder and also a few commits out of date.

Finally, Refactored _sendDirectMessageToUser method for improved testability and clarity. This was done by separating the user retrieval logic into its own method (_getUserByID) for two reasons, Single Responsibility Principle (SRP) and to be able to facilitate isolated testing, - this means should " _sendDirectMessageToUser" method not work as intended it can easily be tested to see why.