1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use serde::{Deserialize, Serialize};
use serde_json::Value;
use serde_repr::{Deserialize_repr, Serialize_repr};
use crate::entities::UserApiType;
/// <https://discord.com/developers/docs/resources/webhook#webhook-object>
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct WebhookApiType {
/// the id of the webhook
pub id: String,
/// the type of the webhook
#[serde(rename = "type")]
pub type_: WebhookType,
/// the guild id this webhook is for, if any
#[serde(skip_serializing_if = "Option::is_none")]
pub guild_id: Option<String>,
/// the channel id this webhook is for, if any
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
/// the user this webhook was created by (not returned when getting a webhook with its token)
#[serde(skip_serializing_if = "Option::is_none")]
pub user: Option<UserApiType>,
/// the default name of the webhook
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// the default user avatar hash of the webhook
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar: Option<String>,
/// the secure token of the webhook (returned for Incoming Webhooks)
#[serde(skip_serializing_if = "Option::is_none")]
pub token: Option<String>,
/// the bot/OAuth2 application that created this webhook
#[serde(skip_serializing_if = "Option::is_none")]
pub application_id: Option<String>,
/// partial guild object - the guild of the channel that this webhook is following (returned for Channel Follower Webhooks)
/// Note: Kept as Value because it's a true partial object with an unpredictable subset of fields
#[serde(skip_serializing_if = "Option::is_none")]
pub source_guild: Option<Value>,
/// partial channel object - the channel that this webhook is following (returned for Channel Follower Webhooks)
/// Note: Kept as Value because it's a true partial object with an unpredictable subset of fields
#[serde(skip_serializing_if = "Option::is_none")]
pub source_channel: Option<Value>,
/// the url used for executing the webhook (returned by the webhooks OAuth2 flow)
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
}
/// <https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types>
#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum WebhookType {
/// Incoming Webhooks can post messages to channels with a generated token
Incoming = 1,
/// Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels
ChannelFollower = 2,
/// Application webhooks are webhooks used with Interactions
Application = 3,
}