[Refactor] Remove some unnecessary async/await (#2739)
* Remove some unnecessary async/await * More not-so-async stuff * More not-so-async stuff * Fix merge issue
This commit is contained in:
@@ -56,7 +56,7 @@ namespace Discord.Webhook
|
||||
return model.Id;
|
||||
}
|
||||
|
||||
public static async Task ModifyMessageAsync(DiscordWebhookClient client, ulong messageId,
|
||||
public static Task ModifyMessageAsync(DiscordWebhookClient client, ulong messageId,
|
||||
Action<WebhookMessageProperties> func, RequestOptions options, ulong? threadId)
|
||||
{
|
||||
var args = new WebhookMessageProperties();
|
||||
@@ -104,8 +104,7 @@ namespace Discord.Webhook
|
||||
Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.Unspecified,
|
||||
};
|
||||
|
||||
await client.ApiClient.ModifyWebhookMessageAsync(client.Webhook.Id, messageId, apiArgs, options, threadId)
|
||||
.ConfigureAwait(false);
|
||||
return client.ApiClient.ModifyWebhookMessageAsync(client.Webhook.Id, messageId, apiArgs, options, threadId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -124,15 +123,12 @@ namespace Discord.Webhook
|
||||
MessageComponents = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.Unspecified,
|
||||
};
|
||||
|
||||
await client.ApiClient.ModifyWebhookMessageAsync(client.Webhook.Id, messageId, apiArgs, options, threadId)
|
||||
.ConfigureAwait(false);
|
||||
return client.ApiClient.ModifyWebhookMessageAsync(client.Webhook.Id, messageId, apiArgs, options, threadId);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task DeleteMessageAsync(DiscordWebhookClient client, ulong messageId, RequestOptions options, ulong? threadId)
|
||||
{
|
||||
await client.ApiClient.DeleteWebhookMessageAsync(client.Webhook.Id, messageId, options, threadId).ConfigureAwait(false);
|
||||
}
|
||||
public static Task DeleteMessageAsync(DiscordWebhookClient client, ulong messageId, RequestOptions options, ulong? threadId)
|
||||
=> client.ApiClient.DeleteWebhookMessageAsync(client.Webhook.Id, messageId, options, threadId);
|
||||
|
||||
public static async Task<ulong> SendFileAsync(DiscordWebhookClient client, string filePath, string text, bool isTTS,
|
||||
IEnumerable<Embed> embeds, string username, string avatarUrl, AllowedMentions allowedMentions, RequestOptions options,
|
||||
@@ -206,7 +202,7 @@ namespace Discord.Webhook
|
||||
return msg.Id;
|
||||
}
|
||||
|
||||
public static async Task<WebhookModel> ModifyAsync(DiscordWebhookClient client, Action<WebhookProperties> func, RequestOptions options)
|
||||
public static Task<WebhookModel> ModifyAsync(DiscordWebhookClient client, Action<WebhookProperties> func, RequestOptions options)
|
||||
{
|
||||
var args = new WebhookProperties();
|
||||
func(args);
|
||||
@@ -219,12 +215,10 @@ namespace Discord.Webhook
|
||||
if (!apiArgs.Avatar.IsSpecified && client.Webhook.AvatarId != null)
|
||||
apiArgs.Avatar = new ImageModel(client.Webhook.AvatarId);
|
||||
|
||||
return await client.ApiClient.ModifyWebhookAsync(client.Webhook.Id, apiArgs, options).ConfigureAwait(false);
|
||||
return client.ApiClient.ModifyWebhookAsync(client.Webhook.Id, apiArgs, options);
|
||||
}
|
||||
|
||||
public static async Task DeleteAsync(DiscordWebhookClient client, RequestOptions options)
|
||||
{
|
||||
await client.ApiClient.DeleteWebhookAsync(client.Webhook.Id, options).ConfigureAwait(false);
|
||||
}
|
||||
public static Task DeleteAsync(DiscordWebhookClient client, RequestOptions options)
|
||||
=> client.ApiClient.DeleteWebhookAsync(client.Webhook.Id, options);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user