Closed j24m closed 9 months ago
Lgtm
@j24m can we do a small change by change text to
Server joined on
Not needed right now in my opinion, already discussed with @ankushdharkar during morning standup. Also it is not change by change to text Server joined on, it's change by changing text to and so on.
Issue :
https://github.com/Real-Dev-Squad/discord-slash-commands/issues/147
Description :
This pull request introduces improvements to the handling of user details formatting in the
formatUserDetails
function and addresses the scenario wherediscordJoinedAt
is undefined when we use the /user command.Code Changes :
userCommand.ts : In the userCommand function, it is updated to return an appropriate response when the user details cannot be found.
formatUserDetails.ts : In the formatUserDetails and convertTimeStamp functions, I've added enhanced handling for discordJoinedAt to ensure the user details are correctly formatted even when discordJoinedAt is undefined.
tests/fixtures/users.ts : I've introduced a new fixture userWithoutDiscordJoinedAt representing a user without discordJoinedAt data.
tests/unit/utils/formatUserDetails.test.ts : I've added new test cases to verify the behavior of the formatUserDetails function when discordJoinedAt is undefined.
Test Stats :
Before :![image](https://github.com/Real-Dev-Squad/discord-slash-commands/assets/53934353/9747b620-a0b9-4d17-8d82-324c238b66c8)
After :![image](https://github.com/Real-Dev-Squad/discord-slash-commands/assets/53934353/3dc31da5-c320-471b-909a-a6a00a2bbeb1)
Working Proof :
User found :![image](https://github.com/Real-Dev-Squad/discord-slash-commands/assets/53934353/d7a716fe-d576-4f9c-acbe-831da0c6c31d)
User not found : (BOT)![image](https://github.com/Real-Dev-Squad/discord-slash-commands/assets/53934353/d38c1a91-16b5-4580-bfe3-eb8e8eea0d8f)
User not found : (HUMAN)![image](https://github.com/Real-Dev-Squad/discord-slash-commands/assets/53934353/fb24a11c-6b0b-4a29-b2b1-cbff4dce2f03)
Server Join Date (N/A) :![image](https://github.com/Real-Dev-Squad/discord-slash-commands/assets/53934353/59d5ee32-3250-443f-a078-bd60af6f1049)