Skip to content

Commit

Permalink
[New] Added getUserFromMention function that parses user mentions and…
Browse files Browse the repository at this point in the history
… returns the user constructor
  • Loading branch information
naseif committed Oct 5, 2021
1 parent bff46cb commit 9567a8c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/getUserFromMention.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Parses User Mention
* @param {User} mention
* @param {Client} client
* @returns User Class
*/

module.exports.getUserFromMention = (mention, client) => {
if (!mention) return;

if (mention.startsWith("<@") && mention.endsWith(">")) {
mention = mention.slice(2, -1);

if (mention.startsWith("!")) {
mention = mention.slice(1);
}

return client.users.cache.get(mention);
}
};

0 comments on commit 9567a8c

Please sign in to comment.