Class: OnyxCord::Events::VoiceStateUpdateEvent
- Defined in:
- lib/onyxcord/events/voice/state_update.rb
Overview
Event raised when a user's voice state updates
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#channel_id ⇒ Integer?
readonly
The current voice channel ID, or nil if the user left voice.
-
#deaf ⇒ Object
readonly
Returns the value of attribute deaf.
-
#mute ⇒ Object
readonly
Returns the value of attribute mute.
-
#old_channel ⇒ Channel?
readonly
The old channel this user was on, or nil if the user is newly joining voice.
-
#old_channel_id ⇒ Integer?
readonly
The previous voice channel ID, or nil if the user joined voice.
-
#self_deaf ⇒ Object
readonly
Returns the value of attribute self_deaf.
-
#self_mute ⇒ Object
readonly
Returns the value of attribute self_mute.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#suppress ⇒ Object
readonly
Returns the value of attribute suppress.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Attributes inherited from Event
Instance Method Summary collapse
- #cached_channel(bot, channel_id, server) ⇒ Object
- #cached_server(bot, server_id) ⇒ Object
- #cached_user(bot, data) ⇒ Object
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def channel @channel end |
#channel_id ⇒ Integer? (readonly)
Returns the current voice channel ID, or nil if the user left voice.
15 16 17 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 15 def channel_id @channel_id end |
#deaf ⇒ Object (readonly)
Returns the value of attribute deaf.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def deaf @deaf end |
#mute ⇒ Object (readonly)
Returns the value of attribute mute.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def mute @mute end |
#old_channel ⇒ Channel? (readonly)
Returns the old channel this user was on, or nil if the user is newly joining voice.
12 13 14 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 12 def old_channel @old_channel end |
#old_channel_id ⇒ Integer? (readonly)
Returns the previous voice channel ID, or nil if the user joined voice.
18 19 20 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 18 def old_channel_id @old_channel_id end |
#self_deaf ⇒ Object (readonly)
Returns the value of attribute self_deaf.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def self_deaf @self_deaf end |
#self_mute ⇒ Object (readonly)
Returns the value of attribute self_mute.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def self_mute @self_mute end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def server @server end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def session_id @session_id end |
#suppress ⇒ Object (readonly)
Returns the value of attribute suppress.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def suppress @suppress end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def token @token end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def user @user end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
9 10 11 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 9 def user_id @user_id end |
Instance Method Details
#cached_channel(bot, channel_id, server) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 47 def cached_channel(bot, channel_id, server) return nil unless channel_id channels = bot.instance_variable_get(:@channels) channels&.[](channel_id.to_i) || server.channels.find { |channel| channel.id == channel_id.to_i } end |
#cached_server(bot, server_id) ⇒ Object
42 43 44 45 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 42 def cached_server(bot, server_id) servers = bot.instance_variable_get(:@servers) servers&.[](server_id.to_i) end |
#cached_user(bot, data) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/onyxcord/events/voice/state_update.rb', line 54 def cached_user(bot, data) user_data = data.dig('member', 'user') || data['user'] return bot.ensure_user(user_data) if user_data users = bot.instance_variable_get(:@users) users&.[](data['user_id'].to_i) end |