Browse Source

Add event for autocomplete interaction (#214)

pull/1923/head
marens101 GitHub 3 years ago
parent
commit
34748c86c5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 1 deletions
  1. +10
    -1
      src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
  2. +5
    -0
      src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
  3. +1
    -0
      src/Discord.Net.WebSocket/DiscordShardedClient.cs
  4. +3
    -0
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 10
- 1
src/Discord.Net.WebSocket/BaseSocketClient.Events.cs View File

@@ -469,7 +469,7 @@ namespace Discord.WebSocket

#region Interactions
/// <summary>
/// Fired when an Interaction is created. This event covers all types of interactions including but not limited to: buttons, select menus, slash commands.
/// Fired when an Interaction is created. This event covers all types of interactions including but not limited to: buttons, select menus, slash commands, autocompletes.
/// </summary>
/// <remarks>
/// <para>
@@ -535,6 +535,15 @@ namespace Discord.WebSocket
remove => _messageCommandExecuted.Remove(value);
}
internal readonly AsyncEvent<Func<SocketMessageCommand, Task>> _messageCommandExecuted = new AsyncEvent<Func<SocketMessageCommand, Task>>();
/// <summary>
/// Fired when an autocomplete is used and its interaction is received.
/// </summary>
public event Func<SocketAutocompleteInteraction, Task> AutocompleteExecuted
{
add => _autocompleteExecuted.Add(value);
remove => _autocompleteExecuted.Remove(value);
}
internal readonly AsyncEvent<Func<SocketAutocompleteInteraction, Task>> _autocompleteExecuted = new AsyncEvent<Func<SocketAutocompleteInteraction, Task>>();

/// <summary>
/// Fired when a guild application command is created.


+ 5
- 0
src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml View File

@@ -746,6 +746,11 @@
Fired when a message command is used and its interaction is received.
</summary>
</member>
<member name="E:Discord.WebSocket.BaseSocketClient.AutocompleteExecuted">
<summary>
Fired when an autocomplete is used and its interaction is received.
</summary>
</member>
<member name="E:Discord.WebSocket.BaseSocketClient.ApplicationCommandCreated">
<summary>
Fired when a guild application command is created.


+ 1
- 0
src/Discord.Net.WebSocket/DiscordShardedClient.cs View File

@@ -466,6 +466,7 @@ namespace Discord.WebSocket
client.SlashCommandExecuted += (arg) => _slashCommandExecuted.InvokeAsync(arg);
client.UserCommandExecuted += (arg) => _userCommandExecuted.InvokeAsync(arg);
client.MessageCommandExecuted += (arg) => _messageCommandExecuted.InvokeAsync(arg);
client.AutocompleteExecuted += (arg) => _autocompleteExecuted.InvokeAsync(arg);

client.ThreadUpdated += (thread1, thread2) => _threadUpdated.InvokeAsync(thread1, thread2);
client.ThreadCreated += (thread) => _threadCreated.InvokeAsync(thread);


+ 3
- 0
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -2125,6 +2125,9 @@ namespace Discord.WebSocket
case SocketMessageCommand messageCommand:
await TimedInvokeAsync(_messageCommandExecuted, nameof(MessageCommandExecuted), messageCommand).ConfigureAwait(false);
break;
case SocketAutocompleteInteraction autocomplete:
await TimedInvokeAsync(_autocompleteExecuted, nameof(AutocompleteExecuted), autocomplete).ConfigureAwait(false);
break;
}
}
else


Loading…
Cancel
Save