diff --git a/README.md b/README.md index 18dab9f72..9c3e6eaa4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Discord.Net v1.0.0-dev -[![NuGet Pre Release](https://img.shields.io/nuget/vpre/Discord.Net.svg?maxAge=2592000?style=plastic)](https://www.nuget.org/packages/Discord.Net) [![AppVeyor](https://img.shields.io/appveyor/ci/foxbot/discord-net.svg?maxAge=2592000?style=plastic)](https://ci.appveyor.com/project/foxbot/discord-net/) [![Discord](https://discordapp.com/api/servers/81384788765712384/widget.png)](https://discord.gg/0SBTUU1wZTYLhAAW) +[![MyGet](https://img.shields.io/myget/discord-net/vpre/Discord.Net.svg?maxAge=2592000)](https://www.myget.org/feed/Packages/discord-net) [![AppVeyor](https://img.shields.io/appveyor/ci/foxbot/discord-net.svg?maxAge=2592000?style=plastic)](https://ci.appveyor.com/project/foxbot/discord-net/) [![Discord](https://discordapp.com/api/servers/81384788765712384/widget.png)](https://discord.gg/0SBTUU1wZTYLhAAW) An unofficial .Net API Wrapper for the Discord client (http://discordapp.com). diff --git a/src/Discord.Net/DiscordSocketClient.cs b/src/Discord.Net/DiscordSocketClient.cs index 30dd40487..a2ca7def3 100644 --- a/src/Discord.Net/DiscordSocketClient.cs +++ b/src/Discord.Net/DiscordSocketClient.cs @@ -892,6 +892,12 @@ namespace Discord } else { + if (!guild.HasAllMembers) + { + await _gatewayLogger.DebugAsync("Ignored GUILD_MEMBER_UPDATE, this user has not been downloaded yet.").ConfigureAwait(false); + return; + } + await _gatewayLogger.WarningAsync("GUILD_MEMBER_UPDATE referenced an unknown user.").ConfigureAwait(false); return; } @@ -926,6 +932,12 @@ namespace Discord } else { + if (!guild.HasAllMembers) + { + await _gatewayLogger.DebugAsync("Ignored GUILD_MEMBER_REMOVE, this user has not been downloaded yet.").ConfigureAwait(false); + return; + } + await _gatewayLogger.WarningAsync("GUILD_MEMBER_REMOVE referenced an unknown user.").ConfigureAwait(false); return; } diff --git a/src/Discord.Net/Entities/WebSocket/CachedDMChannel.cs b/src/Discord.Net/Entities/WebSocket/CachedDMChannel.cs index c22aa645b..40d0f72c7 100644 --- a/src/Discord.Net/Entities/WebSocket/CachedDMChannel.cs +++ b/src/Discord.Net/Entities/WebSocket/CachedDMChannel.cs @@ -13,7 +13,7 @@ namespace Discord public new DiscordSocketClient Discord => base.Discord as DiscordSocketClient; public new CachedDMUser Recipient => base.Recipient as CachedDMUser; public IReadOnlyCollection Members => ImmutableArray.Create(Discord.CurrentUser, Recipient); - IReadOnlyCollection ICachedPrivateChannel.Recipients => ImmutableArray.Create(Recipient); + IReadOnlyCollection ICachedPrivateChannel.Recipients => ImmutableArray.Create(Recipient); public CachedDMChannel(DiscordSocketClient discord, CachedDMUser recipient, Model model) : base(discord, recipient, model) diff --git a/src/Discord.Net/Entities/WebSocket/CachedGlobalUser.cs b/src/Discord.Net/Entities/WebSocket/CachedGlobalUser.cs index 04ff30eb0..7f09bf6e7 100644 --- a/src/Discord.Net/Entities/WebSocket/CachedGlobalUser.cs +++ b/src/Discord.Net/Entities/WebSocket/CachedGlobalUser.cs @@ -11,6 +11,7 @@ namespace Discord public Presence Presence { get; private set; } public new DiscordSocketClient Discord { get { throw new NotSupportedException(); } } + CachedGlobalUser ICachedUser.User => this; public CachedGlobalUser(Model model) : base(model) diff --git a/src/Discord.Net/Entities/WebSocket/CachedGroupChannel.cs b/src/Discord.Net/Entities/WebSocket/CachedGroupChannel.cs index 6b217d217..783bcd133 100644 --- a/src/Discord.Net/Entities/WebSocket/CachedGroupChannel.cs +++ b/src/Discord.Net/Entities/WebSocket/CachedGroupChannel.cs @@ -8,7 +8,6 @@ using MessageModel = Discord.API.Message; using Model = Discord.API.Channel; using UserModel = Discord.API.User; using VoiceStateModel = Discord.API.VoiceState; -using Discord.API; namespace Discord { @@ -20,7 +19,7 @@ namespace Discord public new DiscordSocketClient Discord => base.Discord as DiscordSocketClient; public IReadOnlyCollection Members => _users.Select(x => x.Value as ICachedUser).Concat(ImmutableArray.Create(Discord.CurrentUser)).ToReadOnlyCollection(() => _users.Count + 1); - public new IReadOnlyCollection Recipients => _users.Cast().ToReadOnlyCollection(_users); + public new IReadOnlyCollection Recipients => _users.Select(x => x.Value as ICachedUser).ToReadOnlyCollection(_users); public CachedGroupChannel(DiscordSocketClient discord, Model model) : base(discord, model) diff --git a/src/Discord.Net/Entities/WebSocket/CachedSelfUser.cs b/src/Discord.Net/Entities/WebSocket/CachedSelfUser.cs index 9b3543c11..5e9c2dbc2 100644 --- a/src/Discord.Net/Entities/WebSocket/CachedSelfUser.cs +++ b/src/Discord.Net/Entities/WebSocket/CachedSelfUser.cs @@ -1,10 +1,12 @@ -using Model = Discord.API.User; +using System; +using Model = Discord.API.User; namespace Discord { internal class CachedSelfUser : SelfUser, ICachedUser { public new DiscordSocketClient Discord => base.Discord as DiscordSocketClient; + CachedGlobalUser ICachedUser.User { get { throw new NotSupportedException(); } } public CachedSelfUser(DiscordSocketClient discord, Model model) : base(discord, model) diff --git a/src/Discord.Net/Entities/WebSocket/ICachedPrivateChannel.cs b/src/Discord.Net/Entities/WebSocket/ICachedPrivateChannel.cs index 3b9081521..af2d885be 100644 --- a/src/Discord.Net/Entities/WebSocket/ICachedPrivateChannel.cs +++ b/src/Discord.Net/Entities/WebSocket/ICachedPrivateChannel.cs @@ -4,6 +4,6 @@ namespace Discord { internal interface ICachedPrivateChannel : ICachedChannel, IPrivateChannel { - new IReadOnlyCollection Recipients { get; } + new IReadOnlyCollection Recipients { get; } } } diff --git a/src/Discord.Net/Entities/WebSocket/ICachedUser.cs b/src/Discord.Net/Entities/WebSocket/ICachedUser.cs index e9e7d2929..fbae8c5ff 100644 --- a/src/Discord.Net/Entities/WebSocket/ICachedUser.cs +++ b/src/Discord.Net/Entities/WebSocket/ICachedUser.cs @@ -2,6 +2,8 @@ { internal interface ICachedUser : IUser, ICachedEntity { + CachedGlobalUser User { get; } + ICachedUser Clone(); } } diff --git a/src/Discord.Net/Net/Queue/RequestQueueBucket.cs b/src/Discord.Net/Net/Queue/RequestQueueBucket.cs index 5521a2967..2ec9a9e02 100644 --- a/src/Discord.Net/Net/Queue/RequestQueueBucket.cs +++ b/src/Discord.Net/Net/Queue/RequestQueueBucket.cs @@ -42,7 +42,7 @@ namespace Discord.Net.Queue } catch (HttpRateLimitException ex) { - //When a 429 occurs, we drop all our locks, including the ones we wanted. + //When a 429 occurs, we drop all our locks. //This is generally safe though since 429s actually occuring should be very rare. RequestQueueBucket bucket; bool success = FindBucket(ex.BucketId, out bucket); @@ -152,7 +152,8 @@ namespace Discord.Net.Queue if (millis <= 0 || !await _semaphore.WaitAsync(millis).ConfigureAwait(false)) throw new TimeoutException(); } - await _semaphore.WaitAsync().ConfigureAwait(false); + else + await _semaphore.WaitAsync().ConfigureAwait(false); } private async Task QueueExitAsync() {