DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
Collecting Autocomplete Input

// main.cpp - main entry point.
// jun 17, 2021
// chris m.
// https://github.com/RealTimeChris
void theAutoCompleteFunction(on_auto_complete_entry_data dataPackage) {
respond_to_input_event_data& dataPackageNew{ dataPackage.inputEvent };
if (dataPackage.inputEvent.getInteractionData().data.applicationCommandData.options[0].valueString.find("tes") != jsonifier::string::npos) {
dataPackageNew.setAutoCompleteChoice("the test value", "test_value_name");
dataPackageNew.setResponseType(input_event_response_type::Application_Command_AutoComplete_Result);
input_events::respondToInputEventAsync(dataPackageNew).get();
} else {
dataPackageNew.setResponseType(input_event_response_type::Application_Command_AutoComplete_Result);
input_events::respondToInputEventAsync(dataPackageNew).get();
}
}
int32_t main() {
jsonifier::string botToken = "YOUR_BOT_TOKEN_HERE";
discord_core_client client{ botToken };
client.eventManager.onAutoCompleteEntry(&theAutoCompleteFunction);
client.registerFunction(jsonifier::vector<jsonifier::string>{ "test" }, makeUnique<test>());
client.runBot();
return 0;
}