mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
Remove mention parsing from link
This commit is contained in:
parent
a0a2772870
commit
1e201c46f6
1 changed files with 12 additions and 5 deletions
|
@ -12,11 +12,18 @@ exports.lbrylink = async function(bot, msg, suffix) {
|
||||||
|
|
||||||
const urlOccurrences = (msg.content.match(/lbry:\/\//g) || []).length;
|
const urlOccurrences = (msg.content.match(/lbry:\/\//g) || []).length;
|
||||||
if (urlOccurrences > 0) {
|
if (urlOccurrences > 0) {
|
||||||
//convert all mentions to a plain string (because lbry://@Nikooo777 gets parsed as lbry://@<123123123> instead)
|
//convert all mentions to a plain string (because lbry://@Nikooo777 gets parsed as lbry://@<123123123> instead)
|
||||||
let mentions = msg.mentions.users;
|
const mentionRegex = /(.+)<@!?(\d{18})>(.+)/;
|
||||||
mentions.forEach(m => {
|
let match;
|
||||||
msg.content = msg.content.replace(new RegExp(m.toString(), 'g'), `@${m.username}`);
|
do {
|
||||||
});
|
if (match) {
|
||||||
|
msg.content =
|
||||||
|
match[1] +
|
||||||
|
`@${msg.guild.members.get(match[2]).user.username}` +
|
||||||
|
match[3];
|
||||||
|
}
|
||||||
|
match = msg.content.match(mentionRegex);
|
||||||
|
} while (match);
|
||||||
|
|
||||||
//compile a list of URLs
|
//compile a list of URLs
|
||||||
let urls = msg.content.match(/lbry:\/\/\S+/g);
|
let urls = msg.content.match(/lbry:\/\/\S+/g);
|
||||||
|
|
Loading…
Add table
Reference in a new issue