feature: messages bulk deleted event (from previous PR #1120) (#1236)

* Reimplement messags bulk deleted event RogueException/Discord.Net#1120

* Update remark

* Backwards compatability with config option
This commit is contained in:
NovusTheory
2019-05-17 17:49:36 -05:00
committed by Christopher F
parent b52b54d80c
commit dec353e57f
4 changed files with 48 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Discord.WebSocket
@@ -128,6 +129,38 @@ namespace Discord.WebSocket
remove { _messageDeletedEvent.Remove(value); }
}
internal readonly AsyncEvent<Func<Cacheable<IMessage, ulong>, ISocketMessageChannel, Task>> _messageDeletedEvent = new AsyncEvent<Func<Cacheable<IMessage, ulong>, ISocketMessageChannel, Task>>();
/// <summary> Fired when multiple messages are bulk deleted. </summary>
/// <remarks>
/// <note>
/// The <see cref="MessageDeleted"/> event will not be fired for individual messages contained in this event.
/// </note>
/// <para>
/// 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{TEntity,TId}}"/> and
/// <see cref="ISocketMessageChannel"/> as its parameters.
/// </para>
/// <para>
/// <note type="important">
/// It is not possible to retrieve the message via
/// <see cref="Cacheable{TEntity,TId}.DownloadAsync"/>; the message cannot be retrieved by Discord
/// after the message has been deleted.
/// </note>
/// If caching is enabled via <see cref="DiscordSocketConfig"/>, the
/// <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
/// <see cref="ulong"/>.
/// </para>
/// <para>
/// The source channel of the removed message will be passed into the
/// <see cref="ISocketMessageChannel"/> parameter.
/// </para>
/// </remarks>
public event Func<IReadOnlyCollection<Cacheable<IMessage, ulong>>, ISocketMessageChannel, Task> MessagesBulkDeleted
{
add { _messagesBulkDeletedEvent.Add(value); }
remove { _messagesBulkDeletedEvent.Remove(value); }
}
internal readonly AsyncEvent<Func<IReadOnlyCollection<Cacheable<IMessage, ulong>>, ISocketMessageChannel, Task>> _messagesBulkDeletedEvent = new AsyncEvent<Func<IReadOnlyCollection<Cacheable<IMessage, ulong>>, ISocketMessageChannel, Task>>();
/// <summary> Fired when a message is updated. </summary>
/// <remarks>
/// <para>