Creating option with no emoji does not work
Closed this issue · 1 comments
Summary
Example for buttons/select_menu https://github.com/shardlab/discordrb/blob/main/examples/slash_commands.rb#L72-L86 does nto work. When run results in error:
[ERROR : it-1245911902400548916 @ 2024-05-31 03:29:06.262] Invalid Form Body
- data.components[1].components[0].options[0].emoji.name: Invalid emoji
- data.components[1].components[0].options[1].emoji.name: Invalid emoji
- data.components[1].components[0].options[2].emoji.name: Invalid emoji
- data.components[1].components[0].options[3].emoji.name: Invalid emoji
The problem lies in https://github.com/shardlab/discordrb/blob/main/lib/discordrb/webhooks/view.rb#L148 calling to_h
on nil
which at least in ruby 3+ returns {}
which in turns causes discord API to reject the message.
Environment
Ruby version:
ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux]
Discordrb version:
discordrb (3.5.0)
discordrb-webhooks (3.5.0)
I just tried to fix this myself but this seems to be fixed in master
See:
But unfortunately does not seem to have been released :(
If someone stumbles upon this, a workaround is to use dev version of the gem. Add following to Gemfile and bundle install:
gem 'discordrb', '~> 3.5', git: 'https://github.com/shardlab/discordrb', branch: 'main'