Skip to content

Commit

Permalink
Update documentation around webhook components (#1844)
Browse files Browse the repository at this point in the history
Clarify the conditions for when webhooks are able to correctly use
message components.
  • Loading branch information
mkrasnitski authored and arqunis committed Apr 18, 2022
1 parent d7ef273 commit 6028072
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/builder/edit_webhook_message.rs
Expand Up @@ -53,10 +53,12 @@ impl EditWebhookMessage {
self
}

/// Sets the components of this message. Requires an application-owned webhook, meaning
/// the webhook's `kind` field is set to [`WebhookType::Application`].
/// Creates components for this message. Requires an application-owned webhook, meaning either
/// the webhook's `kind` field is set to [`WebhookType::Application`], or it was created by an
/// application (and has kind [`WebhookType::Incoming`]).
///
/// [`WebhookType::Application`]: crate::model::webhook::WebhookType
/// [`WebhookType::Incoming`]: crate::model::webhook::WebhookType
pub fn components<F>(&mut self, f: F) -> &mut Self
where
F: FnOnce(&mut CreateComponents) -> &mut CreateComponents,
Expand Down
11 changes: 8 additions & 3 deletions src/builder/execute_webhook.rs
Expand Up @@ -163,10 +163,12 @@ impl<'a> ExecuteWebhook<'a> {
self
}

/// Creates components for this message. Requires an application-owned webhook, meaning
/// the webhook's `kind` field is set to [`WebhookType::Application`].
/// Creates components for this message. Requires an application-owned webhook, meaning either
/// the webhook's `kind` field is set to [`WebhookType::Application`], or it was created by an
/// application (and has kind [`WebhookType::Incoming`]).
///
/// [`WebhookType::Application`]: crate::model::webhook::WebhookType
/// [`WebhookType::Incoming`]: crate::model::webhook::WebhookType
pub fn components<F>(&mut self, f: F) -> &mut Self
where
F: FnOnce(&mut CreateComponents) -> &mut CreateComponents,
Expand All @@ -178,7 +180,10 @@ impl<'a> ExecuteWebhook<'a> {
self
}

/// Sets the components of this message. Requires an application-owned webhook. See [`ExecuteWebhook::components`] for details.
/// Sets the components of this message. Requires an application-owned webhook. See
/// [`components`] for details.
///
/// [`components`]: crate::builder::ExecuteWebhook::components
pub fn set_components(&mut self, components: CreateComponents) -> &mut Self {
self.0.insert("components", Value::Array(components.0));
self
Expand Down

0 comments on commit 6028072

Please sign in to comment.