Added missing ConfigureAwaits
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user