Browse Source

Cleanup emoji docs

pull/988/head
Hsu Still 7 years ago
parent
commit
8cdf46464e
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
5 changed files with 19 additions and 39 deletions
  1. +1
    -1
      docs/faq/basics/basic-operations.md
  2. +6
    -12
      src/Discord.Net.Core/Entities/Emotes/Emoji.cs
  3. +9
    -17
      src/Discord.Net.Core/Entities/Emotes/Emote.cs
  4. +1
    -3
      src/Discord.Net.Core/Entities/Emotes/GuildEmote.cs
  5. +2
    -6
      src/Discord.Net.Core/Entities/Emotes/IEmote.cs

+ 1
- 1
docs/faq/basics/basic-operations.md View File

@@ -70,7 +70,7 @@ as in field values. With that in mind, links can be added with

Any entity that implements [IUserMessage] has an [AddReactionAsync]
method. This method expects an [IEmote] as a parameter.
In Discord.Net, an Emote represents a server custom emote, while an
In Discord.Net, an Emote represents a custom-image emote, while an
Emoji is a Unicode emoji (standard emoji). Both [Emoji] and [Emote]
implement [IEmote] and are valid options.



+ 6
- 12
src/Discord.Net.Core/Entities/Emotes/Emoji.cs View File

@@ -1,22 +1,16 @@
namespace Discord
{
/// <summary>
/// A unicode emoji.
/// </summary>
/// <summary> A Unicode emoji. </summary>
public class Emoji : IEmote
{
// TODO: need to constrain this to unicode-only emojis somehow

/// <summary>
/// The unicode representation of this emote.
/// </summary>
// TODO: need to constrain this to Unicode-only emojis somehow
/// <summary> Gets the Unicode representation of this emote. </summary>
public string Name { get; }
/// <summary> Gets the Unicode representation of this emote. </summary>
public override string ToString() => Name;

/// <summary>
/// Creates a unicode emoji.
/// </summary>
/// <summary> Creates a Unicode emoji. </summary>
/// <param name="unicode">The pure UTF-8 encoding of an emoji</param>
public Emoji(string unicode)
{


+ 9
- 17
src/Discord.Net.Core/Entities/Emotes/Emote.cs View File

@@ -3,24 +3,18 @@ using System.Globalization;

namespace Discord
{
/// <summary>
/// A custom image-based emote.
/// </summary>
/// <summary> A custom image-based emote. </summary>
public class Emote : IEmote, ISnowflakeEntity
{
/// <summary>
/// The display name (tooltip) of this emote.
/// </summary>
/// <summary> Gets the display name (tooltip) of this emote. </summary>
public string Name { get; }
/// <summary>
/// The ID of this emote.
/// </summary>
/// <summary> Gets the ID of this emote. </summary>
public ulong Id { get; }
/// <summary>
/// Is this emote animated?
/// </summary>
/// <summary> Gets whether this emote animated? </summary>
public bool Animated { get; }
/// <summary> Gets the date when this emote is created. </summary>
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
/// <summary> Gets the image URL of this emote. </summary>
public string Url => CDN.GetEmojiUrl(Id, Animated);

internal Emote(ulong id, string name, bool animated)
@@ -49,16 +43,14 @@ namespace Discord
}
}

/// <summary>
/// Parses an Emote from its raw format.
/// </summary>
/// <param name="text">The raw encoding of an emote; for example, &lt;:dab:277855270321782784&gt;</param>
/// <summary> Parses an <see cref="Emote"/> from its raw format. </summary>
/// <param name="text">The raw encoding of an emote; for example, &lt;:dab:277855270321782784&gt;.</param>
/// <returns>An emote</returns>
public static Emote Parse(string text)
{
if (TryParse(text, out Emote result))
return result;
throw new ArgumentException("Invalid emote format", nameof(text));
throw new ArgumentException("Invalid emote format.", nameof(text));
}

public static bool TryParse(string text, out Emote result)


+ 1
- 3
src/Discord.Net.Core/Entities/Emotes/GuildEmote.cs View File

@@ -3,9 +3,7 @@ using System.Diagnostics;

namespace Discord
{
/// <summary>
/// An image-based emote that is attached to a guild.
/// </summary>
/// <summary> An image-based emote that is attached to a guild. </summary>
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class GuildEmote : Emote
{


+ 2
- 6
src/Discord.Net.Core/Entities/Emotes/IEmote.cs View File

@@ -1,13 +1,9 @@
namespace Discord
{
/// <summary>
/// A general container for any type of emote in a message.
/// </summary>
/// <summary> Represents a general container for any type of emote in a message. </summary>
public interface IEmote
{
/// <summary>
/// The display name or unicode representation of this emote
/// </summary>
/// <summary> Gets the display name or Unicode representation of this emote. </summary>
string Name { get; }
}
}

Loading…
Cancel
Save