Module: Discordrb::Events
- Included in:
- EventContainer
- Defined in:
- lib/discordrb/events/raw.rb,
lib/discordrb/events/bans.rb,
lib/discordrb/events/await.rb,
lib/discordrb/events/roles.rb,
lib/discordrb/events/guilds.rb,
lib/discordrb/events/typing.rb,
lib/discordrb/events/generic.rb,
lib/discordrb/events/invites.rb,
lib/discordrb/events/members.rb,
lib/discordrb/events/message.rb,
lib/discordrb/events/threads.rb,
lib/discordrb/events/channels.rb,
lib/discordrb/events/lifetime.rb,
lib/discordrb/events/presence.rb,
lib/discordrb/events/webhooks.rb,
lib/discordrb/events/reactions.rb,
lib/discordrb/events/interactions.rb,
lib/discordrb/events/voice_state_update.rb,
lib/discordrb/events/voice_server_update.rb
Overview
Events used by discordrb
Defined Under Namespace
Modules: Respondable Classes: ApplicationCommandEvent, ApplicationCommandEventHandler, AwaitEvent, AwaitEventHandler, ButtonEvent, ButtonEventHandler, ChannelCreateEvent, ChannelCreateEventHandler, ChannelDeleteEvent, ChannelDeleteEventHandler, ChannelRecipientAddEvent, ChannelRecipientAddEventHandler, ChannelRecipientEvent, ChannelRecipientEventHandler, ChannelRecipientRemoveEvent, ChannelRecipientRemoveEventHandler, ChannelSelectEvent, ChannelSelectEventHandler, ChannelUpdateEvent, ChannelUpdateEventHandler, ComponentEvent, ComponentEventHandler, DisconnectEvent, DisconnectEventHandler, Event, EventHandler, HeartbeatEvent, HeartbeatEventHandler, InteractionCreateEvent, InteractionCreateEventHandler, InviteCreateEvent, InviteCreateEventHandler, InviteDeleteEvent, InviteDeleteEventHandler, LifetimeEvent, MentionEvent, MentionEventHandler, MentionableSelectEvent, MentionableSelectEventHandler, MessageDeleteEvent, MessageDeleteEventHandler, MessageEditEvent, MessageEditEventHandler, MessageEvent, MessageEventHandler, MessageIDEvent, MessageIDEventHandler, MessageUpdateEvent, MessageUpdateEventHandler, ModalSubmitEvent, ModalSubmitEventHandler, Negated, PlayingEvent, PlayingEventHandler, PresenceEvent, PresenceEventHandler, PrivateMessageEvent, PrivateMessageEventHandler, RawEvent, RawEventHandler, ReactionAddEvent, ReactionAddEventHandler, ReactionEvent, ReactionEventHandler, ReactionRemoveAllEvent, ReactionRemoveAllEventHandler, ReactionRemoveEvent, ReactionRemoveEventHandler, ReadyEvent, ReadyEventHandler, RoleSelectEvent, RoleSelectEventHandler, ServerCreateEvent, ServerCreateEventHandler, ServerDeleteEvent, ServerDeleteEventHandler, ServerEmojiCDEvent, ServerEmojiCDEventHandler, ServerEmojiChangeEvent, ServerEmojiChangeEventHandler, ServerEmojiCreateEvent, ServerEmojiCreateEventHandler, ServerEmojiDeleteEvent, ServerEmojiDeleteEventHandler, ServerEmojiUpdateEvent, ServerEmojiUpdateEventHandler, ServerEvent, ServerEventHandler, ServerMemberAddEvent, ServerMemberAddEventHandler, ServerMemberDeleteEvent, ServerMemberDeleteEventHandler, ServerMemberEvent, ServerMemberEventHandler, ServerMemberUpdateEvent, ServerMemberUpdateEventHandler, ServerRoleCreateEvent, ServerRoleCreateEventHandler, ServerRoleDeleteEvent, ServerRoleDeleteEventHandler, ServerRoleUpdateEvent, ServerRoleUpdateEventHandler, ServerUpdateEvent, ServerUpdateEventHandler, StringSelectEvent, StringSelectEventHandler, SubcommandBuilder, ThreadCreateEvent, ThreadCreateEventHandler, ThreadMembersUpdateEvent, ThreadMembersUpdateEventHandler, ThreadUpdateEvent, ThreadUpdateEventHandler, TrueEventHandler, TypingEvent, TypingEventHandler, UnknownEvent, UnknownEventHandler, UserBanEvent, UserBanEventHandler, UserSelectEvent, UserSelectEventHandler, UserUnbanEvent, UserUnbanEventHandler, VoiceServerUpdateEvent, VoiceServerUpdateEventHandler, VoiceStateUpdateEvent, VoiceStateUpdateEventHandler, WebhookUpdateEvent, WebhookUpdateEventHandler
Class Method Summary collapse
-
.matches_all(attributes, to_check) {|a, e| ... } ⇒ true, false
Attempts to match possible formats of event attributes to a set comparison value, using a comparison block.
Class Method Details
.matches_all(attributes, to_check) {|a, e| ... } ⇒ true, false
Attempts to match possible formats of event attributes to a set comparison value, using a comparison block. It allows five kinds of attribute formats:
- nil -> always returns true
- A single attribute, not negated
- A single attribute, negated
- An array of attributes, not negated
- An array of attributes, not negated Note that it doesn't allow an array of negated attributes. For info on negation stuff, see #not!
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/discordrb/events/generic.rb', line 33 def self.matches_all(attributes, to_check, &block) # "Zeroth" case: attributes is nil return true if attributes.nil? # First case: there's a single negated attribute if attributes.is_a? Negated # The contained object might also be an array, so recursively call matches_all (and negate the result) return !matches_all(attributes.object, to_check, &block) end # Second case: there's a single, not-negated attribute return yield(attributes, to_check) unless attributes.is_a? Array # Third case: it's an array of attributes attributes.reduce(false) do |result, element| result || yield(element, to_check) end end |