From 8229faad7656307b582bdb19b958f539ce612208 Mon Sep 17 00:00:00 2001 From: Droid <174426320+Droid00000@users.noreply.github.com> Date: Thu, 1 Jan 2026 18:58:48 -0500 Subject: [PATCH 1/4] feat: more voice state filters --- lib/discordrb/container.rb | 3 +++ lib/discordrb/events/voice_state_update.rb | 24 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/discordrb/container.rb b/lib/discordrb/container.rb index d3380a49c0..bcf7b0a65f 100644 --- a/lib/discordrb/container.rb +++ b/lib/discordrb/container.rb @@ -297,6 +297,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] :newly_joined 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. diff --git a/lib/discordrb/events/voice_state_update.rb b/lib/discordrb/events/voice_state_update.rb index 41c4b66e4b..aac30124d7 100644 --- a/lib/discordrb/events/voice_state_update.rb +++ b/lib/discordrb/events/voice_state_update.rb @@ -99,6 +99,30 @@ def matches?(event) else e end + end, + matches_all(@attributes[:newly_joined], 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| + 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 From 1c48857cddf0dea1057c106d6766cec19409ef59 Mon Sep 17 00:00:00 2001 From: Droid Date: Sat, 3 Jan 2026 18:41:02 -0500 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Nick <78424211+gitnickolson@users.noreply.github.com> --- lib/discordrb/events/voice_state_update.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/discordrb/events/voice_state_update.rb b/lib/discordrb/events/voice_state_update.rb index aac30124d7..5f24898a82 100644 --- a/lib/discordrb/events/voice_state_update.rb +++ b/lib/discordrb/events/voice_state_update.rb @@ -100,7 +100,7 @@ def matches?(event) e end end, - matches_all(@attributes[:newly_joined], event.old_channel) do |a, e| + matches_all(@attributes[:joined], event.old_channel) do |a, e| case a when TrueClass e.nil? From 6083a13b057096d0a0e35505a945bbb73dc7c64d Mon Sep 17 00:00:00 2001 From: Droid Date: Sat, 3 Jan 2026 18:42:04 -0500 Subject: [PATCH 3/4] Update lib/discordrb/container.rb --- lib/discordrb/container.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/discordrb/container.rb b/lib/discordrb/container.rb index bcf7b0a65f..1d65f9d901 100644 --- a/lib/discordrb/container.rb +++ b/lib/discordrb/container.rb @@ -297,7 +297,7 @@ 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] :newly_joined Matches whether or not the user is newly connecting to voice. + # @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. From 266f8bf6c2854a4b03c92d312e6b59fd86201ecd Mon Sep 17 00:00:00 2001 From: Droid Date: Sat, 3 Jan 2026 18:42:09 -0500 Subject: [PATCH 4/4] Update lib/discordrb/events/voice_state_update.rb --- lib/discordrb/events/voice_state_update.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/discordrb/events/voice_state_update.rb b/lib/discordrb/events/voice_state_update.rb index 5f24898a82..e57bcfcb90 100644 --- a/lib/discordrb/events/voice_state_update.rb +++ b/lib/discordrb/events/voice_state_update.rb @@ -100,7 +100,7 @@ def matches?(event) e end end, - matches_all(@attributes[:joined], event.old_channel) do |a, e| + matches_all(@attributes[:connected], event.old_channel) do |a, e| case a when TrueClass e.nil?