Skip to content
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

Closed

Conversation

DraftProducts
Copy link
Contributor

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 :

  • Commands mentions: </command:318312854816161792>.
  • Custom emojis mentions: <:emoji:318312854816161792>.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@vercel
Copy link

vercel bot commented Feb 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
discord-js ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 26, 2023 at 4:34AM (UTC)
discord-js-guide ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 26, 2023 at 4:34AM (UTC)

@jaw0r3k
Copy link
Contributor

jaw0r3k commented Feb 18, 2023

:name: doesnt look like a proper way to show an emoji

@DraftProducts
Copy link
Contributor Author

:name doesnt look like a proper way to show an emoji

Discord render emojis like that : :name:

@jaw0r3k
Copy link
Contributor

jaw0r3k commented Feb 18, 2023

Discord render emojis like that : :name:

Then nvm

@vercel
Copy link

vercel bot commented Mar 26, 2023

@DraftProducts is attempting to deploy a commit to the discordjs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link

github-actions bot commented Mar 26, 2023

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 75
🟢 Accessibility 94
🟢 Best practices 100
🟢 SEO 100
🟠 PWA 70

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) => {
Copy link
Member

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.

Google Chrome Dev - 2023-03-29 at 17 03 58@2x

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

Google Chrome Dev - 2023-03-29 at 17 14 12@2x

@DraftProducts
Copy link
Contributor Author

My apologies for forgetting and abandoning PR; strangely enough, I don't seem to have received any notification of the answer or milestone changes 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants