Skip to content

Commit

Permalink
Extract any mentions from system messages
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkView committed Jul 18, 2021
1 parent 2ee1f7f commit cb72c14
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion embedMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = async function ({ config, bot, formats }) {
// Accepts 100,100,100 and 100 100 100
const isRgb = /^(\d{1,3})\D+(\d{1,3})\D+(\d{1,3})$/;

const mentionRegex = /<@.?(\d{17,19})>/g;

/**
* Parses a color from the input string. The following formats are accepted:
* - #HEXVALUE
Expand Down Expand Up @@ -382,11 +384,18 @@ module.exports = async function ({ config, bot, formats }) {
}
}

// We can't directly join the matched array since that results in "@Dark,108552944961454080"
const foundMentions = threadMessage.body.matchAll(mentionRegex);
const properMentions = [];
for (const men of foundMentions) {
properMentions.push(men[0]);
}

if (config.threadTimestamps) {
embed.timestamp = moment().utc().toISOString();
}

return { embed };
return { content: properMentions.join(" "), embed, allowedMentions: {users: true, roles: true, everyone: true} };
};

// Reset the pfpMap every hour or so, we dont want outdated pfp's to stay forever
Expand Down

0 comments on commit cb72c14

Please sign in to comment.