| @@ -201,7 +201,7 @@ namespace Discord.Commands | |||
| var commands = searchResult.Commands; | |||
| 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 (commands.Count == 1) | |||
| @@ -210,7 +210,7 @@ namespace Discord.Commands | |||
| 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.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."); | |||
| @@ -116,7 +116,7 @@ namespace Discord.API | |||
| _restClient.SetHeader("authorization", GetPrefixedToken(AuthTokenType, _authToken)); | |||
| if (FetchCurrentUser) | |||
| CurrentUser = await GetMyUserAsync(new RequestOptions { IgnoreState = true }); | |||
| CurrentUser = await GetMyUserAsync(new RequestOptions { IgnoreState = true }).ConfigureAwait(false); | |||
| LoginState = LoginState.LoggedIn; | |||
| } | |||
| @@ -130,7 +130,7 @@ namespace Discord.Net.Queue | |||
| if (millis <= 0 || !await _semaphore.WaitAsync(millis).ConfigureAwait(false)) | |||
| throw new TimeoutException(); | |||
| if (!await _semaphore.WaitAsync(0)) | |||
| if (!await _semaphore.WaitAsync(0).ConfigureAwait(false)) | |||
| { | |||
| await _queue.RaiseRateLimitTriggered(Id, this, null).ConfigureAwait(false); | |||
| @@ -54,7 +54,7 @@ namespace Discord.Net.WebSockets | |||
| await _sendLock.WaitAsync().ConfigureAwait(false); | |||
| try | |||
| { | |||
| await ConnectInternalAsync(host); | |||
| await ConnectInternalAsync(host).ConfigureAwait(false); | |||
| } | |||
| finally | |||
| { | |||
| @@ -86,7 +86,7 @@ namespace Discord.Net.WebSockets | |||
| await _sendLock.WaitAsync().ConfigureAwait(false); | |||
| try | |||
| { | |||
| await DisconnectInternalAsync(); | |||
| await DisconnectInternalAsync().ConfigureAwait(false); | |||
| } | |||
| finally | |||
| { | |||
| @@ -45,7 +45,7 @@ namespace Discord | |||
| if (_info.Remaining == 0) | |||
| return false; | |||
| var data = await _source._getPage(_info, cancelToken); | |||
| var data = await _source._getPage(_info, cancelToken).ConfigureAwait(false); | |||
| Current = new Page<T>(_info, data); | |||
| _info.Page++; | |||
| @@ -78,14 +78,14 @@ namespace Discord.Rest | |||
| async Task<IChannel> IDiscordClient.GetChannelAsync(ulong id, CacheMode mode) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetChannelAsync(id); | |||
| return await GetChannelAsync(id).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| async Task<IReadOnlyCollection<IPrivateChannel>> IDiscordClient.GetPrivateChannelsAsync(CacheMode mode) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetPrivateChannelsAsync(); | |||
| return await GetPrivateChannelsAsync().ConfigureAwait(false); | |||
| else | |||
| return ImmutableArray.Create<IPrivateChannel>(); | |||
| } | |||
| @@ -23,7 +23,7 @@ namespace Discord.Rest | |||
| { | |||
| var args = new ModifyGuildChannelParams(); | |||
| 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, | |||
| Action<ModifyTextChannelParams> func, | |||
| @@ -31,7 +31,7 @@ namespace Discord.Rest | |||
| { | |||
| var args = new ModifyTextChannelParams(); | |||
| 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, | |||
| Action<ModifyVoiceChannelParams> func, | |||
| @@ -39,14 +39,14 @@ namespace Discord.Rest | |||
| { | |||
| var args = new ModifyVoiceChannelParams(); | |||
| func(args); | |||
| return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options); | |||
| return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options).ConfigureAwait(false); | |||
| } | |||
| //Invites | |||
| public static async Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(IChannel channel, BaseDiscordClient client, | |||
| 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(); | |||
| } | |||
| public static async Task<RestInviteMetadata> CreateInviteAsync(IChannel channel, BaseDiscordClient client, | |||
| @@ -57,7 +57,7 @@ namespace Discord.Rest | |||
| args.MaxAge = maxAge.Value; | |||
| if (maxUses.HasValue) | |||
| 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); | |||
| } | |||
| @@ -83,7 +83,7 @@ namespace Discord.Rest | |||
| }; | |||
| if (info.Position != null) | |||
| 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(); ; | |||
| }, | |||
| nextPage: (info, lastPage) => | |||
| @@ -164,7 +164,7 @@ namespace Discord.Rest | |||
| public static async Task<RestGuildUser> GetUserAsync(IGuildChannel channel, IGuild guild, BaseDiscordClient client, | |||
| 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) | |||
| return null; | |||
| var user = RestGuildUser.Create(client, guild, model); | |||
| @@ -186,7 +186,7 @@ namespace Discord.Rest | |||
| }; | |||
| if (info.Position != null) | |||
| 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 | |||
| .Select(x => RestGuildUser.Create(client, guild, x)) | |||
| .Where(x => x.GetPermissions(channel).ReadMessages) | |||
| @@ -207,7 +207,7 @@ namespace Discord.Rest | |||
| public static async Task TriggerTypingAsync(IMessageChannel channel, BaseDiscordClient client, | |||
| 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, | |||
| RequestOptions options) | |||
| @@ -36,7 +36,7 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| public Task CloseAsync(RequestOptions options = null) | |||
| @@ -94,7 +94,7 @@ namespace Discord.Rest | |||
| async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetMessageAsync(id, options); | |||
| return await GetMessageAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| @@ -120,14 +120,14 @@ namespace Discord.Rest | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| } | |||
| 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) | |||
| => 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) | |||
| => 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) | |||
| => await SendMessageAsync(text, isTTS, options); | |||
| => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); | |||
| IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
| => EnterTypingState(options); | |||
| @@ -51,7 +51,7 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| public Task LeaveAsync(RequestOptions options = null) | |||
| @@ -104,7 +104,7 @@ namespace Discord.Rest | |||
| async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetMessageAsync(id, options); | |||
| return await GetMessageAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| @@ -130,14 +130,14 @@ namespace Discord.Rest | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| } | |||
| 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) | |||
| => 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) | |||
| => 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) | |||
| => await SendMessageAsync(text, isTTS, options); | |||
| => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); | |||
| IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
| => EnterTypingState(options); | |||
| @@ -51,12 +51,12 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| 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); | |||
| } | |||
| public Task DeleteAsync(RequestOptions options = null) | |||
| @@ -118,30 +118,30 @@ namespace Discord.Rest | |||
| } | |||
| 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) | |||
| => 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; | |||
| //IGuildChannel | |||
| 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) | |||
| => await CreateInviteAsync(maxAge, maxUses, isTemporary, options); | |||
| => await CreateInviteAsync(maxAge, maxUses, isTemporary, options).ConfigureAwait(false); | |||
| OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IRole role) | |||
| => GetPermissionOverwrite(role); | |||
| OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user) | |||
| => GetPermissionOverwrite(user); | |||
| 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) | |||
| => await AddPermissionOverwriteAsync(user, permissions, options); | |||
| => await AddPermissionOverwriteAsync(user, permissions, options).ConfigureAwait(false); | |||
| 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) | |||
| => await RemovePermissionOverwriteAsync(user, options); | |||
| => await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false); | |||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); //Overriden //Overriden in Text/Voice //TODO: Does this actually override? | |||
| @@ -35,7 +35,7 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| @@ -76,7 +76,7 @@ namespace Discord.Rest | |||
| async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetUserAsync(id, options); | |||
| return await GetUserAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| @@ -92,7 +92,7 @@ namespace Discord.Rest | |||
| async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetMessageAsync(id, options); | |||
| return await GetMessageAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| @@ -118,14 +118,14 @@ namespace Discord.Rest | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| } | |||
| 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) | |||
| => 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) | |||
| => 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) | |||
| => await SendMessageAsync(text, isTTS, options); | |||
| => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); | |||
| IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
| => EnterTypingState(options); | |||
| } | |||
| @@ -35,7 +35,7 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| @@ -62,7 +62,7 @@ namespace Discord.Rest | |||
| public static async Task<IReadOnlyCollection<RestBan>> GetBansAsync(IGuild guild, BaseDiscordClient client, | |||
| 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(); | |||
| } | |||
| @@ -70,12 +70,12 @@ namespace Discord.Rest | |||
| ulong userId, int pruneDays, RequestOptions options) | |||
| { | |||
| 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, | |||
| ulong userId, RequestOptions options) | |||
| { | |||
| await client.ApiClient.RemoveGuildBanAsync(guild.Id, userId, options); | |||
| await client.ApiClient.RemoveGuildBanAsync(guild.Id, userId, options).ConfigureAwait(false); | |||
| } | |||
| //Channels | |||
| @@ -100,18 +100,18 @@ namespace Discord.Rest | |||
| //General | |||
| 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) | |||
| => GuildHelper.DeleteAsync(this, Discord, options); | |||
| 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); | |||
| } | |||
| 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); | |||
| } | |||
| 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) | |||
| { | |||
| 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) | |||
| { | |||
| 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?), | |||
| 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); | |||
| return role; | |||
| } | |||
| @@ -205,58 +205,58 @@ namespace Discord.Rest | |||
| IReadOnlyCollection<IRole> IGuild.Roles => Roles; | |||
| 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) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetChannelsAsync(options); | |||
| return await GetChannelsAsync(options).ConfigureAwait(false); | |||
| else | |||
| return ImmutableArray.Create<IGuildChannel>(); | |||
| } | |||
| async Task<IGuildChannel> IGuild.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetChannelAsync(id, options); | |||
| return await GetChannelAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| 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) | |||
| => await CreateVoiceChannelAsync(name, options); | |||
| => await CreateVoiceChannelAsync(name, options).ConfigureAwait(false); | |||
| 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) | |||
| => await CreateIntegrationAsync(id, type, options); | |||
| => await CreateIntegrationAsync(id, type, options).ConfigureAwait(false); | |||
| async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | |||
| => await GetInvitesAsync(options); | |||
| => await GetInvitesAsync(options).ConfigureAwait(false); | |||
| IRole IGuild.GetRole(ulong id) | |||
| => GetRole(id); | |||
| 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) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetUserAsync(id, options); | |||
| return await GetUserAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| async Task<IGuildUser> IGuild.GetCurrentUserAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetCurrentUserAsync(options); | |||
| return await GetCurrentUserAsync(options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| async Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return (await GetUsersAsync(options).Flatten()).ToImmutableArray(); | |||
| return (await GetUsersAsync(options).Flatten().ConfigureAwait(false)).ToImmutableArray(); | |||
| else | |||
| return ImmutableArray.Create<IGuildUser>(); | |||
| } | |||
| @@ -35,7 +35,7 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| public Task DeleteAsync(RequestOptions options = null) | |||
| @@ -15,23 +15,23 @@ namespace Discord.Rest | |||
| { | |||
| var args = new ModifyMessageParams(); | |||
| 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, | |||
| 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, | |||
| 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, | |||
| 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) | |||
| @@ -113,7 +113,7 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| public Task DeleteAsync(RequestOptions options) | |||
| @@ -44,7 +44,7 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| public Task DeleteAsync(RequestOptions options = null) | |||
| @@ -18,7 +18,7 @@ namespace Discord.Rest | |||
| { | |||
| var args = new ModifyGuildRoleParams(); | |||
| 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); | |||
| } | |||
| } | |||
| } | |||
| @@ -64,12 +64,12 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| 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) | |||
| IsDeafened = args.Deaf.Value; | |||
| if (args.Mute.IsSpecified) | |||
| @@ -37,7 +37,7 @@ namespace Discord.Rest | |||
| 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) | |||
| throw new InvalidOperationException("Unable to update this object using a different token."); | |||
| Update(model); | |||
| @@ -47,7 +47,7 @@ namespace Discord.Rest | |||
| { | |||
| if (Id != Discord.CurrentUser.Id) | |||
| 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); | |||
| } | |||
| @@ -42,7 +42,7 @@ namespace Discord.Rest | |||
| 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); | |||
| } | |||
| @@ -56,6 +56,6 @@ namespace Discord.Rest | |||
| Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IDMChannel>(null); | |||
| async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) | |||
| => await CreateDMChannelAsync(options); | |||
| => await CreateDMChannelAsync(options).ConfigureAwait(false); | |||
| } | |||
| } | |||
| @@ -12,28 +12,28 @@ namespace Discord.Rest | |||
| { | |||
| var args = new ModifyCurrentUserParams(); | |||
| 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, | |||
| RequestOptions options) | |||
| { | |||
| var args = new ModifyGuildMemberParams(); | |||
| 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; | |||
| } | |||
| public static async Task KickAsync(IGuildUser user, BaseDiscordClient client, | |||
| 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, | |||
| RequestOptions options) | |||
| { | |||
| 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)); | |||
| } | |||
| } | |||
| } | |||
| @@ -29,10 +29,10 @@ namespace Discord.Rest | |||
| { | |||
| try | |||
| { | |||
| await _channel.TriggerTypingAsync(_options); | |||
| await _channel.TriggerTypingAsync(_options).ConfigureAwait(false); | |||
| } | |||
| catch { } | |||
| await Task.Delay(9750, token); | |||
| await Task.Delay(9750, token).ConfigureAwait(false); | |||
| } | |||
| } | |||
| catch (OperationCanceledException) { } | |||
| @@ -103,7 +103,7 @@ namespace Discord.Rpc | |||
| //Abort connection on timeout | |||
| var _ = Task.Run(async () => | |||
| { | |||
| await Task.Delay(ConnectionTimeout); | |||
| await Task.Delay(ConnectionTimeout).ConfigureAwait(false); | |||
| connectTask.TrySetException(new TimeoutException()); | |||
| }); | |||
| @@ -231,27 +231,27 @@ namespace Discord.Rpc | |||
| 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) | |||
| { | |||
| 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) | |||
| { | |||
| 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) | |||
| { | |||
| 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) | |||
| { | |||
| 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) | |||
| { | |||
| await ApiClient.SendChannelUnsubscribeAsync(GetEventName(evnt), channelId); | |||
| await ApiClient.SendChannelUnsubscribeAsync(GetEventName(evnt), channelId).ConfigureAwait(false); | |||
| } | |||
| public async Task<RpcGuild> GetRpcGuildAsync(ulong id, RequestOptions options = null) | |||
| @@ -72,14 +72,14 @@ namespace Discord.Rpc | |||
| async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetMessageAsync(id, options); | |||
| return await GetMessageAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(limit, options); | |||
| return GetMessagesAsync(limit, options).ConfigureAwait(false); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| } | |||
| @@ -98,14 +98,14 @@ namespace Discord.Rpc | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| } | |||
| 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) | |||
| => 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) | |||
| => 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) | |||
| => await SendMessageAsync(text, isTTS, options); | |||
| => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); | |||
| IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
| => EnterTypingState(options); | |||
| @@ -71,14 +71,14 @@ namespace Discord.Rpc | |||
| async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetMessageAsync(id, options); | |||
| return await GetMessageAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return GetMessagesAsync(limit, options); | |||
| return GetMessagesAsync(limit, options).ConfigureAwait(false); | |||
| else | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| } | |||
| @@ -97,14 +97,14 @@ namespace Discord.Rpc | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| } | |||
| 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) | |||
| => 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) | |||
| => 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) | |||
| => await SendMessageAsync(text, isTTS, options); | |||
| => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); | |||
| IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
| => EnterTypingState(options); | |||
| @@ -51,17 +51,17 @@ namespace Discord.Rpc | |||
| => ChannelHelper.RemovePermissionOverwriteAsync(this, Discord, role, options); | |||
| 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) | |||
| => 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; | |||
| //IGuildChannel | |||
| 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) | |||
| => await CreateInviteAsync(maxAge, maxUses, isTemporary, options); | |||
| => await CreateInviteAsync(maxAge, maxUses, isTemporary, options).ConfigureAwait(false); | |||
| IReadOnlyCollection<Overwrite> IGuildChannel.PermissionOverwrites { get { throw new NotSupportedException(); } } | |||
| OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user) | |||
| @@ -73,7 +73,7 @@ namespace Discord.Rpc | |||
| async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetMessageAsync(id, options); | |||
| return await GetMessageAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return null; | |||
| } | |||
| @@ -99,14 +99,14 @@ namespace Discord.Rpc | |||
| return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>(); | |||
| } | |||
| 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) | |||
| => 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) | |||
| => 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) | |||
| => await SendMessageAsync(text, isTTS, options); | |||
| => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); | |||
| IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
| => EnterTypingState(options); | |||
| } | |||
| @@ -51,6 +51,6 @@ namespace Discord.Rpc | |||
| Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IDMChannel>(null); | |||
| async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) | |||
| => await CreateDMChannelAsync(options); | |||
| => await CreateDMChannelAsync(options).ConfigureAwait(false); | |||
| } | |||
| } | |||
| @@ -107,7 +107,7 @@ namespace Discord.Audio | |||
| if (payload != null) | |||
| bytes = Encoding.UTF8.GetBytes(SerializeJson(payload)); | |||
| 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) | |||
| { | |||
| @@ -132,7 +132,7 @@ namespace Discord.Audio | |||
| UserId = userId, | |||
| SessionId = sessionId, | |||
| Token = token | |||
| }); | |||
| }).ConfigureAwait(false); | |||
| } | |||
| public async Task SendSelectProtocol(string externalIp, int externalPort) | |||
| { | |||
| @@ -145,7 +145,7 @@ namespace Discord.Audio | |||
| Port = externalPort, | |||
| Mode = Mode | |||
| } | |||
| }); | |||
| }).ConfigureAwait(false); | |||
| } | |||
| public async Task SendSetSpeaking(bool value) | |||
| { | |||
| @@ -153,7 +153,7 @@ namespace Discord.Audio | |||
| { | |||
| IsSpeaking = value, | |||
| Delay = 0 | |||
| }); | |||
| }).ConfigureAwait(false); | |||
| } | |||
| public async Task ConnectAsync(string url) | |||
| @@ -269,7 +269,7 @@ namespace Discord.Audio | |||
| catch { return; } | |||
| await _audioLogger.DebugAsync("Received Discovery").ConfigureAwait(false); | |||
| await ApiClient.SendSelectProtocol(ip, port); | |||
| await ApiClient.SendSelectProtocol(ip, port).ConfigureAwait(false); | |||
| } | |||
| } | |||
| } | |||
| @@ -163,7 +163,7 @@ namespace Discord.WebSocket | |||
| //Abort connection on timeout | |||
| var _ = Task.Run(async () => | |||
| { | |||
| await Task.Delay(ConnectionTimeout); | |||
| await Task.Delay(ConnectionTimeout).ConfigureAwait(false); | |||
| connectTask.TrySetException(new TimeoutException()); | |||
| }); | |||
| @@ -410,7 +410,7 @@ namespace Discord.WebSocket | |||
| //Wait for unsynced guilds to sync first. | |||
| var unsyncedGuilds = guilds.Select(x => x.SyncPromise).Where(x => !x.IsCompleted).ToImmutableArray(); | |||
| if (unsyncedGuilds.Length > 0) | |||
| await Task.WhenAll(unsyncedGuilds); | |||
| await Task.WhenAll(unsyncedGuilds).ConfigureAwait(false); | |||
| //Download offline members | |||
| const short batchSize = 50; | |||
| @@ -1468,10 +1468,10 @@ namespace Discord.WebSocket | |||
| //Ignored (User only) | |||
| case "CHANNEL_PINS_ACK": | |||
| await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_ACK)"); | |||
| await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_ACK)").ConfigureAwait(false); | |||
| break; | |||
| case "CHANNEL_PINS_UPDATE": | |||
| await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_UPDATE)"); | |||
| await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_UPDATE)").ConfigureAwait(false); | |||
| break; | |||
| case "GUILD_INTEGRATIONS_UPDATE": | |||
| await _gatewayLogger.DebugAsync("Ignored Dispatch (GUILD_INTEGRATIONS_UPDATE)").ConfigureAwait(false); | |||
| @@ -1621,17 +1621,17 @@ namespace Discord.WebSocket | |||
| => Task.FromResult<IReadOnlyCollection<IPrivateChannel>>(PrivateChannels); | |||
| async Task<IReadOnlyCollection<IConnection>> IDiscordClient.GetConnectionsAsync() | |||
| => await GetConnectionsAsync(); | |||
| => await GetConnectionsAsync().ConfigureAwait(false); | |||
| async Task<IInvite> IDiscordClient.GetInviteAsync(string inviteId) | |||
| => await GetInviteAsync(inviteId); | |||
| => await GetInviteAsync(inviteId).ConfigureAwait(false); | |||
| Task<IGuild> IDiscordClient.GetGuildAsync(ulong id, CacheMode mode) | |||
| => Task.FromResult<IGuild>(GetGuild(id)); | |||
| Task<IReadOnlyCollection<IGuild>> IDiscordClient.GetGuildsAsync(CacheMode mode) | |||
| => Task.FromResult<IReadOnlyCollection<IGuild>>(Guilds); | |||
| 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.FromResult<IUser>(GetUser(id)); | |||
| @@ -48,7 +48,7 @@ namespace Discord.WebSocket | |||
| { | |||
| IMessage msg = _messages?.Get(id); | |||
| 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; | |||
| } | |||
| 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) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetMessageAsync(id, options); | |||
| return await GetMessageAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return GetCachedMessage(id); | |||
| } | |||
| @@ -131,11 +131,11 @@ namespace Discord.WebSocket | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| 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) | |||
| => 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) | |||
| => await SendMessageAsync(text, isTTS, options); | |||
| => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); | |||
| IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
| => EnterTypingState(options); | |||
| @@ -71,7 +71,7 @@ namespace Discord.WebSocket | |||
| { | |||
| IMessage msg = _messages?.Get(id); | |||
| 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; | |||
| } | |||
| 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) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetMessageAsync(id, options); | |||
| return await GetMessageAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return GetCachedMessage(id); | |||
| } | |||
| @@ -194,11 +194,11 @@ namespace Discord.WebSocket | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| 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) | |||
| => 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) | |||
| => await SendMessageAsync(text, isTTS, options); | |||
| => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); | |||
| IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
| => EnterTypingState(options); | |||
| @@ -112,9 +112,9 @@ namespace Discord.WebSocket | |||
| } | |||
| 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) | |||
| => 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); | |||
| @@ -129,22 +129,22 @@ namespace Discord.WebSocket | |||
| ulong IGuildChannel.GuildId => Guild.Id; | |||
| 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) | |||
| => await CreateInviteAsync(maxAge, maxUses, isTemporary, options); | |||
| => await CreateInviteAsync(maxAge, maxUses, isTemporary, options).ConfigureAwait(false); | |||
| OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IRole role) | |||
| => GetPermissionOverwrite(role); | |||
| OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user) | |||
| => GetPermissionOverwrite(user); | |||
| 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) | |||
| => await AddPermissionOverwriteAsync(user, permissions, options); | |||
| => await AddPermissionOverwriteAsync(user, permissions, options).ConfigureAwait(false); | |||
| 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) | |||
| => await RemovePermissionOverwriteAsync(user, options); | |||
| => await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false); | |||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | |||
| => ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable(); | |||
| @@ -54,7 +54,7 @@ namespace Discord.WebSocket | |||
| { | |||
| IMessage msg = _messages?.Get(id); | |||
| 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; | |||
| } | |||
| 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) | |||
| { | |||
| if (mode == CacheMode.AllowDownload) | |||
| return await GetMessageAsync(id, options); | |||
| return await GetMessageAsync(id, options).ConfigureAwait(false); | |||
| else | |||
| return GetCachedMessage(id); | |||
| } | |||
| @@ -132,11 +132,11 @@ namespace Discord.WebSocket | |||
| async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) | |||
| => await GetPinnedMessagesAsync(options).ConfigureAwait(false); | |||
| 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) | |||
| => 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) | |||
| => await SendMessageAsync(text, isTTS, options); | |||
| => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); | |||
| IDisposable IMessageChannel.EnterTypingState(RequestOptions options) | |||
| => EnterTypingState(options); | |||
| } | |||
| @@ -387,7 +387,7 @@ namespace Discord.WebSocket | |||
| public async Task DownloadUsersAsync() | |||
| { | |||
| await Discord.DownloadUsersAsync(new[] { this }); | |||
| await Discord.DownloadUsersAsync(new[] { this }).ConfigureAwait(false); | |||
| } | |||
| internal void CompleteDownloadUsers() | |||
| { | |||
| @@ -495,12 +495,12 @@ namespace Discord.WebSocket | |||
| } | |||
| catch (OperationCanceledException) | |||
| { | |||
| await DisconnectAudioAsync(); | |||
| await DisconnectAudioAsync().ConfigureAwait(false); | |||
| } | |||
| catch (Exception e) | |||
| { | |||
| await _audioConnectPromise.SetExceptionAsync(e).ConfigureAwait(false); | |||
| await DisconnectAudioAsync(); | |||
| await DisconnectAudioAsync().ConfigureAwait(false); | |||
| } | |||
| finally | |||
| { | |||
| @@ -532,29 +532,29 @@ namespace Discord.WebSocket | |||
| IReadOnlyCollection<IRole> IGuild.Roles => Roles; | |||
| 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.FromResult<IReadOnlyCollection<IGuildChannel>>(Channels); | |||
| Task<IGuildChannel> IGuild.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IGuildChannel>(GetChannel(id)); | |||
| 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) | |||
| => await CreateVoiceChannelAsync(name, options); | |||
| => await CreateVoiceChannelAsync(name, options).ConfigureAwait(false); | |||
| 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) | |||
| => await CreateIntegrationAsync(id, type, options); | |||
| => await CreateIntegrationAsync(id, type, options).ConfigureAwait(false); | |||
| async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | |||
| => await GetInvitesAsync(options); | |||
| => await GetInvitesAsync(options).ConfigureAwait(false); | |||
| IRole IGuild.GetRole(ulong id) | |||
| => GetRole(id); | |||
| 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.FromResult<IReadOnlyCollection<IGuildUser>>(Users); | |||
| @@ -80,7 +80,7 @@ namespace Discord.WebSocket | |||
| Presence = new SocketPresence(status, game); | |||
| await SendStatus(status, game); | |||
| await SendStatus(status, game).ConfigureAwait(false); | |||
| } | |||
| internal async Task SendStatus(UserStatus status, GameEntity? game) | |||
| { | |||
| @@ -95,7 +95,7 @@ namespace Discord.WebSocket | |||
| status, | |||
| status == UserStatus.AFK, | |||
| _statusSince != null ? _statusSince.Value.ToUnixTimeMilliseconds() : (long?)null, | |||
| gameModel); | |||
| gameModel).ConfigureAwait(false); | |||
| } | |||
| internal new SocketSelfUser Clone() => MemberwiseClone() as SocketSelfUser; | |||
| @@ -51,6 +51,6 @@ namespace Discord.WebSocket | |||
| Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) | |||
| => Task.FromResult<IDMChannel>(GlobalUser.DMChannel); | |||
| async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) | |||
| => await CreateDMChannelAsync(options); | |||
| => await CreateDMChannelAsync(options).ConfigureAwait(false); | |||
| } | |||
| } | |||