|
@@ -3,24 +3,18 @@ using System.Globalization; |
|
|
|
|
|
|
|
|
namespace Discord |
|
|
namespace Discord |
|
|
{ |
|
|
{ |
|
|
/// <summary> |
|
|
|
|
|
/// A custom image-based emote. |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
|
/// <summary> A custom image-based emote. </summary> |
|
|
public class Emote : IEmote, ISnowflakeEntity |
|
|
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; } |
|
|
public string Name { get; } |
|
|
/// <summary> |
|
|
|
|
|
/// The ID of this emote. |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
|
/// <summary> Gets the ID of this emote. </summary> |
|
|
public ulong Id { get; } |
|
|
public ulong Id { get; } |
|
|
/// <summary> |
|
|
|
|
|
/// Is this emote animated? |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
|
/// <summary> Gets whether this emote animated? </summary> |
|
|
public bool Animated { get; } |
|
|
public bool Animated { get; } |
|
|
|
|
|
/// <summary> Gets the date when this emote is created. </summary> |
|
|
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); |
|
|
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); |
|
|
|
|
|
/// <summary> Gets the image URL of this emote. </summary> |
|
|
public string Url => CDN.GetEmojiUrl(Id, Animated); |
|
|
public string Url => CDN.GetEmojiUrl(Id, Animated); |
|
|
|
|
|
|
|
|
internal Emote(ulong id, string name, bool 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, <:dab:277855270321782784></param> |
|
|
|
|
|
|
|
|
/// <summary> Parses an <see cref="Emote"/> from its raw format. </summary> |
|
|
|
|
|
/// <param name="text">The raw encoding of an emote; for example, <:dab:277855270321782784>.</param> |
|
|
/// <returns>An emote</returns> |
|
|
/// <returns>An emote</returns> |
|
|
public static Emote Parse(string text) |
|
|
public static Emote Parse(string text) |
|
|
{ |
|
|
{ |
|
|
if (TryParse(text, out Emote result)) |
|
|
if (TryParse(text, out Emote result)) |
|
|
return 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) |
|
|
public static bool TryParse(string text, out Emote result) |
|
|