You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Webhook.cs 4.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System.Text.Json.Serialization;
  2. namespace Discord.Net.Models
  3. {
  4. /// <summary>
  5. /// Represents a webhook object.
  6. /// </summary>
  7. public record Webhook
  8. {
  9. /// <summary>
  10. /// Creates a <see cref="Webhook"/> with the provided parameters.
  11. /// </summary>
  12. /// <param name="id">The id of the webhook.</param>
  13. /// <param name="type">The type of the webhook.</param>
  14. /// <param name="guildId">The guild id this webhook is for, if any.</param>
  15. /// <param name="channelId">The channel id this webhook is for, if any.</param>
  16. /// <param name="user">The user this webhook was created by (not returned when getting a webhook with its token).</param>
  17. /// <param name="name">The default name of the webhook.</param>
  18. /// <param name="avatar">The default user avatar hash of the webhook.</param>
  19. /// <param name="token">The secure token of the webhook (returned for Incoming Webhooks).</param>
  20. /// <param name="applicationId">The bot/OAuth2 application that created this webhook.</param>
  21. /// <param name="sourceGuild">The guild of the channel that this webhook is following (returned for Channel Follower Webhooks).</param>
  22. /// <param name="sourceChannel">The channel that this webhook is following (returned for Channel Follower Webhooks).</param>
  23. /// <param name="url">The url used for executing the webhook (returned by the webhooks OAuth2 flow).</param>
  24. [JsonConstructor]
  25. public Webhook(Snowflake id, WebhookType type, Optional<Snowflake?> guildId, Snowflake? channelId, Optional<User> user, string? name, string? avatar, Optional<string> token, Snowflake? applicationId, Optional<Guild> sourceGuild, Optional<Channel> sourceChannel, Optional<string> url)
  26. {
  27. Id = id;
  28. Type = type;
  29. GuildId = guildId;
  30. ChannelId = channelId;
  31. User = user;
  32. Name = name;
  33. Avatar = avatar;
  34. Token = token;
  35. ApplicationId = applicationId;
  36. SourceGuild = sourceGuild;
  37. SourceChannel = sourceChannel;
  38. Url = url;
  39. }
  40. /// <summary>
  41. /// The id of the webhook.
  42. /// </summary>
  43. [JsonPropertyName("id")]
  44. public Snowflake Id { get; }
  45. /// <summary>
  46. /// The type of the webhook.
  47. /// </summary>
  48. [JsonPropertyName("type")]
  49. public WebhookType Type { get; }
  50. /// <summary>
  51. /// The guild id this webhook is for, if any.
  52. /// </summary>
  53. [JsonPropertyName("guild_id")]
  54. public Optional<Snowflake?> GuildId { get; }
  55. /// <summary>
  56. /// The channel id this webhook is for, if any.
  57. /// </summary>
  58. [JsonPropertyName("channel_id")]
  59. public Snowflake? ChannelId { get; }
  60. /// <summary>
  61. /// The user this webhook was created by (not returned when getting a webhook with its token).
  62. /// </summary>
  63. [JsonPropertyName("user")]
  64. public Optional<User> User { get; }
  65. /// <summary>
  66. /// The default name of the webhook.
  67. /// </summary>
  68. [JsonPropertyName("name")]
  69. public string? Name { get; }
  70. /// <summary>
  71. /// The default user avatar hash of the webhook.
  72. /// </summary>
  73. [JsonPropertyName("avatar")]
  74. public string? Avatar { get; }
  75. /// <summary>
  76. /// The secure token of the webhook (returned for Incoming Webhooks).
  77. /// </summary>
  78. [JsonPropertyName("token")]
  79. public Optional<string> Token { get; }
  80. /// <summary>
  81. /// The bot/OAuth2 application that created this webhook.
  82. /// </summary>
  83. [JsonPropertyName("application_id")]
  84. public Snowflake? ApplicationId { get; }
  85. /// <summary>
  86. /// The guild of the channel that this webhook is following (returned for Channel Follower Webhooks).
  87. /// </summary>
  88. [JsonPropertyName("source_guild")]
  89. public Optional<Guild> SourceGuild { get; }
  90. /// <summary>
  91. /// The channel that this webhook is following (returned for Channel Follower Webhooks).
  92. /// </summary>
  93. [JsonPropertyName("source_channel")]
  94. public Optional<Channel> SourceChannel { get; }
  95. /// <summary>
  96. /// The url used for executing the webhook (returned by the webhooks OAuth2 flow).
  97. /// </summary>
  98. [JsonPropertyName("url")]
  99. public Optional<string> Url { get; }
  100. }
  101. }

No Description