Fix usage of CacheMode.AllowDownload in channels (#2154)

Co-Authored-By:  <25006819+sabihoshi@users.noreply.github.com>

Co-authored-by:  <25006819+sabihoshi@users.noreply.github.com>
This commit is contained in:
Quin Lynch
2022-03-02 19:22:59 -04:00
committed by GitHub
parent 6bf5818e72
commit b3370c33e2
11 changed files with 97 additions and 35 deletions

View File

@@ -543,7 +543,7 @@ namespace Discord.WebSocket
if(model == null)
return null;
if (model.GuildId.IsSpecified)
{
var guild = State.GetGuild(model.GuildId.Value);
@@ -2128,7 +2128,7 @@ namespace Discord.WebSocket
{
await TimedInvokeAsync(_speakerRemoved, nameof(SpeakerRemoved), stage, guildUser);
}
}
}
}
await TimedInvokeAsync(_userVoiceStateUpdatedEvent, nameof(UserVoiceStateUpdated), user, before, after).ConfigureAwait(false);
@@ -2520,7 +2520,7 @@ namespace Discord.WebSocket
}
break;
case "THREAD_MEMBERS_UPDATE":
case "THREAD_MEMBERS_UPDATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (THREAD_MEMBERS_UPDATE)").ConfigureAwait(false);
@@ -3113,7 +3113,14 @@ namespace Discord.WebSocket
/// <inheritdoc />
async Task<IUser> IDiscordClient.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> mode == CacheMode.AllowDownload ? await GetUserAsync(id, options).ConfigureAwait(false) : GetUser(id);
{
var user = GetUser(id);
if (user is not null || mode == CacheMode.CacheOnly)
return user;
return await Rest.GetUserAsync(id, options).ConfigureAwait(false);
}
/// <inheritdoc />
Task<IUser> IDiscordClient.GetUserAsync(string username, string discriminator, RequestOptions options)
=> Task.FromResult<IUser>(GetUser(username, discriminator));