-
-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for animated emoji (#913)
* Added support for animated emoji This was such a useful feature Discord, I'm glad you added this instead of fixing bugs. * Fix bugs in emote parser * Added unit tests for emotes
- Loading branch information
Showing
8 changed files
with
68 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace Discord | ||
{ | ||
public class EmoteTests | ||
{ | ||
[Fact] | ||
public void Test_Emote_Parse() | ||
{ | ||
Assert.True(Emote.TryParse("<:typingstatus:394207658351263745>", out Emote emote)); | ||
Assert.NotNull(emote); | ||
Assert.Equal("typingstatus", emote.Name); | ||
Assert.Equal(394207658351263745UL, emote.Id); | ||
Assert.False(emote.Animated); | ||
Assert.Equal(DateTimeOffset.FromUnixTimeMilliseconds(1514056829775), emote.CreatedAt); | ||
Assert.EndsWith("png", emote.Url); | ||
} | ||
[Fact] | ||
public void Test_Invalid_Emote_Parse() | ||
{ | ||
Assert.False(Emote.TryParse("invalid", out _)); | ||
Assert.False(Emote.TryParse("<:typingstatus:not_a_number>", out _)); | ||
Assert.Throws<ArgumentException>(() => Emote.Parse("invalid")); | ||
} | ||
[Fact] | ||
public void Test_Animated_Emote_Parse() | ||
{ | ||
Assert.True(Emote.TryParse("<a:typingstatus:394207658351263745>", out Emote emote)); | ||
Assert.NotNull(emote); | ||
Assert.Equal("typingstatus", emote.Name); | ||
Assert.Equal(394207658351263745UL, emote.Id); | ||
Assert.True(emote.Animated); | ||
Assert.Equal(DateTimeOffset.FromUnixTimeMilliseconds(1514056829775), emote.CreatedAt); | ||
Assert.EndsWith("gif", emote.Url); | ||
} | ||
public void Test_Invalid_Amimated_Emote_Parse() | ||
{ | ||
Assert.False(Emote.TryParse("<x:typingstatus:394207658351263745>", out _)); | ||
Assert.False(Emote.TryParse("<a:typingstatus>", out _)); | ||
Assert.False(Emote.TryParse("<a:typingstatus:not_a_number>", out _)); | ||
} | ||
} | ||
} |