fac30sb / discord-chatbot-emma-egbie

0 stars 0 forks source link

Test if bot can send direct messages to users #42

Open electricblues opened 7 months ago

electricblues commented 7 months ago

As a back-end developer, I want to…

ensure my bot can send direct messages to users, testing the user.send() method’s functionality

blackNoir2 commented 6 months ago

[Test if bot can send direct messages to users]

Test description [ensure my bot can send direct messages to users, testing the user.send() method’s functionality]

This test aimed to verify whether the bot can successfully send direct messages to users by unit testing. Due to limitations in the Discord platform, mainly for security reasons, creating users programmatically for testing purposes is not supported. Manually creating a user and placing them on the server failed as the user account did not appear in the test environment and by test environment I mean inside the code (unit testing) not the UI , preventing them from being messaged. Further investigation revealed that in unit testing, since there was no prior interaction with the bot, it didn't appear on the server, making it impossible to send messages to users.

Efforts to manually provide the user ID to the bot for messaging also encountered difficulties, resulting in errors. Retrieving user accounts programmatically from the server returned only bot accounts, not user accounts. Even manually fetching user information directly by copying and pasting the user ID returned nothing from the cache or from fetch which was strange because one can physically see themselves in the UI, and attempting to get all users on the server only returned the bots that were on the system even though one can see themselves visually in the UI. Additionally, because only bots showed up, I attempted to message one bot from another by placing two bots on the same server, but Discord's restrictions prevented inter-bot communication.

Ultimately, the test was conducted manually by sending a message from the bot to a given user and verifying its delivery to the intended user account. While this approach lacks automation, it provided confirmation of the bot's messaging functionality.