feat: add support for custom discord emotes

This commit is contained in:
Oliver Booth 2023-08-27 21:27:41 +01:00
parent 67a5f9777a
commit f3d035d67b
Signed by: oliverbooth
GPG Key ID: B89D139977693FED
1 changed files with 14 additions and 0 deletions

View File

@ -24,6 +24,11 @@ public static class MentionUtility
else
switch (contents[0])
{
// custom emote
case ':':
ParseCustomEmote(contents, ref builder, whitespaceTrivia);
break;
// user mention
case '@':
ParseUserMention(guild, contents, ref builder, whitespaceTrivia);
@ -71,6 +76,15 @@ public static class MentionUtility
whitespaceTrivia);
}
private static void ParseCustomEmote(ReadOnlySpan<char> contents,
ref PlainTextMessageBuilder builder,
char whitespaceTrivia)
{
contents = contents[1..];
ReadOnlySpan<char> name = contents[..contents.IndexOf(':')];
builder.AddWord($":{name.ToString()}:", whitespaceTrivia);
}
private static void ParseTimestamp(ReadOnlySpan<char> contents,
ref PlainTextMessageBuilder builder,
char whitespaceTrivia)