Browse Source

Add event docs

- MessageReceived
- ChannelUpdated/Destroyed/Created
pull/1161/head
Still Hsu 7 years ago
parent
commit
a9983026f0
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
2 changed files with 69 additions and 1 deletions
  1. +1
    -1
      docs/docfx.json
  2. +68
    -0
      src/Discord.Net.WebSocket/BaseSocketClient.Events.cs

+ 1
- 1
docs/docfx.json View File

@@ -43,7 +43,7 @@
"globalMetadata": { "globalMetadata": {
"_appTitle": "Discord.Net Documentation", "_appTitle": "Discord.Net Documentation",
"_appFooter": "Discord.Net (c) 2015-2018 2.0.0-beta", "_appFooter": "Discord.Net (c) 2015-2018 2.0.0-beta",
"_enableSearch": true,
"_enableSearch": true
}, },
"noLangKeyword": false, "noLangKeyword": false,
"xrefService": [ "xrefService": [


+ 68
- 0
src/Discord.Net.WebSocket/BaseSocketClient.Events.cs View File

@@ -7,6 +7,17 @@ namespace Discord.WebSocket
{ {
//Channels //Channels
/// <summary> Fired when a channel is created. </summary> /// <summary> Fired when a channel is created. </summary>
/// <remarks>
/// <para>
/// This event is fired when a generic channel has been created. The event handler must return a
/// <see cref="Task"/>.
/// </para>
/// <para>
/// The newly created channel is passed into the event handler parameter. The given channel type may
/// include, but not limited to, Private Channels (DM, Group), Guild Channels (Text, Voice, Category);
/// see the derived classes of <see cref="SocketChannel"/> for more details.
/// </para>
/// </remarks>
public event Func<SocketChannel, Task> ChannelCreated public event Func<SocketChannel, Task> ChannelCreated
{ {
add { _channelCreatedEvent.Add(value); } add { _channelCreatedEvent.Add(value); }
@@ -14,12 +25,35 @@ namespace Discord.WebSocket
} }
internal readonly AsyncEvent<Func<SocketChannel, Task>> _channelCreatedEvent = new AsyncEvent<Func<SocketChannel, Task>>(); internal readonly AsyncEvent<Func<SocketChannel, Task>> _channelCreatedEvent = new AsyncEvent<Func<SocketChannel, Task>>();
/// <summary> Fired when a channel is destroyed. </summary> /// <summary> Fired when a channel is destroyed. </summary>
/// <remarks>
/// <para>
/// This event is fired when a generic channel has been destroyed. The event handler must return a
/// <see cref="Task"/>.
/// </para>
/// <para>
/// The destroyed channel is passed into the event handler parameter. The given channel type may
/// include, but not limited to, Private Channels (DM, Group), Guild Channels (Text, Voice, Category);
/// see the derived classes of <see cref="SocketChannel"/> for more details.
/// </para>
/// </remarks>
public event Func<SocketChannel, Task> ChannelDestroyed { public event Func<SocketChannel, Task> ChannelDestroyed {
add { _channelDestroyedEvent.Add(value); } add { _channelDestroyedEvent.Add(value); }
remove { _channelDestroyedEvent.Remove(value); } remove { _channelDestroyedEvent.Remove(value); }
} }
internal readonly AsyncEvent<Func<SocketChannel, Task>> _channelDestroyedEvent = new AsyncEvent<Func<SocketChannel, Task>>(); internal readonly AsyncEvent<Func<SocketChannel, Task>> _channelDestroyedEvent = new AsyncEvent<Func<SocketChannel, Task>>();
/// <summary> Fired when a channel is updated. </summary> /// <summary> Fired when a channel is updated. </summary>
/// <remarks>
/// <para>
/// This event is fired when a generic channel has been destroyed. The event handler must return a
/// <see cref="Task"/>.
/// </para>
/// <para>
/// The original (prior to update) channel is passed into the first <see cref="SocketChannel"/>, while
/// the updated channel is passed into the second. The given channel type may include, but not limited
/// to, Private Channels (DM, Group), Guild Channels (Text, Voice, Category); see the derived classes of
/// <see cref="SocketChannel"/> for more details.
/// </para>
/// </remarks>
public event Func<SocketChannel, SocketChannel, Task> ChannelUpdated { public event Func<SocketChannel, SocketChannel, Task> ChannelUpdated {
add { _channelUpdatedEvent.Add(value); } add { _channelUpdatedEvent.Add(value); }
remove { _channelUpdatedEvent.Remove(value); } remove { _channelUpdatedEvent.Remove(value); }
@@ -28,12 +62,46 @@ namespace Discord.WebSocket


//Messages //Messages
/// <summary> Fired when a message is received. </summary> /// <summary> Fired when a message is received. </summary>
/// <remarks>
/// <para>
/// This event is fired when a message is received. The event handler must return a
/// <see cref="Task"/>.
/// </para>
/// <para>
/// The message that is sent to the client is passed into the event handler parameter as
/// <see cref="SocketMessage"/>. This message may be a system message (i.e.
/// <see cref="SocketSystemMessage"/>) or a user message (i.e. <see cref="SocketUserMessage"/>. See
/// the derived clsases of <see cref="SocketMessage"/> for more details.
/// </para>
/// </remarks>
public event Func<SocketMessage, Task> MessageReceived { public event Func<SocketMessage, Task> MessageReceived {
add { _messageReceivedEvent.Add(value); } add { _messageReceivedEvent.Add(value); }
remove { _messageReceivedEvent.Remove(value); } remove { _messageReceivedEvent.Remove(value); }
} }
internal readonly AsyncEvent<Func<SocketMessage, Task>> _messageReceivedEvent = new AsyncEvent<Func<SocketMessage, Task>>(); internal readonly AsyncEvent<Func<SocketMessage, Task>> _messageReceivedEvent = new AsyncEvent<Func<SocketMessage, Task>>();
/// <summary> Fired when a message is deleted. </summary> /// <summary> Fired when a message is deleted. </summary>
/// <remarks>
/// <para>
/// 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="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<Cacheable<IMessage, ulong>, ISocketMessageChannel, Task> MessageDeleted { public event Func<Cacheable<IMessage, ulong>, ISocketMessageChannel, Task> MessageDeleted {
add { _messageDeletedEvent.Add(value); } add { _messageDeletedEvent.Add(value); }
remove { _messageDeletedEvent.Remove(value); } remove { _messageDeletedEvent.Remove(value); }


Loading…
Cancel
Save