Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/discordrb/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ def channel_recipient_remove(attributes = {}, &block)
# @option attributes [true, false] :deaf Matches whether or not the user is deafened server-wide.
# @option attributes [true, false] :self_mute Matches whether or not the user is muted by the bot.
# @option attributes [true, false] :self_deaf Matches whether or not the user is deafened by the bot.
# @option attributes [true, false] :connected Matches whether or not the user is newly connecting to voice.
# @option attributes [true, false] :disconnected Matches whether or not the user is no longer connected to any voice channel.
# @option attributes [true, false] :moved Matches whether or not the user moved to a different voice channel.
# @yield The block is executed when the event is raised.
# @yieldparam event [VoiceStateUpdateEvent] The event that was raised.
# @return [VoiceStateUpdateEventHandler] the event handler that was registered.
Expand Down
24 changes: 24 additions & 0 deletions lib/discordrb/events/voice_state_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,30 @@ def matches?(event)
else
e
end
end,
matches_all(@attributes[:connected], event.old_channel) do |a, e|
case a
when TrueClass
e.nil?
when FalseClass
!e.nil?
end
end,
matches_all(@attributes[:disconnected], event.channel) do |a, e|
case a
when TrueClass
e.nil?
when FalseClass
!e.nil?
end
end,
matches_all(@attributes[:moved], event) do |a, e|
Comment thread
Droid00000 marked this conversation as resolved.
case a
when TrueClass
(e.channel && e.old_channel) && e.channel != e.old_channel
when FalseClass
!((e.channel && e.old_channel) && e.channel != e.old_channel)
end
end
].reduce(true, &:&)
end
Expand Down
Loading