Closed MathieuDR closed 2 years ago
There's already a way to do this, using the Callbacks
property.
Callbacks
is a dictionary containing the IDs of the messages and their callbacks.
So, to check if an interaction is meant for InteractiveService
you simply use ContainsKey()
passing the ID of the message the interaction comes from.
Example:
private async Task InteractionCreated(SocketInteraction interaction)
{
if (interaction is SocketMessageComponent messageComponent && !Interactive.Callbacks.ContainsKey(messageComponent.Message.Id))
{
await interaction.RespondAsync("Cannot find a handler for this interaction.", ephemeral: true);
}
}
This only works with component interactions (paginators and selections) and won't work with other type of interactions.
Thanks, I did not see this
While using Discord.Net.Labs I have my own event handler when an interaction is created.
I also want to send a response when I cannot find a correct handler to the user, however I have no clear cut solution to ID an interaction meant for this library (eg the paginator).
It would be nice to have a possibility for this.