Open joelzwarrington opened 1 year ago
The docs for Discordrb::Bot#application_command
(which is included from Discordrb::EventContainer
) state that the name argument shall be a symbol, so I would expect that it is intended to not work with strings.
A dive into the source code confirms that:
The application command is called here.
https://github.com/shardlab/discordrb/blob/a873d4efad8e87af5732a7e63044ff95cebc11d6/lib/discordrb/bot.rb#L1561
event
is a Discordrb::Events::ApplicationCommandEvent
, as can be seen a few lines above that one. The initializer of that class turns any command name received from Discord into a symbol.
https://github.com/shardlab/discordrb/blob/a873d4efad8e87af5732a7e63044ff95cebc11d6/lib/discordrb/events/interactions.rb#L162
This symbolized command name is then used to look up the block in a Hash
, but the key is the name String
you passed, so the lookup fails.
Assuming that it is a common mistake to not read the docs properly, this is probably not the first nor the last time someone has this issue. An improvement could be to convert the command name argument of #application_command
to a symbol and maybe even add String
as a valid argument type to its documentation (in addition to Symbol
).
The example for slash commands uses strings, so if only symbols are supported, that should be fixed...
Summary
When adding application command handlers with a string instead of a symbol, they do not respond.
No warnings are present in the logger either.
Environment
Ruby version:
Discordrb version: