class Discorb::VoiceState

Attributes

live?[R]

@return [Boolean] Whether the user is streaming.

member[R]

@return [Discorb::Member] The member associated with this voice state.

request_to_speak_timestamp[R]

@return [Time] The time at which the user requested to speak.

self_deaf[R]

@return [Boolean] Whether the user is deafened.

self_deaf?[R]

@return [Boolean] Whether the user is deafened.

self_mute[R]

@return [Boolean] Whether the user is muted.

self_mute?[R]

@return [Boolean] Whether the user is muted.

self_stream[R]

@return [Boolean] Whether the user is streaming.

self_video[R]

@return [Boolean] Whether the user is video-enabled.

session_id[R]

@return [Discorb::Snowflake] The ID of the guild this voice state is for.

stream?[R]

@return [Boolean] Whether the user is streaming.

suppress[R]

@return [Boolean] Whether the user is suppressed. (Is at audience)

suppress?[R]

@return [Boolean] Whether the user is suppressed. (Is at audience)

video?[R]

@return [Boolean] Whether the user is video-enabled.

Public Class Methods

new(client, data) click to toggle source

@!visibility private

# File lib/discorb/voice_state.rb, line 47
def initialize(client, data)
  @client = client
  _set_data(data)
end

Public Instance Methods

channel() click to toggle source
# File lib/discorb/voice_state.rb, line 72
def channel
  @channel_id && @client.channels[@channel_id]
end
deaf?() click to toggle source
# File lib/discorb/voice_state.rb, line 52
def deaf?
  @deaf || @self_deaf
end
guild() click to toggle source
# File lib/discorb/voice_state.rb, line 68
def guild
  @guild_id && @client.guilds[@guild_id]
end
mute?() click to toggle source
# File lib/discorb/voice_state.rb, line 56
def mute?
  @mute || @self_mute
end
server_deaf?() click to toggle source
# File lib/discorb/voice_state.rb, line 60
def server_deaf?
  @deaf
end
server_mute?() click to toggle source
# File lib/discorb/voice_state.rb, line 64
def server_mute?
  @mute
end
user() click to toggle source
# File lib/discorb/voice_state.rb, line 76
def user
  @client.users[@user_id]
end

Private Instance Methods

_set_data(data) click to toggle source
# File lib/discorb/voice_state.rb, line 82
def _set_data(data)
  @data = data
  @guild_id = data[:guild_id]
  @channel_id = data[:channel_id]
  @user_id = data[:user_id]
  unless guild.nil?
    @member = if data.key?(:member)
        guild.members[data[:user_id]] || Member.new(@client, @guild_id, data[:member][:user], data[:member])
      else
        guild.members[data[:user_id]]
      end
  end
  @session_id = data[:session_id]
  @deaf = data[:deaf]
  @mute = data[:mute]
  @self_deaf = data[:self_deaf]
  @self_mute = data[:self_mute]
  @self_stream = data[:self_stream]
  @self_video = data[:self_video]
  @suppress = data[:suppress]
  @request_to_speak_timestamp = data[:request_to_speak_timestamp] && Time.iso8601(data[:request_to_speak_timestamp])
end