Module: Discorb::Voice::ClientVoicePrepend
- Included in:
- Client
- Defined in:
- lib/discorb/voice/extend.rb
Instance Attribute Summary collapse
-
#voice_conditions ⇒ Object
readonly
Returns the value of attribute voice_conditions.
-
#voice_mutexes ⇒ Object
readonly
Returns the value of attribute voice_mutexes.
Instance Method Summary collapse
- #connect_to(channel) ⇒ Object
- #disconnect_voice(guild_id) ⇒ Object
- #event_voice_server_update(data) ⇒ Object
- #initialize ⇒ Object
Instance Attribute Details
#voice_conditions ⇒ Object (readonly)
Returns the value of attribute voice_conditions.
8 9 10 |
# File 'lib/discorb/voice/extend.rb', line 8 def voice_conditions @voice_conditions end |
#voice_mutexes ⇒ Object (readonly)
Returns the value of attribute voice_mutexes.
9 10 11 |
# File 'lib/discorb/voice/extend.rb', line 9 def voice_mutexes @voice_mutexes end |
Instance Method Details
#connect_to(channel) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/discorb/voice/extend.rb', line 35 def connect_to(channel) Async do @logger.debug("Connecting to #{channel.id}") send_gateway( 4, guild_id: channel.guild.id.to_s, channel_id: channel.id.to_s, self_mute: channel.guild.me.voice_state&.self_mute?, self_deaf: channel.guild.me.voice_state&.self_deaf?, ) condition = Async::Condition.new @voice_conditions[channel.guild.id.to_s] = condition condition.wait end end |
#disconnect_voice(guild_id) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/discorb/voice/extend.rb', line 26 def disconnect_voice(guild_id) send_gateway( 4, guild_id: guild_id, channel_id: nil, ) end |
#event_voice_server_update(data) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/discorb/voice/extend.rb', line 18 def event_voice_server_update(data) @logger.debug("Received VOICE_SERVER_UPDATE") client = Discorb::Voice::Client.new(self, data) @voice_clients[data[:guild_id]] = client client.connect_condition.wait @voice_conditions[data[:guild_id]].signal client end |
#initialize ⇒ Object
11 12 13 14 15 16 |
# File 'lib/discorb/voice/extend.rb', line 11 def initialize(*, **) super @voice_clients = Discorb::Dictionary.new @voice_conditions = {} @voice_mutexes = {} end |