class Discorb::StageInstance

Represents a stage instance of a voice state.

Attributes

privacy_level[R]
id[R]

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

privacy_level[R]

@return [:public, :guild_only] The privacy level of the stage instance.

topic[R]

@return [String] The topic of the stage instance.

Public Class Methods

new(client, data, no_cache: false) click to toggle source

@!visibility private

# File lib/discorb/voice_state.rb, line 136
def initialize(client, data, no_cache: false)
  @client = client
  @data = data
  _set_data(data)
  channel.stage_instances[@id] = self unless no_cache
end

Public Instance Methods

channel() click to toggle source
# File lib/discorb/voice_state.rb, line 147
def channel
  @client.channels[@data[:channel_id]]
end
delete!(reason: nil) click to toggle source

Deletes the stage instance.

@param [String] reason The reason for deleting the stage instance.

# File lib/discorb/voice_state.rb, line 194
def delete!(reason: nil)
  Async do
    @client.http.delete("/stage-instances/#{@channel_id}", reason: reason).wait
    self
  end
end
Also aliased as: destroy!, end!
destroy!(reason: nil)
Alias for: delete!
discoverable?() click to toggle source
# File lib/discorb/voice_state.rb, line 151
def discoverable?
  !@discoverable_disabled
end
edit(topic: :unset, privacy_level: :unset, reason: nil) click to toggle source

Edits the stage instance. @macro async @macro http @macro edit

@param [String] topic The new topic of the stage instance. @param [:public, :guild_only] privacy_level The new privacy level of the stage instance. @param [String] reason The reason for editing the stage instance.

# File lib/discorb/voice_state.rb, line 177
def edit(topic: :unset, privacy_level: :unset, reason: nil)
  Async do
    payload = {}
    payload[:topic] = topic if topic != :unset
    payload[:privacy_level] = self.class.privacy_level.key(privacy_level) if privacy_level != :unset
    @client.http.edit("/stage-instances/#{@channel_id}", payload, audit_log_reason: reason).wait
    self
  end
end
Also aliased as: modify
end!(reason: nil)
Alias for: delete!
guild() click to toggle source
# File lib/discorb/voice_state.rb, line 143
def guild
  @client.guilds[@data[:guild_id]]
end
guild_only?() click to toggle source
# File lib/discorb/voice_state.rb, line 159
def guild_only?
  @privacy_level == :guild_only
end
inspect() click to toggle source
# File lib/discorb/voice_state.rb, line 163
def inspect
  "#<#{self.class} topic=#{@topic.inspect}>"
end
modify(topic: :unset, privacy_level: :unset, reason: nil)
Alias for: edit
public?() click to toggle source
# File lib/discorb/voice_state.rb, line 155
def public?
  @privacy_level == :public
end

Private Instance Methods

_set_data(data) click to toggle source
# File lib/discorb/voice_state.rb, line 206
def _set_data(data)
  @id = Snowflake.new(data[:id])
  @guild_id = Snowflake.new(data[:guild_id])
  @channel_id = Snowflake.new(data[:channel_id])
  @topic = data[:topic]
  @privacy_level = self.class.privacy_level[data[:privacy_level]]
  @discoverable_disabled = data[:discoverable_disabled]
end