You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

emoji.md 3.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. ---
  2. uid: Guides.Emoji
  3. title: Emoji
  4. ---
  5. # Emoji in Discord.Net
  6. Before we delve into the difference between an @Discord.Emoji and an
  7. @Discord.Emote in Discord.Net, it is **crucial** to understand what
  8. they both look like behind the scene. When the end-users are sending
  9. or receiving an emoji or emote, they are typically in the form of
  10. `:ok_hand:` or `:reeee:`; however, what goes under the hood is that,
  11. depending on the type of emoji, they are sent in an entirely
  12. different format.
  13. What does this all mean? It means that you should know that by
  14. reacting with a string like `“:ok_hand:”` will **NOT** automatically
  15. translate to `👌`; rather, it will be treated as-is,
  16. like `:ok_hand:`, thus the server will return a `400 Bad Request`.
  17. ## Emoji
  18. An emoji is a standard emoji that can be found anywhere else outside
  19. of Discord, which means strings like `👌`, `♥`, `👀` are all
  20. considered an emoji in Discord. However, from the
  21. introduction paragraph we have learned that we cannot
  22. simply send `:ok_hand:` and have Discord take
  23. care of it, but what do we need to send exactly?
  24. To send an emoji correctly, one must send the emoji in its Unicode
  25. form; this can be obtained in several different ways.
  26. 1. (Easiest) Escape the emoji by using the escape character, `\`, in
  27. your Discord chat client; this will reveal the emoji’s pure Unicode
  28. form, which will allow you to copy-paste into your code.
  29. 2. Look it up on Emojipedia, from which you can copy the emoji
  30. easily into your code.
  31. ![Emojipedia](images/emojipedia.png)
  32. 3. (Recommended) Look it up in the Emoji list from [FileFormat.Info];
  33. this will give you the .NET-compatible code that
  34. represents the emoji.
  35. * This is the most recommended method because some systems or
  36. IDE sometimes do not render the Unicode emoji correctly.
  37. ![Fileformat Emoji Source Code](images/fileformat-emoji-src.png)
  38. ### Emoji Declaration
  39. After obtaining the Unicode representation of the emoji, you may
  40. create the @Discord.Emoji object by passing the string into its
  41. constructor (e.g. `new Emoji("👌");` or `new Emoji("\uD83D\uDC4C");`).
  42. Your method of declaring an @Discord.Emoji should look similar to
  43. this:
  44. [!code-csharp[Emoji Sample](samples/emoji-sample.cs)]
  45. [FileFormat.Info]: https://www.fileformat.info/info/emoji/list.htm
  46. ## Emote
  47. The meat of the debate is here; what is an emote and how does it
  48. differ from an emoji? An emote refers to a **custom emoji**
  49. created on Discord.
  50. The underlying structure of an emote also differs drastically; an
  51. emote looks sort-of like a mention on Discord. It consists of two
  52. main elements as illustrated below:
  53. ![Emote illustration](images/emote-format.png)
  54. As you can see, emote uses a completely different format. To obtain
  55. the raw string as shown above for your emote, you would need to
  56. escape the emote using the escape character `\` in chat somewhere.
  57. ### Emote Declaration
  58. After obtaining the raw emote string, you would need to use
  59. @Discord.Emote.Parse* or @Discord.Emote.TryParse* to create a valid
  60. emote object.
  61. Your method of declaring an @Discord.Emote should look similar to
  62. this:
  63. [!code[Emote Sample](samples/emote-sample.cs)]
  64. > [!TIP]
  65. > For WebSocket users, you may also consider fetching the Emote
  66. > via the @Discord.WebSocket.SocketGuild.Emotes collection.
  67. > [!code-csharp[Socket emote sample](samples/socket-emote-sample.cs)]
  68. ## Additional Information
  69. To learn more about emote and emojis and how they could be used,
  70. see the documentation of @Discord.IEmote.