Skip to content

Commit

Permalink
feat: add with_components support for webhooks
Browse files Browse the repository at this point in the history
This is just needed if you send non-application-owned webhooks
  • Loading branch information
Lulalaby committed Jan 25, 2025
1 parent a51c2c0 commit befff00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions DisCatSharp/Entities/Webhook/DiscordWebhookBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ public string Content
/// </summary>
public List<IMention>? Mentions { get; private set; }

/// <summary>
/// Whether to send components with this webhook requests.
/// Set to <see langword="true"/> if you want to send components with non-application-owned webhooks.
/// </summary>
public bool? WithComponents { get; internal set; }

/// <summary>
/// Gets the components.
/// </summary>
Expand Down Expand Up @@ -148,6 +154,15 @@ public DiscordWebhookBuilder AsSilentMessage()
return this;
}

/// <summary>
/// Sets if you want to send components with non-application-owned webhooks.
/// </summary>
public DiscordWebhookBuilder SendWithComponents()
{
this.WithComponents = true;
return this;
}

/// <summary>
/// Sets the webhook to be send as voice message.
/// </summary>
Expand Down Expand Up @@ -510,6 +525,7 @@ public void Clear()
this.NotificationsSuppressed = false;
this.IsTts = false;
this.IsVoiceMessage = false;
this.WithComponents = null;
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions DisCatSharp/Net/Rest/DiscordApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5368,6 +5368,8 @@ internal async Task<DiscordMessage> ExecuteWebhookAsync(ulong webhookId, string
var qub = Utilities.GetApiUriBuilderFor(path, this.Discord?.Configuration).AddParameter("wait", "true");
if (threadId != null)
qub.AddParameter("thread_id", threadId);
if (builder.WithComponents != null)
qub.AddParameter("with_components", builder.WithComponents.Value.ToString().ToLower());

var url = qub.Build();

Expand Down

0 comments on commit befff00

Please sign in to comment.