Skip to content

Commit

Permalink
[New] getTextChannelFromMention function to parse text channels
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Nov 4, 2021
1 parent d868d3f commit c55aa11
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions modules/getUserFromMention.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,20 @@ module.exports.getRoleFromMention = async (mention, message) => {
return await message.guild.roles.fetch(mention);
}
};

/**
* Parses the Text Channel ID
* @param {TextChannel} mention
* @param {Message} message
* @returns ID String
*/
module.exports.getTextChannelFromMention = async (mention) => {
if (!mention) return;

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

return mention;
}
return mention;
};

0 comments on commit c55aa11

Please sign in to comment.