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

🐛 Fix getting user#91

Open
alaninnovates wants to merge 1 commit into
suggestionsbot:mainfrom
alaninnovates:mention-matching-fixes
Open

🐛 Fix getting user#91
alaninnovates wants to merge 1 commit into
suggestionsbot:mainfrom
alaninnovates:mention-matching-fixes

Conversation

@alaninnovates

Copy link
Copy Markdown
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];

@acollierr17 acollierr17 Apr 3, 2022

Copy link
Copy Markdown
Member

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