Archived
1
0
Fork 0

user update fixes

This commit is contained in:
flash 2017-05-21 20:49:34 +02:00
parent 597c350b9c
commit c81ea9441c
3 changed files with 13 additions and 4 deletions

View file

@ -723,6 +723,15 @@ namespace Maki
{ {
DiscordMember member = members.Find(x => x.User.Id == presence.User.Id && x.Server.Id == presence.Guild); DiscordMember member = members.Find(x => x.User.Id == presence.User.Id && x.Server.Id == presence.Guild);
if (!string.IsNullOrEmpty(presence.User.Username))
member.User.Username = presence.User.Username;
if (presence.User.Tag.HasValue)
member.User.Tag = presence.User.Tag.Value;
if (!string.IsNullOrEmpty(presence.User.AvatarHash))
member.User.avatarHash = presence.User.AvatarHash;
member.User.Game = presence.Game.HasValue ? new DiscordGame(presence.Game.Value) : null; member.User.Game = presence.Game.HasValue ? new DiscordGame(presence.Game.Value) : null;
if (presence.Roles != null) if (presence.Roles != null)

View file

@ -20,11 +20,11 @@ namespace Maki
public DiscordUserStatus Status { get; internal set; } public DiscordUserStatus Status { get; internal set; }
public DiscordGame Game { get; internal set; } public DiscordGame Game { get; internal set; }
internal string avatarHash;
public string NameWithTag => $"{Username}#{Tag:0000}"; public string NameWithTag => $"{Username}#{Tag:0000}";
public override string ToString() => $"<@{Id}>"; public override string ToString() => $"<@{Id}>";
private string avatarHash;
public string Avatar(string ext = @"png", int size = 128) => RestEndpoints.CDN_URL + $@"/avatars/{Id}/{avatarHash}.{ext}?size={size}"; public string Avatar(string ext = @"png", int size = 128) => RestEndpoints.CDN_URL + $@"/avatars/{Id}/{avatarHash}.{ext}?size={size}";
internal DiscordUser(Discord discord, User user) internal DiscordUser(Discord discord, User user)
@ -33,7 +33,7 @@ namespace Maki
Id = user.Id; Id = user.Id;
Created = Utility.FromDiscordTimeMilliseconds((long) Id >> 22); Created = Utility.FromDiscordTimeMilliseconds((long) Id >> 22);
Username = user.Username; Username = user.Username;
Tag = user.Tag; Tag = user.Tag.Value;
IsBot = user.IsBot; IsBot = user.IsBot;
HasMFA = user.HasMFA; HasMFA = user.HasMFA;
IsVerified = user.IsVerified; IsVerified = user.IsVerified;

View file

@ -29,7 +29,7 @@ namespace Maki.Structures.Users
/// the user's 4-digit discord-tag /// the user's 4-digit discord-tag
/// </summary> /// </summary>
[JsonProperty("discriminator")] [JsonProperty("discriminator")]
public ushort Tag; public ushort? Tag;
/// <summary> /// <summary>
/// the user's avatar hash /// the user's avatar hash