Skip to content

Conversation

BannerBomb
Copy link
Contributor

@BannerBomb BannerBomb commented Jul 28, 2019

Please describe the changes this PR makes and why it should be merged:
Paragraph on this PR
I changed the regex to output the results if you provide <aemoji:123456789012345678> and <:aemoji:123456789012345678> which will output { animated: false, name: "aemoji", id: "123456789012345678" } or <:emojiname:> which outputs { animated: false, name: "emojiname", id: null } or <a:emoji:> which would output { animated: true, name: "emoji", id: null }. Before this PR the method would return that the emoji was animated if you provided something like <anemojiname:emoji_id> because the name started with an a.


Simplified description of this PR (using examples)
I changed the regex a bit for the parseEmoji function to fix a few parsing issues.
Parsing results before this PR:

 "<anemojiname:123456789012345678>"	-	{ animated: true, name: "nemojiname", id: "123456789012345678" } // [this would be a possible false positive because the name starts with an 'a' but doesn't include an ':' to separate it from the name.]
 "<atest:>"				-	null
 "<:emojiName:>"			-	null
 "<a:emojiName:>"			-	null
 "<atest>"				-	null

Parsing results after this PR:

 "<anemojiname:123456789012345678>"	-	{ animated: false, name: "anemojiname", id: "123456789012345678" }
 "<atest:>"				-	{ animated: false, name: "atest", id: null }
 "<:emojiName:>"			-	{ animated: false, name: "emojiName", id: null }
 "<a:emojiName:>"			-	{ animated: true, name: "emojiName", id: null }
 "<atest>"				-	null // [since it's an invalid emoji.]

Status

  • 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

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

I just made a small change to the parseEmoji regex, this change will make an invalid emoji, like `<aname:id>` return as null, before this change it would return as an animated emoji because the name started with an `a` which would result in false positives, then the `?` I added to the end of `(\d{17,19})?` is used if someone provided an emoji as `:name:` or `a:name:` it will return the correct values but have an invalid id.
2nd Update: I changed the regex to output the results if you provide `<aemoji:123456789012345678>` and <:aemoji:123456789012345678>` which will output `{ animated: false, name: "aemoji", id: "123456789012345678" }` or `<:emojiname:>` which outputs `{ animated: false, name: "emojiname", id: null }` or `<a:emoji:>` which would output `{ animated: true, name: "emoji", id: null }`. Before this PR the method would return that the emoji was animated if you provided something like `<anemojiname:emoji_id>` because the name started with an `a`.
Copy link
Member

@vladfrangu vladfrangu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Past the fact the ID is now optional (should it, tho?), this is a 👍 from me

@SpaceEEC SpaceEEC merged commit b662678 into discordjs:master Aug 17, 2019
@BannerBomb BannerBomb deleted the patch-1 branch August 29, 2019 10:04
samsamson33 pushed a commit to samsamson33/discord.js that referenced this pull request Feb 27, 2020
…ional (discordjs#3407)

* Small changes to parseEmoji regex

I just made a small change to the parseEmoji regex, this change will make an invalid emoji, like `<aname:id>` return as null, before this change it would return as an animated emoji because the name started with an `a` which would result in false positives, then the `?` I added to the end of `(\d{17,19})?` is used if someone provided an emoji as `:name:` or `a:name:` it will return the correct values but have an invalid id.

* Update Util.js

2nd Update: I changed the regex to output the results if you provide `<aemoji:123456789012345678>` and <:aemoji:123456789012345678>` which will output `{ animated: false, name: "aemoji", id: "123456789012345678" }` or `<:emojiname:>` which outputs `{ animated: false, name: "emojiname", id: null }` or `<a:emoji:>` which would output `{ animated: true, name: "emoji", id: null }`. Before this PR the method would return that the emoji was animated if you provided something like `<anemojiname:emoji_id>` because the name started with an `a`.
samsamson33 added a commit to samsamson33/discord.js that referenced this pull request Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants