fix(bot): display new Discord usernames correctly
This commit is contained in:
parent
11d70666d0
commit
a0fa03599b
@ -23,6 +23,7 @@ public record User
|
|||||||
public ulong Id { get; init; }
|
public ulong Id { get; init; }
|
||||||
public string Username { get; init; }
|
public string Username { get; init; }
|
||||||
public string Discriminator { get; init; }
|
public string Discriminator { get; init; }
|
||||||
|
public string GlobalName { get; init; }
|
||||||
public string? Avatar { get; init; }
|
public string? Avatar { get; init; }
|
||||||
public bool Bot { get; init; }
|
public bool Bot { get; init; }
|
||||||
public bool? System { get; init; }
|
public bool? System { get; init; }
|
||||||
|
@ -386,7 +386,7 @@ public class ProxyService
|
|||||||
content.Append($"*[(click to see attachment)]({jumpLink})*");
|
content.Append($"*[(click to see attachment)]({jumpLink})*");
|
||||||
}
|
}
|
||||||
|
|
||||||
var username = nickname ?? repliedTo.Author.Username;
|
var username = nickname ?? repliedTo.Author.GlobalName ?? repliedTo.Author.Username;
|
||||||
var avatarUrl = avatar != null
|
var avatarUrl = avatar != null
|
||||||
? $"https://cdn.discordapp.com/guilds/{trigger.GuildId}/users/{repliedTo.Author.Id}/avatars/{avatar}.png"
|
? $"https://cdn.discordapp.com/guilds/{trigger.GuildId}/users/{repliedTo.Author.Id}/avatars/{avatar}.png"
|
||||||
: $"https://cdn.discordapp.com/avatars/{repliedTo.Author.Id}/{repliedTo.Author.Avatar}.png";
|
: $"https://cdn.discordapp.com/avatars/{repliedTo.Author.Id}/{repliedTo.Author.Avatar}.png";
|
||||||
|
@ -35,7 +35,7 @@ public static class DiscordUtils
|
|||||||
private static readonly Regex UNBROKEN_LINK_REGEX = new("<?(https?:\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])>?");
|
private static readonly Regex UNBROKEN_LINK_REGEX = new("<?(https?:\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])>?");
|
||||||
|
|
||||||
public static string NameAndMention(this User user) =>
|
public static string NameAndMention(this User user) =>
|
||||||
$"{user.Username}#{user.Discriminator} ({user.Mention()})";
|
$"{user.Username}{(user.Discriminator == "0" ? "" : $"#{user.Discriminator}")} ({user.Mention()})";
|
||||||
|
|
||||||
public static Instant SnowflakeToInstant(ulong snowflake) =>
|
public static Instant SnowflakeToInstant(ulong snowflake) =>
|
||||||
Instant.FromUtc(2015, 1, 1, 0, 0, 0) + Duration.FromMilliseconds(snowflake >> 22);
|
Instant.FromUtc(2015, 1, 1, 0, 0, 0) + Duration.FromMilliseconds(snowflake >> 22);
|
||||||
|
Loading…
Reference in New Issue
Block a user