Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix InteractionCreateEvent type matching #251

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

zeiv
Copy link

@zeiv zeiv commented Jan 23, 2024

Summary

This PR fixes some bugs where matching Interactions based on type via a symbol or string wasn't working. There was a typo in the matcher block, and as far as I can call the comparison wasn't working either. Specs have been added to cover all formats described as supported in the documentation for matching Interaction types (Integer, String, and Symbol).

Example broken code before this fix:

module EventHandler
  extend Discordrb::EventContainer

  interaction_create type: :component do |event|
    event.defer
  end
end

This would result in NameError: uninitialized constant Discordrb::Interactions::TYPES


Added

  • Specs for InteractionCreateEvent

Changed

  • Matching behavior for :type attribute in InteractionCreateEventHandler

Deprecated

Removed

Fixed

  • NameError: uninitialized constant Discordrb::Interactions::TYPES in InteractionCreateEventHandler when matching on :type
  • Incorrect matching logic with Strings and Symbols in InteractionCreateEventHandler :type attribute

@zeiv
Copy link
Author

zeiv commented Jan 24, 2024

This should be ready to review, it appears that the Ruby 3.1 failures are unrelated to this PR and due to libsodium issues. Rubocop violations have been addressed though I can't rerun the check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant