feat: Support the WEBHOOKS_UPDATED event (#2384)
Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
246282dda3
commit
010e8e828f
@@ -0,0 +1,13 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Discord.API.Gateway
|
||||||
|
{
|
||||||
|
internal class WebhooksUpdatedEvent
|
||||||
|
{
|
||||||
|
[JsonProperty("guild_id")]
|
||||||
|
public ulong GuildId { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("channel_id")]
|
||||||
|
public ulong ChannelId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -106,7 +106,7 @@ namespace Discord.WebSocket
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// This event is fired when a message is deleted. The event handler must return a
|
/// This event is fired when a message is deleted. The event handler must return a
|
||||||
/// <see cref="Task"/> and accept a <see cref="Cacheable{TEntity,TId}"/> and
|
/// <see cref="Task"/> and accept a <see cref="Cacheable{TEntity,TId}"/> and
|
||||||
/// <see cref="ISocketMessageChannel"/> as its parameters.
|
/// <see cref="ISocketMessageChannel"/> as its parameters.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
@@ -117,11 +117,11 @@ namespace Discord.WebSocket
|
|||||||
/// </note>
|
/// </note>
|
||||||
/// If caching is enabled via <see cref="DiscordSocketConfig"/>, the
|
/// If caching is enabled via <see cref="DiscordSocketConfig"/>, the
|
||||||
/// <see cref="Cacheable{TEntity,TId}"/> entity will contain the deleted message; otherwise, in event
|
/// <see cref="Cacheable{TEntity,TId}"/> entity will contain the deleted message; otherwise, in event
|
||||||
/// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
|
/// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
|
||||||
/// <see cref="ulong"/>.
|
/// <see cref="ulong"/>.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The source channel of the removed message will be passed into the
|
/// The source channel of the removed message will be passed into the
|
||||||
/// <see cref="ISocketMessageChannel"/> parameter.
|
/// <see cref="ISocketMessageChannel"/> parameter.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
@@ -143,7 +143,7 @@ namespace Discord.WebSocket
|
|||||||
/// </note>
|
/// </note>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// This event is fired when multiple messages are bulk deleted. The event handler must return a
|
/// This event is fired when multiple messages are bulk deleted. The event handler must return a
|
||||||
/// <see cref="Task"/> and accept an <see cref="IReadOnlyCollection{Cacheable}"/> and
|
/// <see cref="Task"/> and accept an <see cref="IReadOnlyCollection{Cacheable}"/> and
|
||||||
/// <see cref="ISocketMessageChannel"/> as its parameters.
|
/// <see cref="ISocketMessageChannel"/> as its parameters.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
@@ -154,11 +154,11 @@ namespace Discord.WebSocket
|
|||||||
/// </note>
|
/// </note>
|
||||||
/// If caching is enabled via <see cref="DiscordSocketConfig"/>, the
|
/// If caching is enabled via <see cref="DiscordSocketConfig"/>, the
|
||||||
/// <see cref="Cacheable{TEntity,TId}"/> entity will contain the deleted message; otherwise, in event
|
/// <see cref="Cacheable{TEntity,TId}"/> entity will contain the deleted message; otherwise, in event
|
||||||
/// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
|
/// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
|
||||||
/// <see cref="ulong"/>.
|
/// <see cref="ulong"/>.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The source channel of the removed message will be passed into the
|
/// The source channel of the removed message will be passed into the
|
||||||
/// <see cref="ISocketMessageChannel"/> parameter.
|
/// <see cref="ISocketMessageChannel"/> parameter.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
@@ -178,14 +178,14 @@ namespace Discord.WebSocket
|
|||||||
/// <para>
|
/// <para>
|
||||||
/// If caching is enabled via <see cref="DiscordSocketConfig"/>, the
|
/// If caching is enabled via <see cref="DiscordSocketConfig"/>, the
|
||||||
/// <see cref="Cacheable{TEntity,TId}"/> entity will contain the original message; otherwise, in event
|
/// <see cref="Cacheable{TEntity,TId}"/> entity will contain the original message; otherwise, in event
|
||||||
/// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
|
/// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
|
||||||
/// <see cref="ulong"/>.
|
/// <see cref="ulong"/>.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The updated message will be passed into the <see cref="SocketMessage"/> parameter.
|
/// The updated message will be passed into the <see cref="SocketMessage"/> parameter.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The source channel of the updated message will be passed into the
|
/// The source channel of the updated message will be passed into the
|
||||||
/// <see cref="ISocketMessageChannel"/> parameter.
|
/// <see cref="ISocketMessageChannel"/> parameter.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
@@ -199,24 +199,24 @@ namespace Discord.WebSocket
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// This event is fired when a reaction is added to a user message. The event handler must return a
|
/// This event is fired when a reaction is added to a user message. The event handler must return a
|
||||||
/// <see cref="Task"/> and accept a <see cref="Cacheable{TEntity,TId}"/>, an
|
/// <see cref="Task"/> and accept a <see cref="Cacheable{TEntity,TId}"/>, an
|
||||||
/// <see cref="ISocketMessageChannel"/>, and a <see cref="SocketReaction"/> as its parameter.
|
/// <see cref="ISocketMessageChannel"/>, and a <see cref="SocketReaction"/> as its parameter.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// If caching is enabled via <see cref="DiscordSocketConfig"/>, the
|
/// If caching is enabled via <see cref="DiscordSocketConfig"/>, the
|
||||||
/// <see cref="Cacheable{TEntity,TId}"/> entity will contain the original message; otherwise, in event
|
/// <see cref="Cacheable{TEntity,TId}"/> entity will contain the original message; otherwise, in event
|
||||||
/// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
|
/// that the message cannot be retrieved, the snowflake ID of the message is preserved in the
|
||||||
/// <see cref="ulong"/>.
|
/// <see cref="ulong"/>.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The source channel of the reaction addition will be passed into the
|
/// The source channel of the reaction addition will be passed into the
|
||||||
/// <see cref="ISocketMessageChannel"/> parameter.
|
/// <see cref="ISocketMessageChannel"/> parameter.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The reaction that was added will be passed into the <see cref="SocketReaction"/> parameter.
|
/// The reaction that was added will be passed into the <see cref="SocketReaction"/> parameter.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <note>
|
/// <note>
|
||||||
/// When fetching the reaction from this event, a user may not be provided under
|
/// When fetching the reaction from this event, a user may not be provided under
|
||||||
/// <see cref="SocketReaction.User"/>. Please see the documentation of the property for more
|
/// <see cref="SocketReaction.User"/>. Please see the documentation of the property for more
|
||||||
/// information.
|
/// information.
|
||||||
/// </note>
|
/// </note>
|
||||||
@@ -367,7 +367,7 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
internal readonly AsyncEvent<Func<Cacheable<SocketGuildEvent, ulong>, SocketGuildEvent, Task>> _guildScheduledEventUpdated = new AsyncEvent<Func<Cacheable<SocketGuildEvent, ulong>, SocketGuildEvent, Task>>();
|
internal readonly AsyncEvent<Func<Cacheable<SocketGuildEvent, ulong>, SocketGuildEvent, Task>> _guildScheduledEventUpdated = new AsyncEvent<Func<Cacheable<SocketGuildEvent, ulong>, SocketGuildEvent, Task>>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when a guild event is cancelled.
|
/// Fired when a guild event is cancelled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -877,5 +877,20 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
internal readonly AsyncEvent<Func<SocketCustomSticker, Task>> _guildStickerDeleted = new AsyncEvent<Func<SocketCustomSticker, Task>>();
|
internal readonly AsyncEvent<Func<SocketCustomSticker, Task>> _guildStickerDeleted = new AsyncEvent<Func<SocketCustomSticker, Task>>();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Webhooks
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fired when a webhook is modified, moved, or deleted. If the webhook was
|
||||||
|
/// moved the channel represents the destination channel, not the source.
|
||||||
|
/// </summary>
|
||||||
|
public event Func<SocketGuild, SocketChannel, Task> WebhooksUpdated
|
||||||
|
{
|
||||||
|
add { _webhooksUpdated.Add(value); }
|
||||||
|
remove { _webhooksUpdated.Remove(value); }
|
||||||
|
}
|
||||||
|
internal readonly AsyncEvent<Func<SocketGuild, SocketChannel, Task>> _webhooksUpdated = new AsyncEvent<Func<SocketGuild, SocketChannel, Task>>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -496,6 +496,8 @@ namespace Discord.WebSocket
|
|||||||
client.GuildScheduledEventStarted += (arg) => _guildScheduledEventStarted.InvokeAsync(arg);
|
client.GuildScheduledEventStarted += (arg) => _guildScheduledEventStarted.InvokeAsync(arg);
|
||||||
client.GuildScheduledEventUserAdd += (arg1, arg2) => _guildScheduledEventUserAdd.InvokeAsync(arg1, arg2);
|
client.GuildScheduledEventUserAdd += (arg1, arg2) => _guildScheduledEventUserAdd.InvokeAsync(arg1, arg2);
|
||||||
client.GuildScheduledEventUserRemove += (arg1, arg2) => _guildScheduledEventUserRemove.InvokeAsync(arg1, arg2);
|
client.GuildScheduledEventUserRemove += (arg1, arg2) => _guildScheduledEventUserRemove.InvokeAsync(arg1, arg2);
|
||||||
|
|
||||||
|
client.WebhooksUpdated += (arg1, arg2) => _webhooksUpdated.InvokeAsync(arg1, arg2);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -2839,6 +2839,23 @@ namespace Discord.WebSocket
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Webhooks
|
||||||
|
|
||||||
|
case "WEBHOOKS_UPDATE":
|
||||||
|
{
|
||||||
|
var data = (payload as JToken).ToObject<WebhooksUpdatedEvent>(_serializer);
|
||||||
|
type = "WEBHOOKS_UPDATE";
|
||||||
|
await _gatewayLogger.DebugAsync("Received Dispatch (WEBHOOKS_UPDATE)").ConfigureAwait(false);
|
||||||
|
|
||||||
|
var guild = State.GetGuild(data.GuildId);
|
||||||
|
var channel = State.GetChannel(data.ChanelId);
|
||||||
|
|
||||||
|
await TimedInvokeAsync(_webhooksUpdated, nameof(WebhooksUpdated), guild, channel);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Ignored (User only)
|
#region Ignored (User only)
|
||||||
case "CHANNEL_PINS_ACK":
|
case "CHANNEL_PINS_ACK":
|
||||||
await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_ACK)").ConfigureAwait(false);
|
await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_ACK)").ConfigureAwait(false);
|
||||||
@@ -2858,9 +2875,6 @@ namespace Discord.WebSocket
|
|||||||
case "USER_SETTINGS_UPDATE":
|
case "USER_SETTINGS_UPDATE":
|
||||||
await _gatewayLogger.DebugAsync("Ignored Dispatch (USER_SETTINGS_UPDATE)").ConfigureAwait(false);
|
await _gatewayLogger.DebugAsync("Ignored Dispatch (USER_SETTINGS_UPDATE)").ConfigureAwait(false);
|
||||||
break;
|
break;
|
||||||
case "WEBHOOKS_UPDATE":
|
|
||||||
await _gatewayLogger.DebugAsync("Ignored Dispatch (WEBHOOKS_UPDATE)").ConfigureAwait(false);
|
|
||||||
break;
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Others
|
#region Others
|
||||||
|
|||||||
Reference in New Issue
Block a user