Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

🐛 Fix getting user #91

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alaninnovates
Copy link
Contributor

Handle the cases: user id, mention in the suggestions command

Fixes #81

Comment on lines +29 to +32
let id;
const mention = userID.matchAll(MessageMentions.USERS_PATTERN).next().value;
if (!mention) id = userID;
else id = mention[1];
Copy link
Member

@acollierr17 acollierr17 Apr 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks solid for starters. However, I think we can refactor this logic even more with the following:

const mention = userID.matchAll(MessageMentions.USERS_PATTERN).next().value;
const id = (mention && mention[1]) ?? userID;

Let me know what you think!

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

Successfully merging this pull request may close these issues.

"Cannot read properties of null (reading '1')" when running the "suggestions" command
2 participants