-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cleanContent): add missing emojis & slash mentions #9143
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Discord render emojis like that : |
Then nvm |
8814b3a
to
1a9ba61
Compare
1a9ba61
to
a7aec46
Compare
@DraftProducts is attempting to deploy a commit to the discordjs Team on Vercel. A member of the Team first needs to authorize it. |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://discord-js-git-fork-draftbot-clean-content-mentions-discordjs.vercel.app/ |
@@ -315,8 +315,8 @@ function basename(path, ext) { | |||
* @returns {string} | |||
*/ | |||
function cleanContent(str, channel) { | |||
return str.replaceAll(/<(@[!&]?|#)(\d{17,19})>/g, (match, type, id) => { | |||
switch (type) { | |||
return str.replaceAll(/<(?:(@[!&]?|#)|([/:])([\w ]+):)(\d{17,19})>/g, (match, type, prefix, name, id) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your regexp does not match animated emojis! it's also became much more complex to handle.
You could use <(?:(?<type>@[!&]?|#)|(?:(?<command>\/[\w ]+)|(?<animatedEmoji>a)?:(?<emojiName>[\w]+)):)(?<id>\d{17,19})>
for a regex, and then use the groups for the actual replacing (if you prefer that), or.. honestly 🤷 whatever floats your boat
My apologies for forgetting and abandoning PR; strangely enough, I don't seem to have received any notification of the answer or milestone changes 🤔 |
Please describe the changes this PR makes and why it should be merged:
The function
<Util>.cleanContent
function replace all mentions by the text equivalent.This PR add the two missing mentions types :
</command:318312854816161792>
.<:emoji:318312854816161792>
.Status and versioning classification: