Added missing ConfigureAwaits

This commit is contained in:
RogueException
2016-10-08 16:59:17 -03:00
parent 960119d965
commit 5c33e28757
40 changed files with 166 additions and 166 deletions

View File

@@ -201,7 +201,7 @@ namespace Discord.Commands
var commands = searchResult.Commands; var commands = searchResult.Commands;
for (int i = commands.Count - 1; i >= 0; i--) for (int i = commands.Count - 1; i >= 0; i--)
{ {
var preconditionResult = await commands[i].CheckPreconditions(context); var preconditionResult = await commands[i].CheckPreconditions(context).ConfigureAwait(false);
if (!preconditionResult.IsSuccess) if (!preconditionResult.IsSuccess)
{ {
if (commands.Count == 1) if (commands.Count == 1)
@@ -210,7 +210,7 @@ namespace Discord.Commands
continue; continue;
} }
var parseResult = await commands[i].Parse(context, searchResult, preconditionResult); var parseResult = await commands[i].Parse(context, searchResult, preconditionResult).ConfigureAwait(false);
if (!parseResult.IsSuccess) if (!parseResult.IsSuccess)
{ {
if (parseResult.Error == CommandError.MultipleMatches) if (parseResult.Error == CommandError.MultipleMatches)
@@ -235,7 +235,7 @@ namespace Discord.Commands
} }
} }
return await commands[i].Execute(context, parseResult); return await commands[i].Execute(context, parseResult).ConfigureAwait(false);
} }
return SearchResult.FromError(CommandError.UnknownCommand, "This input does not match any overload."); return SearchResult.FromError(CommandError.UnknownCommand, "This input does not match any overload.");

View File

@@ -116,7 +116,7 @@ namespace Discord.API
_restClient.SetHeader("authorization", GetPrefixedToken(AuthTokenType, _authToken)); _restClient.SetHeader("authorization", GetPrefixedToken(AuthTokenType, _authToken));
if (FetchCurrentUser) if (FetchCurrentUser)
CurrentUser = await GetMyUserAsync(new RequestOptions { IgnoreState = true }); CurrentUser = await GetMyUserAsync(new RequestOptions { IgnoreState = true }).ConfigureAwait(false);
LoginState = LoginState.LoggedIn; LoginState = LoginState.LoggedIn;
} }

View File

@@ -130,7 +130,7 @@ namespace Discord.Net.Queue
if (millis <= 0 || !await _semaphore.WaitAsync(millis).ConfigureAwait(false)) if (millis <= 0 || !await _semaphore.WaitAsync(millis).ConfigureAwait(false))
throw new TimeoutException(); throw new TimeoutException();
if (!await _semaphore.WaitAsync(0)) if (!await _semaphore.WaitAsync(0).ConfigureAwait(false))
{ {
await _queue.RaiseRateLimitTriggered(Id, this, null).ConfigureAwait(false); await _queue.RaiseRateLimitTriggered(Id, this, null).ConfigureAwait(false);

View File

@@ -54,7 +54,7 @@ namespace Discord.Net.WebSockets
await _sendLock.WaitAsync().ConfigureAwait(false); await _sendLock.WaitAsync().ConfigureAwait(false);
try try
{ {
await ConnectInternalAsync(host); await ConnectInternalAsync(host).ConfigureAwait(false);
} }
finally finally
{ {
@@ -86,7 +86,7 @@ namespace Discord.Net.WebSockets
await _sendLock.WaitAsync().ConfigureAwait(false); await _sendLock.WaitAsync().ConfigureAwait(false);
try try
{ {
await DisconnectInternalAsync(); await DisconnectInternalAsync().ConfigureAwait(false);
} }
finally finally
{ {

View File

@@ -45,7 +45,7 @@ namespace Discord
if (_info.Remaining == 0) if (_info.Remaining == 0)
return false; return false;
var data = await _source._getPage(_info, cancelToken); var data = await _source._getPage(_info, cancelToken).ConfigureAwait(false);
Current = new Page<T>(_info, data); Current = new Page<T>(_info, data);
_info.Page++; _info.Page++;

View File

@@ -78,14 +78,14 @@ namespace Discord.Rest
async Task<IChannel> IDiscordClient.GetChannelAsync(ulong id, CacheMode mode) async Task<IChannel> IDiscordClient.GetChannelAsync(ulong id, CacheMode mode)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetChannelAsync(id); return await GetChannelAsync(id).ConfigureAwait(false);
else else
return null; return null;
} }
async Task<IReadOnlyCollection<IPrivateChannel>> IDiscordClient.GetPrivateChannelsAsync(CacheMode mode) async Task<IReadOnlyCollection<IPrivateChannel>> IDiscordClient.GetPrivateChannelsAsync(CacheMode mode)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetPrivateChannelsAsync(); return await GetPrivateChannelsAsync().ConfigureAwait(false);
else else
return ImmutableArray.Create<IPrivateChannel>(); return ImmutableArray.Create<IPrivateChannel>();
} }

View File

@@ -23,7 +23,7 @@ namespace Discord.Rest
{ {
var args = new ModifyGuildChannelParams(); var args = new ModifyGuildChannelParams();
func(args); func(args);
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options); return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options).ConfigureAwait(false);
} }
public static async Task<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client, public static async Task<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client,
Action<ModifyTextChannelParams> func, Action<ModifyTextChannelParams> func,
@@ -31,7 +31,7 @@ namespace Discord.Rest
{ {
var args = new ModifyTextChannelParams(); var args = new ModifyTextChannelParams();
func(args); func(args);
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options); return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options).ConfigureAwait(false);
} }
public static async Task<Model> ModifyAsync(IVoiceChannel channel, BaseDiscordClient client, public static async Task<Model> ModifyAsync(IVoiceChannel channel, BaseDiscordClient client,
Action<ModifyVoiceChannelParams> func, Action<ModifyVoiceChannelParams> func,
@@ -39,14 +39,14 @@ namespace Discord.Rest
{ {
var args = new ModifyVoiceChannelParams(); var args = new ModifyVoiceChannelParams();
func(args); func(args);
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options); return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options).ConfigureAwait(false);
} }
//Invites //Invites
public static async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(IChannel channel, BaseDiscordClient client, public static async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(IChannel channel, BaseDiscordClient client,
RequestOptions options) RequestOptions options)
{ {
var models = await client.ApiClient.GetChannelInvitesAsync(channel.Id, options); var models = await client.ApiClient.GetChannelInvitesAsync(channel.Id, options).ConfigureAwait(false);
return models.Select(x => RestInviteMetadata.Create(client, x)).ToImmutableArray(); return models.Select(x => RestInviteMetadata.Create(client, x)).ToImmutableArray();
} }
public static async Task<RestInviteMetadata> CreateInviteAsync(IChannel channel, BaseDiscordClient client, public static async Task<RestInviteMetadata> CreateInviteAsync(IChannel channel, BaseDiscordClient client,
@@ -57,7 +57,7 @@ namespace Discord.Rest
args.MaxAge = maxAge.Value; args.MaxAge = maxAge.Value;
if (maxUses.HasValue) if (maxUses.HasValue)
args.MaxUses = maxUses.Value; args.MaxUses = maxUses.Value;
var model = await client.ApiClient.CreateChannelInviteAsync(channel.Id, args, options); var model = await client.ApiClient.CreateChannelInviteAsync(channel.Id, args, options).ConfigureAwait(false);
return RestInviteMetadata.Create(client, model); return RestInviteMetadata.Create(client, model);
} }
@@ -83,7 +83,7 @@ namespace Discord.Rest
}; };
if (info.Position != null) if (info.Position != null)
args.RelativeMessageId = info.Position.Value; args.RelativeMessageId = info.Position.Value;
var models = await client.ApiClient.GetChannelMessagesAsync(channel.Id, args, options); var models = await client.ApiClient.GetChannelMessagesAsync(channel.Id, args, options).ConfigureAwait(false);
return models.Select(x => RestMessage.Create(client, guild, x)).ToImmutableArray(); ; return models.Select(x => RestMessage.Create(client, guild, x)).ToImmutableArray(); ;
}, },
nextPage: (info, lastPage) => nextPage: (info, lastPage) =>
@@ -164,7 +164,7 @@ namespace Discord.Rest
public static async Task<RestGuildUser> GetUserAsync(IGuildChannel channel, IGuild guild, BaseDiscordClient client, public static async Task<RestGuildUser> GetUserAsync(IGuildChannel channel, IGuild guild, BaseDiscordClient client,
ulong id, RequestOptions options) ulong id, RequestOptions options)
{ {
var model = await client.ApiClient.GetGuildMemberAsync(channel.GuildId, id, options); var model = await client.ApiClient.GetGuildMemberAsync(channel.GuildId, id, options).ConfigureAwait(false);
if (model == null) if (model == null)
return null; return null;
var user = RestGuildUser.Create(client, guild, model); var user = RestGuildUser.Create(client, guild, model);
@@ -186,7 +186,7 @@ namespace Discord.Rest
}; };
if (info.Position != null) if (info.Position != null)
args.AfterUserId = info.Position.Value; args.AfterUserId = info.Position.Value;
var models = await guild.Discord.ApiClient.GetGuildMembersAsync(guild.Id, args, options); var models = await guild.Discord.ApiClient.GetGuildMembersAsync(guild.Id, args, options).ConfigureAwait(false);
return models return models
.Select(x => RestGuildUser.Create(client, guild, x)) .Select(x => RestGuildUser.Create(client, guild, x))
.Where(x => x.GetPermissions(channel).ReadMessages) .Where(x => x.GetPermissions(channel).ReadMessages)
@@ -207,7 +207,7 @@ namespace Discord.Rest
public static async Task TriggerTypingAsync(IMessageChannel channel, BaseDiscordClient client, public static async Task TriggerTypingAsync(IMessageChannel channel, BaseDiscordClient client,
RequestOptions options = null) RequestOptions options = null)
{ {
await client.ApiClient.TriggerTypingIndicatorAsync(channel.Id, options); await client.ApiClient.TriggerTypingIndicatorAsync(channel.Id, options).ConfigureAwait(false);
} }
public static IDisposable EnterTypingState(IMessageChannel channel, BaseDiscordClient client, public static IDisposable EnterTypingState(IMessageChannel channel, BaseDiscordClient client,
RequestOptions options) RequestOptions options)

View File

@@ -36,7 +36,7 @@ namespace Discord.Rest
public override async Task UpdateAsync(RequestOptions options = null) public override async Task UpdateAsync(RequestOptions options = null)
{ {
var model = await Discord.ApiClient.GetChannelAsync(Id, options); var model = await Discord.ApiClient.GetChannelAsync(Id, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public Task CloseAsync(RequestOptions options = null) public Task CloseAsync(RequestOptions options = null)
@@ -94,7 +94,7 @@ namespace Discord.Rest
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id, options); return await GetMessageAsync(id, options).ConfigureAwait(false);
else else
return null; return null;
} }
@@ -120,14 +120,14 @@ namespace Discord.Rest
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, options); => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options); => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);

View File

@@ -51,7 +51,7 @@ namespace Discord.Rest
public override async Task UpdateAsync(RequestOptions options = null) public override async Task UpdateAsync(RequestOptions options = null)
{ {
var model = await Discord.ApiClient.GetChannelAsync(Id, options); var model = await Discord.ApiClient.GetChannelAsync(Id, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public Task LeaveAsync(RequestOptions options = null) public Task LeaveAsync(RequestOptions options = null)
@@ -104,7 +104,7 @@ namespace Discord.Rest
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id, options); return await GetMessageAsync(id, options).ConfigureAwait(false);
else else
return null; return null;
} }
@@ -130,14 +130,14 @@ namespace Discord.Rest
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, options); => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options); => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);

View File

@@ -51,12 +51,12 @@ namespace Discord.Rest
public override async Task UpdateAsync(RequestOptions options = null) public override async Task UpdateAsync(RequestOptions options = null)
{ {
var model = await Discord.ApiClient.GetChannelAsync(GuildId, Id, options); var model = await Discord.ApiClient.GetChannelAsync(GuildId, Id, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public async Task ModifyAsync(Action<ModifyGuildChannelParams> func, RequestOptions options = null) public async Task ModifyAsync(Action<ModifyGuildChannelParams> func, RequestOptions options = null)
{ {
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options); var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public Task DeleteAsync(RequestOptions options = null) public Task DeleteAsync(RequestOptions options = null)
@@ -118,30 +118,30 @@ namespace Discord.Rest
} }
public async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) public async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null)
=> await ChannelHelper.GetInvitesAsync(this, Discord, options); => await ChannelHelper.GetInvitesAsync(this, Discord, options).ConfigureAwait(false);
public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true, RequestOptions options = null) public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true, RequestOptions options = null)
=> await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, options); => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, options).ConfigureAwait(false);
public override string ToString() => Name; public override string ToString() => Name;
//IGuildChannel //IGuildChannel
async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options) async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options)
=> await GetInvitesAsync(options); => await GetInvitesAsync(options).ConfigureAwait(false);
async Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, RequestOptions options) async Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, RequestOptions options)
=> await CreateInviteAsync(maxAge, maxUses, isTemporary, options); => await CreateInviteAsync(maxAge, maxUses, isTemporary, options).ConfigureAwait(false);
OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IRole role) OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IRole role)
=> GetPermissionOverwrite(role); => GetPermissionOverwrite(role);
OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user) OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user)
=> GetPermissionOverwrite(user); => GetPermissionOverwrite(user);
async Task IGuildChannel.AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options) async Task IGuildChannel.AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options)
=> await AddPermissionOverwriteAsync(role, permissions, options); => await AddPermissionOverwriteAsync(role, permissions, options).ConfigureAwait(false);
async Task IGuildChannel.AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options) async Task IGuildChannel.AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options)
=> await AddPermissionOverwriteAsync(user, permissions, options); => await AddPermissionOverwriteAsync(user, permissions, options).ConfigureAwait(false);
async Task IGuildChannel.RemovePermissionOverwriteAsync(IRole role, RequestOptions options) async Task IGuildChannel.RemovePermissionOverwriteAsync(IRole role, RequestOptions options)
=> await RemovePermissionOverwriteAsync(role, options); => await RemovePermissionOverwriteAsync(role, options).ConfigureAwait(false);
async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options) async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options)
=> await RemovePermissionOverwriteAsync(user, options); => await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false);
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); //Overriden //Overriden in Text/Voice //TODO: Does this actually override? => AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); //Overriden //Overriden in Text/Voice //TODO: Does this actually override?

View File

@@ -35,7 +35,7 @@ namespace Discord.Rest
public async Task ModifyAsync(Action<ModifyTextChannelParams> func, RequestOptions options = null) public async Task ModifyAsync(Action<ModifyTextChannelParams> func, RequestOptions options = null)
{ {
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options); var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model); Update(model);
} }
@@ -76,7 +76,7 @@ namespace Discord.Rest
async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetUserAsync(id, options); return await GetUserAsync(id, options).ConfigureAwait(false);
else else
return null; return null;
} }
@@ -92,7 +92,7 @@ namespace Discord.Rest
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id, options); return await GetMessageAsync(id, options).ConfigureAwait(false);
else else
return null; return null;
} }
@@ -118,14 +118,14 @@ namespace Discord.Rest
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, options); => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options); => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);
} }

View File

@@ -35,7 +35,7 @@ namespace Discord.Rest
public async Task ModifyAsync(Action<ModifyVoiceChannelParams> func, RequestOptions options = null) public async Task ModifyAsync(Action<ModifyVoiceChannelParams> func, RequestOptions options = null)
{ {
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options); var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model); Update(model);
} }

View File

@@ -62,7 +62,7 @@ namespace Discord.Rest
public static async Task<IReadOnlyCollection<RestBan>> GetBansAsync(IGuild guild, BaseDiscordClient client, public static async Task<IReadOnlyCollection<RestBan>> GetBansAsync(IGuild guild, BaseDiscordClient client,
RequestOptions options) RequestOptions options)
{ {
var models = await client.ApiClient.GetGuildBansAsync(guild.Id, options); var models = await client.ApiClient.GetGuildBansAsync(guild.Id, options).ConfigureAwait(false);
return models.Select(x => RestBan.Create(client, x)).ToImmutableArray(); return models.Select(x => RestBan.Create(client, x)).ToImmutableArray();
} }
@@ -70,12 +70,12 @@ namespace Discord.Rest
ulong userId, int pruneDays, RequestOptions options) ulong userId, int pruneDays, RequestOptions options)
{ {
var args = new CreateGuildBanParams { DeleteMessageDays = pruneDays }; var args = new CreateGuildBanParams { DeleteMessageDays = pruneDays };
await client.ApiClient.CreateGuildBanAsync(guild.Id, userId, args, options); await client.ApiClient.CreateGuildBanAsync(guild.Id, userId, args, options).ConfigureAwait(false);
} }
public static async Task RemoveBanAsync(IGuild guild, BaseDiscordClient client, public static async Task RemoveBanAsync(IGuild guild, BaseDiscordClient client,
ulong userId, RequestOptions options) ulong userId, RequestOptions options)
{ {
await client.ApiClient.RemoveGuildBanAsync(guild.Id, userId, options); await client.ApiClient.RemoveGuildBanAsync(guild.Id, userId, options).ConfigureAwait(false);
} }
//Channels //Channels

View File

@@ -100,18 +100,18 @@ namespace Discord.Rest
//General //General
public async Task UpdateAsync(RequestOptions options = null) public async Task UpdateAsync(RequestOptions options = null)
=> Update(await Discord.ApiClient.GetGuildAsync(Id, options)); => Update(await Discord.ApiClient.GetGuildAsync(Id, options).ConfigureAwait(false));
public Task DeleteAsync(RequestOptions options = null) public Task DeleteAsync(RequestOptions options = null)
=> GuildHelper.DeleteAsync(this, Discord, options); => GuildHelper.DeleteAsync(this, Discord, options);
public async Task ModifyAsync(Action<ModifyGuildParams> func, RequestOptions options = null) public async Task ModifyAsync(Action<ModifyGuildParams> func, RequestOptions options = null)
{ {
var model = await GuildHelper.ModifyAsync(this, Discord, func, options); var model = await GuildHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public async Task ModifyEmbedAsync(Action<ModifyGuildEmbedParams> func, RequestOptions options = null) public async Task ModifyEmbedAsync(Action<ModifyGuildEmbedParams> func, RequestOptions options = null)
{ {
var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options); var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public async Task ModifyChannelsAsync(IEnumerable<ModifyGuildChannelsParams> args, RequestOptions options = null) public async Task ModifyChannelsAsync(IEnumerable<ModifyGuildChannelsParams> args, RequestOptions options = null)
@@ -121,7 +121,7 @@ namespace Discord.Rest
} }
public async Task ModifyRolesAsync(IEnumerable<ModifyGuildRolesParams> args, RequestOptions options = null) public async Task ModifyRolesAsync(IEnumerable<ModifyGuildRolesParams> args, RequestOptions options = null)
{ {
var models = await GuildHelper.ModifyRolesAsync(this, Discord, args, options); var models = await GuildHelper.ModifyRolesAsync(this, Discord, args, options).ConfigureAwait(false);
foreach (var model in models) foreach (var model in models)
{ {
var role = GetRole(model.Id); var role = GetRole(model.Id);
@@ -179,7 +179,7 @@ namespace Discord.Rest
public async Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?), public async Task<RestRole> CreateRoleAsync(string name, GuildPermissions? permissions = default(GuildPermissions?), Color? color = default(Color?),
bool isHoisted = false, RequestOptions options = null) bool isHoisted = false, RequestOptions options = null)
{ {
var role = await GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, options); var role = await GuildHelper.CreateRoleAsync(this, Discord, name, permissions, color, isHoisted, options).ConfigureAwait(false);
_roles = _roles.Add(role.Id, role); _roles = _roles.Add(role.Id, role);
return role; return role;
} }
@@ -205,58 +205,58 @@ namespace Discord.Rest
IReadOnlyCollection<IRole> IGuild.Roles => Roles; IReadOnlyCollection<IRole> IGuild.Roles => Roles;
async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options) async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options)
=> await GetBansAsync(options); => await GetBansAsync(options).ConfigureAwait(false);
async Task<IReadOnlyCollection<IGuildChannel>> IGuild.GetChannelsAsync(CacheMode mode, RequestOptions options) async Task<IReadOnlyCollection<IGuildChannel>> IGuild.GetChannelsAsync(CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetChannelsAsync(options); return await GetChannelsAsync(options).ConfigureAwait(false);
else else
return ImmutableArray.Create<IGuildChannel>(); return ImmutableArray.Create<IGuildChannel>();
} }
async Task<IGuildChannel> IGuild.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IGuildChannel> IGuild.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetChannelAsync(id, options); return await GetChannelAsync(id, options).ConfigureAwait(false);
else else
return null; return null;
} }
async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, RequestOptions options) async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, RequestOptions options)
=> await CreateTextChannelAsync(name, options); => await CreateTextChannelAsync(name, options).ConfigureAwait(false);
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options) async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
=> await CreateVoiceChannelAsync(name, options); => await CreateVoiceChannelAsync(name, options).ConfigureAwait(false);
async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options) async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options)
=> await GetIntegrationsAsync(options); => await GetIntegrationsAsync(options).ConfigureAwait(false);
async Task<IGuildIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options) async Task<IGuildIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options)
=> await CreateIntegrationAsync(id, type, options); => await CreateIntegrationAsync(id, type, options).ConfigureAwait(false);
async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options)
=> await GetInvitesAsync(options); => await GetInvitesAsync(options).ConfigureAwait(false);
IRole IGuild.GetRole(ulong id) IRole IGuild.GetRole(ulong id)
=> GetRole(id); => GetRole(id);
async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options) async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options)
=> await CreateRoleAsync(name, permissions, color, isHoisted, options); => await CreateRoleAsync(name, permissions, color, isHoisted, options).ConfigureAwait(false);
async Task<IGuildUser> IGuild.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IGuildUser> IGuild.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetUserAsync(id, options); return await GetUserAsync(id, options).ConfigureAwait(false);
else else
return null; return null;
} }
async Task<IGuildUser> IGuild.GetCurrentUserAsync(CacheMode mode, RequestOptions options) async Task<IGuildUser> IGuild.GetCurrentUserAsync(CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetCurrentUserAsync(options); return await GetCurrentUserAsync(options).ConfigureAwait(false);
else else
return null; return null;
} }
async Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) async Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return (await GetUsersAsync(options).Flatten()).ToImmutableArray(); return (await GetUsersAsync(options).Flatten().ConfigureAwait(false)).ToImmutableArray();
else else
return ImmutableArray.Create<IGuildUser>(); return ImmutableArray.Create<IGuildUser>();
} }

View File

@@ -35,7 +35,7 @@ namespace Discord.Rest
public async Task UpdateAsync(RequestOptions options = null) public async Task UpdateAsync(RequestOptions options = null)
{ {
var model = await Discord.ApiClient.GetInviteAsync(Code, options); var model = await Discord.ApiClient.GetInviteAsync(Code, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public Task DeleteAsync(RequestOptions options = null) public Task DeleteAsync(RequestOptions options = null)

View File

@@ -15,23 +15,23 @@ namespace Discord.Rest
{ {
var args = new ModifyMessageParams(); var args = new ModifyMessageParams();
func(args); func(args);
return await client.ApiClient.ModifyMessageAsync(msg.Channel.Id, msg.Id, args, options); return await client.ApiClient.ModifyMessageAsync(msg.Channel.Id, msg.Id, args, options).ConfigureAwait(false);
} }
public static async Task DeleteAsync(IMessage msg, BaseDiscordClient client, public static async Task DeleteAsync(IMessage msg, BaseDiscordClient client,
RequestOptions options) RequestOptions options)
{ {
await client.ApiClient.DeleteMessageAsync(msg.Channel.Id, msg.Id, options); await client.ApiClient.DeleteMessageAsync(msg.Channel.Id, msg.Id, options).ConfigureAwait(false);
} }
public static async Task PinAsync(IMessage msg, BaseDiscordClient client, public static async Task PinAsync(IMessage msg, BaseDiscordClient client,
RequestOptions options) RequestOptions options)
{ {
await client.ApiClient.AddPinAsync(msg.Channel.Id, msg.Id, options); await client.ApiClient.AddPinAsync(msg.Channel.Id, msg.Id, options).ConfigureAwait(false);
} }
public static async Task UnpinAsync(IMessage msg, BaseDiscordClient client, public static async Task UnpinAsync(IMessage msg, BaseDiscordClient client,
RequestOptions options) RequestOptions options)
{ {
await client.ApiClient.RemovePinAsync(msg.Channel.Id, msg.Id, options); await client.ApiClient.RemovePinAsync(msg.Channel.Id, msg.Id, options).ConfigureAwait(false);
} }
public static ImmutableArray<ITag> ParseTags(string text, IMessageChannel channel, IGuild guild, ImmutableArray<IUser> userMentions) public static ImmutableArray<ITag> ParseTags(string text, IMessageChannel channel, IGuild guild, ImmutableArray<IUser> userMentions)

View File

@@ -113,7 +113,7 @@ namespace Discord.Rest
public async Task ModifyAsync(Action<ModifyMessageParams> func, RequestOptions options) public async Task ModifyAsync(Action<ModifyMessageParams> func, RequestOptions options)
{ {
var model = await MessageHelper.ModifyAsync(this, Discord, func, options); var model = await MessageHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public Task DeleteAsync(RequestOptions options) public Task DeleteAsync(RequestOptions options)

View File

@@ -44,7 +44,7 @@ namespace Discord.Rest
public async Task ModifyAsync(Action<ModifyGuildRoleParams> func, RequestOptions options = null) public async Task ModifyAsync(Action<ModifyGuildRoleParams> func, RequestOptions options = null)
{ {
var model = await RoleHelper.ModifyAsync(this, Discord, func, options); var model = await RoleHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public Task DeleteAsync(RequestOptions options = null) public Task DeleteAsync(RequestOptions options = null)

View File

@@ -18,7 +18,7 @@ namespace Discord.Rest
{ {
var args = new ModifyGuildRoleParams(); var args = new ModifyGuildRoleParams();
func(args); func(args);
return await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, args, options); return await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, args, options).ConfigureAwait(false);
} }
} }
} }

View File

@@ -64,12 +64,12 @@ namespace Discord.Rest
public override async Task UpdateAsync(RequestOptions options = null) public override async Task UpdateAsync(RequestOptions options = null)
{ {
var model = await Discord.ApiClient.GetGuildMemberAsync(GuildId, Id, options); var model = await Discord.ApiClient.GetGuildMemberAsync(GuildId, Id, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public async Task ModifyAsync(Action<ModifyGuildMemberParams> func, RequestOptions options = null) public async Task ModifyAsync(Action<ModifyGuildMemberParams> func, RequestOptions options = null)
{ {
var args = await UserHelper.ModifyAsync(this, Discord, func, options); var args = await UserHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
if (args.Deaf.IsSpecified) if (args.Deaf.IsSpecified)
IsDeafened = args.Deaf.Value; IsDeafened = args.Deaf.Value;
if (args.Mute.IsSpecified) if (args.Mute.IsSpecified)

View File

@@ -37,7 +37,7 @@ namespace Discord.Rest
public override async Task UpdateAsync(RequestOptions options = null) public override async Task UpdateAsync(RequestOptions options = null)
{ {
var model = await Discord.ApiClient.GetMyUserAsync(options); var model = await Discord.ApiClient.GetMyUserAsync(options).ConfigureAwait(false);
if (model.Id != Id) if (model.Id != Id)
throw new InvalidOperationException("Unable to update this object using a different token."); throw new InvalidOperationException("Unable to update this object using a different token.");
Update(model); Update(model);
@@ -47,7 +47,7 @@ namespace Discord.Rest
{ {
if (Id != Discord.CurrentUser.Id) if (Id != Discord.CurrentUser.Id)
throw new InvalidOperationException("Unable to modify this object using a different token."); throw new InvalidOperationException("Unable to modify this object using a different token.");
var model = await UserHelper.ModifyAsync(this, Discord, func, options); var model = await UserHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model); Update(model);
} }

View File

@@ -42,7 +42,7 @@ namespace Discord.Rest
public virtual async Task UpdateAsync(RequestOptions options = null) public virtual async Task UpdateAsync(RequestOptions options = null)
{ {
var model = await Discord.ApiClient.GetUserAsync(Id, options); var model = await Discord.ApiClient.GetUserAsync(Id, options).ConfigureAwait(false);
Update(model); Update(model);
} }
@@ -56,6 +56,6 @@ namespace Discord.Rest
Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult<IDMChannel>(null); => Task.FromResult<IDMChannel>(null);
async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options)
=> await CreateDMChannelAsync(options); => await CreateDMChannelAsync(options).ConfigureAwait(false);
} }
} }

View File

@@ -12,28 +12,28 @@ namespace Discord.Rest
{ {
var args = new ModifyCurrentUserParams(); var args = new ModifyCurrentUserParams();
func(args); func(args);
return await client.ApiClient.ModifySelfAsync(args, options); return await client.ApiClient.ModifySelfAsync(args, options).ConfigureAwait(false);
} }
public static async Task<ModifyGuildMemberParams> ModifyAsync(IGuildUser user, BaseDiscordClient client, Action<ModifyGuildMemberParams> func, public static async Task<ModifyGuildMemberParams> ModifyAsync(IGuildUser user, BaseDiscordClient client, Action<ModifyGuildMemberParams> func,
RequestOptions options) RequestOptions options)
{ {
var args = new ModifyGuildMemberParams(); var args = new ModifyGuildMemberParams();
func(args); func(args);
await client.ApiClient.ModifyGuildMemberAsync(user.GuildId, user.Id, args, options); await client.ApiClient.ModifyGuildMemberAsync(user.GuildId, user.Id, args, options).ConfigureAwait(false);
return args; return args;
} }
public static async Task KickAsync(IGuildUser user, BaseDiscordClient client, public static async Task KickAsync(IGuildUser user, BaseDiscordClient client,
RequestOptions options) RequestOptions options)
{ {
await client.ApiClient.RemoveGuildMemberAsync(user.GuildId, user.Id, options); await client.ApiClient.RemoveGuildMemberAsync(user.GuildId, user.Id, options).ConfigureAwait(false);
} }
public static async Task<RestDMChannel> CreateDMChannelAsync(IUser user, BaseDiscordClient client, public static async Task<RestDMChannel> CreateDMChannelAsync(IUser user, BaseDiscordClient client,
RequestOptions options) RequestOptions options)
{ {
var args = new CreateDMChannelParams(user.Id); var args = new CreateDMChannelParams(user.Id);
return RestDMChannel.Create(client, await client.ApiClient.CreateDMChannelAsync(args, options)); return RestDMChannel.Create(client, await client.ApiClient.CreateDMChannelAsync(args, options).ConfigureAwait(false));
} }
} }
} }

View File

@@ -29,10 +29,10 @@ namespace Discord.Rest
{ {
try try
{ {
await _channel.TriggerTypingAsync(_options); await _channel.TriggerTypingAsync(_options).ConfigureAwait(false);
} }
catch { } catch { }
await Task.Delay(9750, token); await Task.Delay(9750, token).ConfigureAwait(false);
} }
} }
catch (OperationCanceledException) { } catch (OperationCanceledException) { }

View File

@@ -103,7 +103,7 @@ namespace Discord.Rpc
//Abort connection on timeout //Abort connection on timeout
var _ = Task.Run(async () => var _ = Task.Run(async () =>
{ {
await Task.Delay(ConnectionTimeout); await Task.Delay(ConnectionTimeout).ConfigureAwait(false);
connectTask.TrySetException(new TimeoutException()); connectTask.TrySetException(new TimeoutException());
}); });
@@ -231,27 +231,27 @@ namespace Discord.Rpc
public async Task SubscribeGlobal(RpcGlobalEvent evnt, RequestOptions options = null) public async Task SubscribeGlobal(RpcGlobalEvent evnt, RequestOptions options = null)
{ {
await ApiClient.SendGlobalSubscribeAsync(GetEventName(evnt), options); await ApiClient.SendGlobalSubscribeAsync(GetEventName(evnt), options).ConfigureAwait(false);
} }
public async Task UnsubscribeGlobal(RpcGlobalEvent evnt, RequestOptions options = null) public async Task UnsubscribeGlobal(RpcGlobalEvent evnt, RequestOptions options = null)
{ {
await ApiClient.SendGlobalUnsubscribeAsync(GetEventName(evnt), options); await ApiClient.SendGlobalUnsubscribeAsync(GetEventName(evnt), options).ConfigureAwait(false);
} }
public async Task SubscribeGuild(ulong guildId, RpcChannelEvent evnt, RequestOptions options = null) public async Task SubscribeGuild(ulong guildId, RpcChannelEvent evnt, RequestOptions options = null)
{ {
await ApiClient.SendGuildSubscribeAsync(GetEventName(evnt), guildId, options); await ApiClient.SendGuildSubscribeAsync(GetEventName(evnt), guildId, options).ConfigureAwait(false);
} }
public async Task UnsubscribeGuild(ulong guildId, RpcChannelEvent evnt, RequestOptions options = null) public async Task UnsubscribeGuild(ulong guildId, RpcChannelEvent evnt, RequestOptions options = null)
{ {
await ApiClient.SendGuildUnsubscribeAsync(GetEventName(evnt), guildId, options); await ApiClient.SendGuildUnsubscribeAsync(GetEventName(evnt), guildId, options).ConfigureAwait(false);
} }
public async Task SubscribeChannel(ulong channelId, RpcChannelEvent evnt, RequestOptions options = null) public async Task SubscribeChannel(ulong channelId, RpcChannelEvent evnt, RequestOptions options = null)
{ {
await ApiClient.SendChannelSubscribeAsync(GetEventName(evnt), channelId); await ApiClient.SendChannelSubscribeAsync(GetEventName(evnt), channelId).ConfigureAwait(false);
} }
public async Task UnsubscribeChannel(ulong channelId, RpcChannelEvent evnt, RequestOptions options = null) public async Task UnsubscribeChannel(ulong channelId, RpcChannelEvent evnt, RequestOptions options = null)
{ {
await ApiClient.SendChannelUnsubscribeAsync(GetEventName(evnt), channelId); await ApiClient.SendChannelUnsubscribeAsync(GetEventName(evnt), channelId).ConfigureAwait(false);
} }
public async Task<RpcGuild> GetRpcGuildAsync(ulong id, RequestOptions options = null) public async Task<RpcGuild> GetRpcGuildAsync(ulong id, RequestOptions options = null)

View File

@@ -72,14 +72,14 @@ namespace Discord.Rpc
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id, options); return await GetMessageAsync(id, options).ConfigureAwait(false);
else else
return null; return null;
} }
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return GetMessagesAsync(limit, options); return GetMessagesAsync(limit, options).ConfigureAwait(false);
else else
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
@@ -98,14 +98,14 @@ namespace Discord.Rpc
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, options); => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options); => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);

View File

@@ -71,14 +71,14 @@ namespace Discord.Rpc
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id, options); return await GetMessageAsync(id, options).ConfigureAwait(false);
else else
return null; return null;
} }
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return GetMessagesAsync(limit, options); return GetMessagesAsync(limit, options).ConfigureAwait(false);
else else
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
@@ -97,14 +97,14 @@ namespace Discord.Rpc
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, options); => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options); => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);

View File

@@ -51,17 +51,17 @@ namespace Discord.Rpc
=> ChannelHelper.RemovePermissionOverwriteAsync(this, Discord, role, options); => ChannelHelper.RemovePermissionOverwriteAsync(this, Discord, role, options);
public async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) public async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null)
=> await ChannelHelper.GetInvitesAsync(this, Discord, options); => await ChannelHelper.GetInvitesAsync(this, Discord, options).ConfigureAwait(false);
public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true, RequestOptions options = null) public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true, RequestOptions options = null)
=> await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, options); => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, options).ConfigureAwait(false);
public override string ToString() => Name; public override string ToString() => Name;
//IGuildChannel //IGuildChannel
async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options) async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options)
=> await GetInvitesAsync(options); => await GetInvitesAsync(options).ConfigureAwait(false);
async Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, RequestOptions options) async Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, RequestOptions options)
=> await CreateInviteAsync(maxAge, maxUses, isTemporary, options); => await CreateInviteAsync(maxAge, maxUses, isTemporary, options).ConfigureAwait(false);
IReadOnlyCollection<Overwrite> IGuildChannel.PermissionOverwrites { get { throw new NotSupportedException(); } } IReadOnlyCollection<Overwrite> IGuildChannel.PermissionOverwrites { get { throw new NotSupportedException(); } }
OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user) OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user)

View File

@@ -73,7 +73,7 @@ namespace Discord.Rpc
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id, options); return await GetMessageAsync(id, options).ConfigureAwait(false);
else else
return null; return null;
} }
@@ -99,14 +99,14 @@ namespace Discord.Rpc
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
} }
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, options); => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options); => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);
} }

View File

@@ -51,6 +51,6 @@ namespace Discord.Rpc
Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult<IDMChannel>(null); => Task.FromResult<IDMChannel>(null);
async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options)
=> await CreateDMChannelAsync(options); => await CreateDMChannelAsync(options).ConfigureAwait(false);
} }
} }

View File

@@ -107,7 +107,7 @@ namespace Discord.Audio
if (payload != null) if (payload != null)
bytes = Encoding.UTF8.GetBytes(SerializeJson(payload)); bytes = Encoding.UTF8.GetBytes(SerializeJson(payload));
await _webSocketClient.SendAsync(bytes, 0, bytes.Length, true).ConfigureAwait(false); await _webSocketClient.SendAsync(bytes, 0, bytes.Length, true).ConfigureAwait(false);
await _sentGatewayMessageEvent.InvokeAsync(opCode); await _sentGatewayMessageEvent.InvokeAsync(opCode).ConfigureAwait(false);
} }
public async Task SendAsync(byte[] data, int bytes) public async Task SendAsync(byte[] data, int bytes)
{ {
@@ -132,7 +132,7 @@ namespace Discord.Audio
UserId = userId, UserId = userId,
SessionId = sessionId, SessionId = sessionId,
Token = token Token = token
}); }).ConfigureAwait(false);
} }
public async Task SendSelectProtocol(string externalIp, int externalPort) public async Task SendSelectProtocol(string externalIp, int externalPort)
{ {
@@ -145,7 +145,7 @@ namespace Discord.Audio
Port = externalPort, Port = externalPort,
Mode = Mode Mode = Mode
} }
}); }).ConfigureAwait(false);
} }
public async Task SendSetSpeaking(bool value) public async Task SendSetSpeaking(bool value)
{ {
@@ -153,7 +153,7 @@ namespace Discord.Audio
{ {
IsSpeaking = value, IsSpeaking = value,
Delay = 0 Delay = 0
}); }).ConfigureAwait(false);
} }
public async Task ConnectAsync(string url) public async Task ConnectAsync(string url)

View File

@@ -269,7 +269,7 @@ namespace Discord.Audio
catch { return; } catch { return; }
await _audioLogger.DebugAsync("Received Discovery").ConfigureAwait(false); await _audioLogger.DebugAsync("Received Discovery").ConfigureAwait(false);
await ApiClient.SendSelectProtocol(ip, port); await ApiClient.SendSelectProtocol(ip, port).ConfigureAwait(false);
} }
} }
} }

View File

@@ -163,7 +163,7 @@ namespace Discord.WebSocket
//Abort connection on timeout //Abort connection on timeout
var _ = Task.Run(async () => var _ = Task.Run(async () =>
{ {
await Task.Delay(ConnectionTimeout); await Task.Delay(ConnectionTimeout).ConfigureAwait(false);
connectTask.TrySetException(new TimeoutException()); connectTask.TrySetException(new TimeoutException());
}); });
@@ -410,7 +410,7 @@ namespace Discord.WebSocket
//Wait for unsynced guilds to sync first. //Wait for unsynced guilds to sync first.
var unsyncedGuilds = guilds.Select(x => x.SyncPromise).Where(x => !x.IsCompleted).ToImmutableArray(); var unsyncedGuilds = guilds.Select(x => x.SyncPromise).Where(x => !x.IsCompleted).ToImmutableArray();
if (unsyncedGuilds.Length > 0) if (unsyncedGuilds.Length > 0)
await Task.WhenAll(unsyncedGuilds); await Task.WhenAll(unsyncedGuilds).ConfigureAwait(false);
//Download offline members //Download offline members
const short batchSize = 50; const short batchSize = 50;
@@ -1468,10 +1468,10 @@ namespace Discord.WebSocket
//Ignored (User only) //Ignored (User only)
case "CHANNEL_PINS_ACK": case "CHANNEL_PINS_ACK":
await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_ACK)"); await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_ACK)").ConfigureAwait(false);
break; break;
case "CHANNEL_PINS_UPDATE": case "CHANNEL_PINS_UPDATE":
await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_UPDATE)"); await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_UPDATE)").ConfigureAwait(false);
break; break;
case "GUILD_INTEGRATIONS_UPDATE": case "GUILD_INTEGRATIONS_UPDATE":
await _gatewayLogger.DebugAsync("Ignored Dispatch (GUILD_INTEGRATIONS_UPDATE)").ConfigureAwait(false); await _gatewayLogger.DebugAsync("Ignored Dispatch (GUILD_INTEGRATIONS_UPDATE)").ConfigureAwait(false);
@@ -1621,17 +1621,17 @@ namespace Discord.WebSocket
=> Task.FromResult<IReadOnlyCollection<IPrivateChannel>>(PrivateChannels); => Task.FromResult<IReadOnlyCollection<IPrivateChannel>>(PrivateChannels);
async Task<IReadOnlyCollection<IConnection>> IDiscordClient.GetConnectionsAsync() async Task<IReadOnlyCollection<IConnection>> IDiscordClient.GetConnectionsAsync()
=> await GetConnectionsAsync(); => await GetConnectionsAsync().ConfigureAwait(false);
async Task<IInvite> IDiscordClient.GetInviteAsync(string inviteId) async Task<IInvite> IDiscordClient.GetInviteAsync(string inviteId)
=> await GetInviteAsync(inviteId); => await GetInviteAsync(inviteId).ConfigureAwait(false);
Task<IGuild> IDiscordClient.GetGuildAsync(ulong id, CacheMode mode) Task<IGuild> IDiscordClient.GetGuildAsync(ulong id, CacheMode mode)
=> Task.FromResult<IGuild>(GetGuild(id)); => Task.FromResult<IGuild>(GetGuild(id));
Task<IReadOnlyCollection<IGuild>> IDiscordClient.GetGuildsAsync(CacheMode mode) Task<IReadOnlyCollection<IGuild>> IDiscordClient.GetGuildsAsync(CacheMode mode)
=> Task.FromResult<IReadOnlyCollection<IGuild>>(Guilds); => Task.FromResult<IReadOnlyCollection<IGuild>>(Guilds);
async Task<IGuild> IDiscordClient.CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon) async Task<IGuild> IDiscordClient.CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon)
=> await CreateGuildAsync(name, region, jpegIcon); => await CreateGuildAsync(name, region, jpegIcon).ConfigureAwait(false);
Task<IUser> IDiscordClient.GetUserAsync(ulong id, CacheMode mode) Task<IUser> IDiscordClient.GetUserAsync(ulong id, CacheMode mode)
=> Task.FromResult<IUser>(GetUser(id)); => Task.FromResult<IUser>(GetUser(id));

View File

@@ -48,7 +48,7 @@ namespace Discord.WebSocket
{ {
IMessage msg = _messages?.Get(id); IMessage msg = _messages?.Get(id);
if (msg == null) if (msg == null)
msg = await ChannelHelper.GetMessageAsync(this, Discord, id, null, options); msg = await ChannelHelper.GetMessageAsync(this, Discord, id, null, options).ConfigureAwait(false);
return msg; return msg;
} }
public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
@@ -118,7 +118,7 @@ namespace Discord.WebSocket
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id, options); return await GetMessageAsync(id, options).ConfigureAwait(false);
else else
return GetCachedMessage(id); return GetCachedMessage(id);
} }
@@ -131,11 +131,11 @@ namespace Discord.WebSocket
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, options); => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options); => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);

View File

@@ -71,7 +71,7 @@ namespace Discord.WebSocket
{ {
IMessage msg = _messages?.Get(id); IMessage msg = _messages?.Get(id);
if (msg == null) if (msg == null)
msg = await ChannelHelper.GetMessageAsync(this, Discord, id, null, options); msg = await ChannelHelper.GetMessageAsync(this, Discord, id, null, options).ConfigureAwait(false);
return msg; return msg;
} }
public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
@@ -181,7 +181,7 @@ namespace Discord.WebSocket
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id, options); return await GetMessageAsync(id, options).ConfigureAwait(false);
else else
return GetCachedMessage(id); return GetCachedMessage(id);
} }
@@ -194,11 +194,11 @@ namespace Discord.WebSocket
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, options); => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options); => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);

View File

@@ -112,9 +112,9 @@ namespace Discord.WebSocket
} }
public async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) public async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null)
=> await ChannelHelper.GetInvitesAsync(this, Discord, options); => await ChannelHelper.GetInvitesAsync(this, Discord, options).ConfigureAwait(false);
public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true, RequestOptions options = null) public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true, RequestOptions options = null)
=> await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, options); => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, options);.ConfigureAwait(false)
public new abstract SocketGuildUser GetUser(ulong id); public new abstract SocketGuildUser GetUser(ulong id);
@@ -129,22 +129,22 @@ namespace Discord.WebSocket
ulong IGuildChannel.GuildId => Guild.Id; ulong IGuildChannel.GuildId => Guild.Id;
async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options) async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options)
=> await GetInvitesAsync(options); => await GetInvitesAsync(options).ConfigureAwait(false);
async Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, RequestOptions options) async Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, RequestOptions options)
=> await CreateInviteAsync(maxAge, maxUses, isTemporary, options); => await CreateInviteAsync(maxAge, maxUses, isTemporary, options).ConfigureAwait(false);
OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IRole role) OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IRole role)
=> GetPermissionOverwrite(role); => GetPermissionOverwrite(role);
OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user) OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user)
=> GetPermissionOverwrite(user); => GetPermissionOverwrite(user);
async Task IGuildChannel.AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options) async Task IGuildChannel.AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options)
=> await AddPermissionOverwriteAsync(role, permissions, options); => await AddPermissionOverwriteAsync(role, permissions, options).ConfigureAwait(false);
async Task IGuildChannel.AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options) async Task IGuildChannel.AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options)
=> await AddPermissionOverwriteAsync(user, permissions, options); => await AddPermissionOverwriteAsync(user, permissions, options).ConfigureAwait(false);
async Task IGuildChannel.RemovePermissionOverwriteAsync(IRole role, RequestOptions options) async Task IGuildChannel.RemovePermissionOverwriteAsync(IRole role, RequestOptions options)
=> await RemovePermissionOverwriteAsync(role, options); => await RemovePermissionOverwriteAsync(role, options).ConfigureAwait(false);
async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options) async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options)
=> await RemovePermissionOverwriteAsync(user, options); => await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false);
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable(); => ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable();

View File

@@ -54,7 +54,7 @@ namespace Discord.WebSocket
{ {
IMessage msg = _messages?.Get(id); IMessage msg = _messages?.Get(id);
if (msg == null) if (msg == null)
msg = await ChannelHelper.GetMessageAsync(this, Discord, id, Guild, options); msg = await ChannelHelper.GetMessageAsync(this, Discord, id, Guild, options).ConfigureAwait(false);
return msg; return msg;
} }
public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null) public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
@@ -119,7 +119,7 @@ namespace Discord.WebSocket
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload) if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id, options); return await GetMessageAsync(id, options).ConfigureAwait(false);
else else
return GetCachedMessage(id); return GetCachedMessage(id);
} }
@@ -132,11 +132,11 @@ namespace Discord.WebSocket
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(stream, filename, text, isTTS, options); => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options); => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options) IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options); => EnterTypingState(options);
} }

View File

@@ -387,7 +387,7 @@ namespace Discord.WebSocket
public async Task DownloadUsersAsync() public async Task DownloadUsersAsync()
{ {
await Discord.DownloadUsersAsync(new[] { this }); await Discord.DownloadUsersAsync(new[] { this }).ConfigureAwait(false);
} }
internal void CompleteDownloadUsers() internal void CompleteDownloadUsers()
{ {
@@ -495,12 +495,12 @@ namespace Discord.WebSocket
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
await DisconnectAudioAsync(); await DisconnectAudioAsync().ConfigureAwait(false);
} }
catch (Exception e) catch (Exception e)
{ {
await _audioConnectPromise.SetExceptionAsync(e).ConfigureAwait(false); await _audioConnectPromise.SetExceptionAsync(e).ConfigureAwait(false);
await DisconnectAudioAsync(); await DisconnectAudioAsync().ConfigureAwait(false);
} }
finally finally
{ {
@@ -532,29 +532,29 @@ namespace Discord.WebSocket
IReadOnlyCollection<IRole> IGuild.Roles => Roles; IReadOnlyCollection<IRole> IGuild.Roles => Roles;
async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options) async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options)
=> await GetBansAsync(options); => await GetBansAsync(options).ConfigureAwait(false);
Task<IReadOnlyCollection<IGuildChannel>> IGuild.GetChannelsAsync(CacheMode mode, RequestOptions options) Task<IReadOnlyCollection<IGuildChannel>> IGuild.GetChannelsAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult<IReadOnlyCollection<IGuildChannel>>(Channels); => Task.FromResult<IReadOnlyCollection<IGuildChannel>>(Channels);
Task<IGuildChannel> IGuild.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options) Task<IGuildChannel> IGuild.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult<IGuildChannel>(GetChannel(id)); => Task.FromResult<IGuildChannel>(GetChannel(id));
async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, RequestOptions options) async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, RequestOptions options)
=> await CreateTextChannelAsync(name, options); => await CreateTextChannelAsync(name, options).ConfigureAwait(false);
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options) async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
=> await CreateVoiceChannelAsync(name, options); => await CreateVoiceChannelAsync(name, options).ConfigureAwait(false);
async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options) async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options)
=> await GetIntegrationsAsync(options); => await GetIntegrationsAsync(options).ConfigureAwait(false);
async Task<IGuildIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options) async Task<IGuildIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options)
=> await CreateIntegrationAsync(id, type, options); => await CreateIntegrationAsync(id, type, options).ConfigureAwait(false);
async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options)
=> await GetInvitesAsync(options); => await GetInvitesAsync(options).ConfigureAwait(false);
IRole IGuild.GetRole(ulong id) IRole IGuild.GetRole(ulong id)
=> GetRole(id); => GetRole(id);
async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options) async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options)
=> await CreateRoleAsync(name, permissions, color, isHoisted, options); => await CreateRoleAsync(name, permissions, color, isHoisted, options).ConfigureAwait(false);
Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult<IReadOnlyCollection<IGuildUser>>(Users); => Task.FromResult<IReadOnlyCollection<IGuildUser>>(Users);

View File

@@ -80,7 +80,7 @@ namespace Discord.WebSocket
Presence = new SocketPresence(status, game); Presence = new SocketPresence(status, game);
await SendStatus(status, game); await SendStatus(status, game).ConfigureAwait(false);
} }
internal async Task SendStatus(UserStatus status, GameEntity? game) internal async Task SendStatus(UserStatus status, GameEntity? game)
{ {
@@ -95,7 +95,7 @@ namespace Discord.WebSocket
status, status,
status == UserStatus.AFK, status == UserStatus.AFK,
_statusSince != null ? _statusSince.Value.ToUnixTimeMilliseconds() : (long?)null, _statusSince != null ? _statusSince.Value.ToUnixTimeMilliseconds() : (long?)null,
gameModel); gameModel).ConfigureAwait(false);
} }
internal new SocketSelfUser Clone() => MemberwiseClone() as SocketSelfUser; internal new SocketSelfUser Clone() => MemberwiseClone() as SocketSelfUser;

View File

@@ -51,6 +51,6 @@ namespace Discord.WebSocket
Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult<IDMChannel>(GlobalUser.DMChannel); => Task.FromResult<IDMChannel>(GlobalUser.DMChannel);
async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options)
=> await CreateDMChannelAsync(options); => await CreateDMChannelAsync(options).ConfigureAwait(false);
} }
} }