diff --git a/src/Discord.Net.Core/Entities/Webhooks/IWebhook.cs b/src/Discord.Net.Core/Entities/Webhooks/IWebhook.cs
index e0aebae3..ba767df7 100644
--- a/src/Discord.Net.Core/Entities/Webhooks/IWebhook.cs
+++ b/src/Discord.Net.Core/Entities/Webhooks/IWebhook.cs
@@ -9,7 +9,7 @@ namespace Discord
public interface IWebhook : IDeletable, ISnowflakeEntity
{
///
- /// Gets the token of this webhook.
+ /// Gets the token of this webhook; if the is .
///
string Token { get; }
@@ -17,10 +17,12 @@ namespace Discord
/// Gets the default name of this webhook.
///
string Name { get; }
+
///
/// Gets the ID of this webhook's default avatar.
///
string AvatarId { get; }
+
///
/// Gets the URL to this webhook's default avatar.
///
@@ -30,10 +32,11 @@ namespace Discord
/// Gets the channel for this webhook.
///
IIntegrationChannel Channel { get; }
+
///
- /// Gets the ID of the channel for this webhook.
+ /// Gets the ID of the channel for this webhook; for webhooks.
///
- ulong ChannelId { get; }
+ ulong? ChannelId { get; }
///
/// Gets the guild owning this webhook.
@@ -54,6 +57,11 @@ namespace Discord
///
ulong? ApplicationId { get; }
+ ///
+ /// Gets the type of this webhook.
+ ///
+ WebhookType Type { get; }
+
///
/// Modifies this webhook.
///
diff --git a/src/Discord.Net.Core/Entities/Webhooks/WebhookType.cs b/src/Discord.Net.Core/Entities/Webhooks/WebhookType.cs
index 0ddfa393..af7a6a48 100644
--- a/src/Discord.Net.Core/Entities/Webhooks/WebhookType.cs
+++ b/src/Discord.Net.Core/Entities/Webhooks/WebhookType.cs
@@ -1,14 +1,25 @@
-namespace Discord
+namespace Discord;
+
+///
+/// Represents the type of a webhook.
+///
+///
+/// This type is currently unused, and is only returned in audit log responses.
+///
+public enum WebhookType
{
///
- /// Represents the type of a webhook.
+ /// An incoming webhook.
///
- ///
- /// This type is currently unused, and is only returned in audit log responses.
- ///
- public enum WebhookType
- {
- /// An incoming webhook
- Incoming = 1
- }
+ Incoming = 1,
+
+ ///
+ /// A channel follower webhook.
+ ///
+ ChannelFollower = 2,
+
+ ///
+ /// An application (interaction) webhook.
+ ///
+ Application = 3,
}
diff --git a/src/Discord.Net.Rest/API/Common/Webhook.cs b/src/Discord.Net.Rest/API/Common/Webhook.cs
index 23b682bd..f7c2ecda 100644
--- a/src/Discord.Net.Rest/API/Common/Webhook.cs
+++ b/src/Discord.Net.Rest/API/Common/Webhook.cs
@@ -1,26 +1,39 @@
using Newtonsoft.Json;
-namespace Discord.API
+namespace Discord.API;
+
+internal class Webhook
{
- internal class Webhook
- {
- [JsonProperty("id")]
- public ulong Id { get; set; }
- [JsonProperty("channel_id")]
- public ulong ChannelId { get; set; }
- [JsonProperty("token")]
- public string Token { get; set; }
+ [JsonProperty("id")]
+ public ulong Id { get; set; }
- [JsonProperty("name")]
- public Optional Name { get; set; }
- [JsonProperty("avatar")]
- public Optional Avatar { get; set; }
- [JsonProperty("guild_id")]
- public Optional GuildId { get; set; }
+ [JsonProperty("type")]
+ public WebhookType Type { get; set; }
- [JsonProperty("user")]
- public Optional Creator { get; set; }
- [JsonProperty("application_id")]
- public ulong? ApplicationId { get; set; }
- }
+ [JsonProperty("guild_id")]
+ public Optional GuildId { get; set; }
+
+ [JsonProperty("channel_id")]
+ public ulong? ChannelId { get; set; }
+
+ [JsonProperty("user")]
+ public Optional Creator { get; set; }
+
+ [JsonProperty("name")]
+ public Optional Name { get; set; }
+
+ [JsonProperty("avatar")]
+ public Optional Avatar { get; set; }
+
+ [JsonProperty("token")]
+ public Optional Token { get; set; }
+
+ [JsonProperty("application_id")]
+ public ulong? ApplicationId { get; set; }
+
+ [JsonProperty("source_guild")]
+ public Optional Guild { get; set; }
+
+ [JsonProperty("source_channel")]
+ public Optional Channel { get; set; }
}
diff --git a/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs b/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs
index 2f8cc96f..22b9b606 100644
--- a/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs
+++ b/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs
@@ -9,6 +9,7 @@ namespace Discord.Rest
public class RestWebhook : RestEntity, IWebhook, IUpdateable
{
#region RestWebhook
+
internal IGuild Guild { get; private set; }
internal IIntegrationChannel Channel { get; private set; }
@@ -16,43 +17,81 @@ namespace Discord.Rest
public string Token { get; }
///
- public ulong ChannelId { get; private set; }
+ public ulong? ChannelId { get; private set; }
+
///
public string Name { get; private set; }
+
///
public string AvatarId { get; private set; }
+
///
public ulong? GuildId { get; private set; }
+
///
public IUser Creator { get; private set; }
+
///
public ulong? ApplicationId { get; private set; }
+ ///
+ public WebhookType Type { get; private set; }
+
+ ///
+ /// Gets the partial guild of the followed channel. if is not .
+ ///
+ public PartialGuild PartialGuild { get; private set; }
+
+ ///
+ /// Gets the id of the followed channel. if is not .
+ ///
+ public ulong? FollowedChannelId { get; private set; }
+
+ ///
+ /// Gets the name of the followed channel. if is not .
+ ///
+ public string FollowedChannelName { get; private set; }
+
///
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
- internal RestWebhook(BaseDiscordClient discord, IGuild guild, ulong id, string token, ulong channelId)
+ internal RestWebhook(BaseDiscordClient discord, IGuild guild, ulong id, string token, ulong? channelId, WebhookType type, PartialGuild partialGuild,
+ ulong? followedChannelId, string followedChannelName)
: base(discord, id)
{
Guild = guild;
Token = token;
ChannelId = channelId;
+ Type = type;
+ PartialGuild = partialGuild;
+ FollowedChannelId = followedChannelId;
+ FollowedChannelName = followedChannelName;
}
- internal RestWebhook(BaseDiscordClient discord, IIntegrationChannel channel, ulong id, string token, ulong channelId)
- : this(discord, channel.Guild, id, token, channelId)
+
+ internal RestWebhook(BaseDiscordClient discord, IIntegrationChannel channel, ulong id, string token, ulong? channelId, WebhookType type, PartialGuild partialGuild,
+ ulong? followedChannelId, string followedChannelName)
+ : this(discord, channel.Guild, id, token, channelId, type, partialGuild, followedChannelId, followedChannelName)
{
Channel = channel;
}
internal static RestWebhook Create(BaseDiscordClient discord, IGuild guild, Model model)
{
- var entity = new RestWebhook(discord, guild, model.Id, model.Token, model.ChannelId);
+ var entity = new RestWebhook(discord, guild, model.Id, model.Token.GetValueOrDefault(null), model.ChannelId, model.Type,
+ model.Guild.IsSpecified ? PartialGuildExtensions.Create(model.Guild.Value) : null,
+ model.Channel.IsSpecified ? model.Channel.Value.Id : null,
+ model.Channel.IsSpecified ? model.Channel.Value.Name.GetValueOrDefault(null) : null
+ );
entity.Update(model);
return entity;
}
+
internal static RestWebhook Create(BaseDiscordClient discord, IIntegrationChannel channel, Model model)
{
- var entity = new RestWebhook(discord, channel, model.Id, model.Token, model.ChannelId);
+ var entity = new RestWebhook(discord, channel, model.Id, model.Token.GetValueOrDefault(null), model.ChannelId, model.Type,
+ model.Guild.IsSpecified ? PartialGuildExtensions.Create(model.Guild.Value) : null,
+ model.Channel.IsSpecified ? model.Channel.Value.Id : null,
+ model.Channel.IsSpecified ? model.Channel.Value.Name.GetValueOrDefault(null) : null);
entity.Update(model);
return entity;
}
diff --git a/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs b/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs
index cfde6c0d..33b84468 100644
--- a/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs
+++ b/src/Discord.Net.Webhook/Entities/Webhooks/RestInternalWebhook.cs
@@ -13,11 +13,12 @@ namespace Discord.Webhook
public ulong Id { get; }
public string Token { get; }
- public ulong ChannelId { get; private set; }
+ public ulong? ChannelId { get; private set; }
public string Name { get; private set; }
public string AvatarId { get; private set; }
public ulong? GuildId { get; private set; }
public ulong? ApplicationId { get; private set; }
+ public WebhookType Type { get; private set; }
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
@@ -26,7 +27,7 @@ namespace Discord.Webhook
_client = apiClient;
Id = model.Id;
ChannelId = model.Id;
- Token = model.Token;
+ Token = model.Token.GetValueOrDefault(null);
}
internal static RestInternalWebhook Create(DiscordWebhookClient client, Model model)
{
@@ -46,6 +47,8 @@ namespace Discord.Webhook
if (model.Name.IsSpecified)
Name = model.Name.Value;
+ Type = model.Type;
+
ApplicationId = model.ApplicationId;
}