Skip to content

Commit

Permalink
[New] Added getGuildUser that parses the mention and returns the Guil…
Browse files Browse the repository at this point in the history
…dUser class
  • Loading branch information
naseif committed Oct 5, 2021
1 parent a69b758 commit 85d8d86
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
Expand Up @@ -18,3 +18,23 @@ module.exports.getUserFromMention = (mention, client) => {
return client.users.cache.get(mention);
}
};

/**
* ´Gets the GuildMember Object
* @param {mention} mention
* @param {message} message
* @returns GuildMember Object
*/
module.exports.getGuildUserFromMention = (mention, message) => {
if (!mention) return;

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

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

return message.guild.members.cache.get(mention);
}
};

0 comments on commit 85d8d86

Please sign in to comment.