Expand description
Webhook events: events Discord sends over HTTP to an app’s webhook events URL (D-076).
Each request body is a WebhookEventPayload: either a PING (sent when the URL is
configured) or an event whose data depends on its type.
Unlike gateway events, webhook events are not realtime and may arrive out
of order. Every request must be verified with its X-Signature-Ed25519 and
X-Signature-Timestamp headers (answer 401 when the signature is invalid) and acknowledged
with 204 No Content within 3 seconds, otherwise Discord retries it.
The events are chosen in the app’s settings or with the application’s
event_webhooks_types.
§Examples
use djs_model::webhook_event::{PayloadType, WebhookEventData, WebhookEventPayload};
let body = r#"{
"version": 1, "application_id": "1234560123453231555", "type": 1,
"event": {
"type": "APPLICATION_DEAUTHORIZED", "timestamp": "2024-10-18T14:42:53.064834",
"data": { "user": { "id": "111178765189277770", "username": "nelly",
"discriminator": "0", "global_name": null, "avatar": null } }
}
}"#;
let payload: WebhookEventPayload = serde_json::from_str(body)?;
assert_eq!(payload.kind, PayloadType::Event);
let event = payload.event.expect("events carry a body");
let WebhookEventData::ApplicationDeauthorized(data) = &event.data else {
panic!("expected APPLICATION_DEAUTHORIZED");
};
assert_eq!(data.user.username, "nelly");Structs§
- Application
Authorized - The data of an Application Authorized webhook event.
- Application
Deauthorized - The data of an Application Deauthorized webhook event.
- Game
Direct Message - A direct message in a
GAME_DIRECT_MESSAGE_*webhook event (D-079). - Lobby
Message Delete - The data of a Lobby Message Delete webhook event.
- Webhook
Event - The event body of a webhook event: when it happened and its data.
- Webhook
Event Payload - The outer payload of a webhook event request.
Enums§
- Payload
Type - The type of a webhook event payload.
- Webhook
Event Data - The data of a
WebhookEvent, by event type. - Webhook
Event Type - A webhook event type an app can subscribe to.