Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add embed parameter for webhooks in SendMessageAsync #2893

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/WebhookClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

// Webhooks are able to send multiple embeds per message
// As such, your embeds must be passed as a collection.
await client.SendMessageAsync(text: "Send a message to this webhook!", embeds: new[] { embed.Build() });
await client.SendMessageAsync(text: "Send a message to this webhook!", embed: embed.Build() );

Check failure on line 27 in samples/WebhookClient/Program.cs

View workflow job for this annotation

GitHub Actions / Build and Test

The best overload for 'SendMessageAsync' does not have a parameter named 'embed'

Check failure on line 27 in samples/WebhookClient/Program.cs

View workflow job for this annotation

GitHub Actions / Build and Test

The best overload for 'SendMessageAsync' does not have a parameter named 'embed'
}
}
4 changes: 2 additions & 2 deletions src/Discord.Net.Webhook/DiscordWebhookClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ private static API.DiscordRestApiClient CreateApiClient(DiscordRestConfig config
public Task<ulong> SendMessageAsync(string text = null, bool isTTS = false, IEnumerable<Embed> embeds = null,
string username = null, string avatarUrl = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageComponent components = null, MessageFlags flags = MessageFlags.None, ulong? threadId = null, string threadName = null,
ulong[] appliedTags = null)
=> WebhookClientHelper.SendMessageAsync(this, text, isTTS, embeds, username, avatarUrl, allowedMentions, options, components, flags, threadId, threadName, appliedTags);
ulong[] appliedTags = null, Embed embed = null)
=> WebhookClientHelper.SendMessageAsync(this, text, isTTS, embeds, username, avatarUrl, allowedMentions, options, components, flags, threadId, threadName, appliedTags, embed);

/// <summary>
/// Modifies a message posted using this webhook.
Expand Down
7 changes: 6 additions & 1 deletion src/Discord.Net.Webhook/WebhookClientHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ public static async Task<RestInternalWebhook> GetWebhookAsync(DiscordWebhookClie
public static async Task<ulong> SendMessageAsync(DiscordWebhookClient client,
string text, bool isTTS, IEnumerable<Embed> embeds, string username, string avatarUrl,
AllowedMentions allowedMentions, RequestOptions options, MessageComponent components,
MessageFlags flags, ulong? threadId = null, string threadName = null, ulong[] appliedTags = null)
MessageFlags flags, ulong? threadId = null, string threadName = null, ulong[] appliedTags = null,
Embed embed = null)
{
embeds ??= Array.Empty<Embed>();
if (embed != null)
embeds = new[] { embed }.Concat(embeds).ToArray();

var args = new CreateWebhookMessageParams
{
Content = text,
Expand Down
Loading