discordia-slash icon indicating copy to clipboard operation
discordia-slash copied to clipboard

interactionCreate is not guaranteed to be handled first by the library

Open Bilal2453 opened this issue 1 year ago • 0 comments

https://github.com/GitSparTV/discordia-slash/blob/master/libs/client/Client.lua#L268-L303

if the user defines a interactionCreate before the use of Client:useApplicationCommands, their event listener will run first, possibly interfering with the library's code.

The solution to this would be using a pre-listener offer by discordia-interactions, like this:

  function discordia_interactions.EventHandler.interaction_create_prelisteners.slashCommands(intr, client)
    if intr.type == enums.interactionType.applicationCommand and intr.data.type == 1 then
      client:emit('slashCommand', intr)
    end
  end

This also means that the user doesn't even need to do Client:useApplicationCommands to begin with if this is used, you just hook into discordia-interactions which handles it for you.

Bilal2453 avatar Oct 18 '24 00:10 Bilal2453