From 4de6f6fcd700be551da957b2f0c7baa43bf80fde Mon Sep 17 00:00:00 2001 From: hutonahill Date: Thu, 15 Aug 2024 16:46:27 -0500 Subject: [PATCH 1/3] Create exampleRegisterAutocompletion.cs --- .../samples/autocompletion/exampleRegisterAutocompletion.cs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/guides/int_framework/samples/autocompletion/exampleRegisterAutocompletion.cs diff --git a/docs/guides/int_framework/samples/autocompletion/exampleRegisterAutocompletion.cs b/docs/guides/int_framework/samples/autocompletion/exampleRegisterAutocompletion.cs new file mode 100644 index 0000000000..bc1dc94705 --- /dev/null +++ b/docs/guides/int_framework/samples/autocompletion/exampleRegisterAutocompletion.cs @@ -0,0 +1,6 @@ +_client.AutocompleteExecuted += HandleAutocompleteExecution; + +private static async Task HandleAutocompleteExecution(SocketAutocompleteInteraction arg){ + var context = new InteractionContext(_client, arg, arg.Channel); + await _interactionService.ExecuteCommandAsync(context, null); +} From a8102424496e421feb84b245103602dfe8ce1ef1 Mon Sep 17 00:00:00 2001 From: hutonahill Date: Thu, 15 Aug 2024 16:57:15 -0500 Subject: [PATCH 2/3] Update autocompletion.md added an example of the AutocompleteExecuted registration which is needed for this to work. source: https://stackoverflow.com/questions/74957340/how-to-make-the-autocomplete-handler-work-in-discord-net/75298504#75298504 also, i did it and it works now. --- docs/guides/int_framework/autocompletion.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/guides/int_framework/autocompletion.md b/docs/guides/int_framework/autocompletion.md index 35b4858914..68e2bab8b5 100644 --- a/docs/guides/int_framework/autocompletion.md +++ b/docs/guides/int_framework/autocompletion.md @@ -20,6 +20,10 @@ A valid AutocompleteHandlers must inherit [AutocompleteHandler] base type and im [!code-csharp[Autocomplete Command Example](samples/autocompletion/autocomplete-example.cs)] +In order for Autocompletehandlers to work you must register a AutocompleteExecuted method with your DiscordSocketClient + +[!code-csharp[RegisterAutocompleteExecuted](docs/guides/int_framework/samples/autocompletion/exampleRegisterAutocompletion.cs)] + ### GenerateSuggestionsAsync() The Interactions Service uses this method to generate a response of an Autocomplete Interaction. From efb49f3a281199c94fe80cd6964e41f8f7522072 Mon Sep 17 00:00:00 2001 From: hutonahill Date: Thu, 15 Aug 2024 17:31:07 -0500 Subject: [PATCH 3/3] Update autocompletion.md --- docs/guides/int_framework/autocompletion.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/int_framework/autocompletion.md b/docs/guides/int_framework/autocompletion.md index 68e2bab8b5..6c5eefddc0 100644 --- a/docs/guides/int_framework/autocompletion.md +++ b/docs/guides/int_framework/autocompletion.md @@ -22,7 +22,7 @@ A valid AutocompleteHandlers must inherit [AutocompleteHandler] base type and im In order for Autocompletehandlers to work you must register a AutocompleteExecuted method with your DiscordSocketClient -[!code-csharp[RegisterAutocompleteExecuted](docs/guides/int_framework/samples/autocompletion/exampleRegisterAutocompletion.cs)] +[!code-csharp[RegisterAutocompleteExecuted](samples/autocompletion/exampleRegisterAutocompletion.cs)] ### GenerateSuggestionsAsync()