diff --git a/modules/getUserFromMention.js b/modules/getUserFromMention.js new file mode 100644 index 0000000..08f792b --- /dev/null +++ b/modules/getUserFromMention.js @@ -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); + } +};