Add Server.IconUrl and use cdn url for User.AvatarUrl
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
{
|
||||
public const string BaseStatusApi = "https://status.discordapp.com/api/v2/";
|
||||
public const string BaseApi = "https://discordapp.com/api/";
|
||||
public const string BaseCdn = "https://cdn.discordapp.com/";
|
||||
|
||||
public const string Gateway = "gateway";
|
||||
|
||||
@@ -31,6 +32,7 @@
|
||||
public static string ServerPrune(long serverId, int days) => $"guilds/{serverId}/prune?days={days}";
|
||||
public static string ServerRoles(long serverId) => $"guilds/{serverId}/roles";
|
||||
public static string ServerRole(long serverId, long roleId) => $"guilds/{serverId}/roles/{roleId}";
|
||||
public static string ServerIcon(long serverId, string iconId) => BaseCdn + $"icons/{serverId}/{iconId}.jpg";
|
||||
|
||||
public const string Invites = "invite";
|
||||
public static string Invite(long inviteId) => $"invite/{inviteId}";
|
||||
@@ -39,9 +41,9 @@
|
||||
public static string InviteUrl(string inviteIdOrXkcd) => $"https://discord.gg/{inviteIdOrXkcd}";
|
||||
|
||||
public const string Users = "users";
|
||||
public static string UserAvatar(long userId, string avatarId) => BaseApi + $"users/{userId}/avatars/{avatarId}.jpg";
|
||||
public static string UserChannels(long userId) => $"users/{userId}/channels";
|
||||
public static string UserMe => $"users/@me";
|
||||
public static string UserChannels(long userId) => $"users/{userId}/channels";
|
||||
public static string UserAvatar(long serverId, string avatarId) => BaseCdn + $"avatars/{serverId}/{avatarId}.jpg";
|
||||
|
||||
public const string Voice = "voice";
|
||||
public const string VoiceRegions = "voice/regions";
|
||||
|
||||
@@ -111,7 +111,6 @@ namespace Discord
|
||||
|
||||
try { await _api.LeaveServer(server.Id).ConfigureAwait(false); }
|
||||
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { }
|
||||
//return _servers.TryRemove(server.Id);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Region>> GetVoiceRegions()
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Discord
|
||||
/// <summary> Returns the unique identifier for this user's avatar. </summary>
|
||||
public string AvatarId { get; }
|
||||
/// <summary> Returns the full path to this user's avatar. </summary>
|
||||
public string AvatarUrl => User.GetAvatarUrl(Id, AvatarId);
|
||||
public string AvatarUrl => AvatarId != null ? Endpoints.UserAvatar(Id, AvatarId) : null;
|
||||
|
||||
internal InviterInfo(long id, string name, int discriminator, string avatarId)
|
||||
{
|
||||
|
||||
@@ -33,6 +33,10 @@ namespace Discord
|
||||
public DateTime JoinedAt { get; private set; }
|
||||
/// <summary> Returns the region for this server (see Regions). </summary>
|
||||
public string Region { get; private set; }
|
||||
/// <summary> Returns the unique identifier for this user's current avatar. </summary>
|
||||
public string IconId { get; private set; }
|
||||
/// <summary> Returns the URL to this user's current avatar. </summary>
|
||||
public string IconUrl => IconId != null ? Endpoints.ServerIcon(Id, IconId) : null;
|
||||
|
||||
/// <summary> Returns true if the current user created this server. </summary>
|
||||
public bool IsOwner => _client.CurrentUserId == _owner.Id;
|
||||
@@ -154,6 +158,8 @@ namespace Discord
|
||||
_owner.Id = model.OwnerId.Value;
|
||||
if (model.Region != null)
|
||||
Region = model.Region;
|
||||
if (model.Icon != null)
|
||||
IconId = model.Icon;
|
||||
|
||||
if (model.Roles != null)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,6 @@ namespace Discord
|
||||
=> unchecked(ServerId.GetHashCode() + UserId.GetHashCode() + 23);
|
||||
}
|
||||
|
||||
internal static string GetAvatarUrl(long userId, string avatarId) => avatarId != null ? Endpoints.UserAvatar(userId, avatarId) : null;
|
||||
|
||||
/// <summary> Returns a unique identifier combining this user's id with its server's. </summary>
|
||||
internal CompositeKey UniqueId => new CompositeKey(_server.Id ?? 0, Id);
|
||||
/// <summary> Returns the name of this user on this server. </summary>
|
||||
@@ -34,7 +32,7 @@ namespace Discord
|
||||
/// <summary> Returns the unique identifier for this user's current avatar. </summary>
|
||||
public string AvatarId { get; private set; }
|
||||
/// <summary> Returns the URL to this user's current avatar. </summary>
|
||||
public string AvatarUrl => GetAvatarUrl(Id, AvatarId);
|
||||
public string AvatarUrl => AvatarId != null ? Endpoints.UserAvatar(Id, AvatarId) : null;
|
||||
/// <summary> Returns the datetime that this user joined this server. </summary>
|
||||
public DateTime JoinedAt { get; private set; }
|
||||
|
||||
@@ -161,12 +159,12 @@ namespace Discord
|
||||
|
||||
internal void Update(UserReference model)
|
||||
{
|
||||
if (model.Avatar != null)
|
||||
AvatarId = model.Avatar;
|
||||
if (model.Discriminator != null)
|
||||
Discriminator = model.Discriminator.Value;
|
||||
if (model.Username != null)
|
||||
Name = model.Username;
|
||||
if (model.Discriminator != null)
|
||||
Discriminator = model.Discriminator.Value;
|
||||
if (model.Avatar != null)
|
||||
AvatarId = model.Avatar;
|
||||
}
|
||||
internal void Update(MemberInfo model)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user