Class: Discorb::StageInstance

Inherits:
DiscordModel show all
Defined in:
lib/discorb/voice_state.rb

Overview

Represents a stage instance of a voice state.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?, #hash

Class Attribute Details

.privacy_level -> Object (readonly)

Returns the value of attribute privacy_level.



216
217
218
# File 'lib/discorb/voice_state.rb', line 216

def privacy_level
  @privacy_level
end

Instance Attribute Details

#id -> Discorb::Snowflake (readonly)

Returns The ID of the guild this voice state is for.

Returns:



111
112
113
# File 'lib/discorb/voice_state.rb', line 111

def id
  @id
end

#privacy_level -> :public, :guild_only (readonly)

Returns The privacy level of the stage instance.

Returns:

  • (:public, :guild_only)

    The privacy level of the stage instance.



115
116
117
# File 'lib/discorb/voice_state.rb', line 115

def privacy_level
  @privacy_level
end

#topic -> String (readonly)

Returns The topic of the stage instance.

Returns:

  • (String)

    The topic of the stage instance.



113
114
115
# File 'lib/discorb/voice_state.rb', line 113

def topic
  @topic
end

Instance Method Details

#channel -> Object



147
148
149
# File 'lib/discorb/voice_state.rb', line 147

def channel
  @client.channels[@data[:channel_id]]
end

#delete!(reason: nil) -> Object Also known as: destroy!, end!

Deletes the stage instance.

Parameters:

  • reason (String) (defaults to: nil)

    The reason for deleting the stage instance.



194
195
196
197
198
199
# 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

#discoverable? -> Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/discorb/voice_state.rb', line 151

def discoverable?
  !@discoverable_disabled
end

#edit(topic: :unset, privacy_level: :unset, reason: nil) -> Object Also known as: modify

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Note:

The arguments of this method are defaultly set to :unset. Specify value to set the value, if not don't specify or specify :unset.

Edits the stage instance.

Parameters:

  • topic (String) (defaults to: :unset)

    The new topic of the stage instance.

  • privacy_level (:public, :guild_only) (defaults to: :unset)

    The new privacy level of the stage instance.

  • reason (String) (defaults to: nil)

    The reason for editing the stage instance.

Raises:



177
178
179
180
181
182
183
184
185
# 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

#guild -> Object



143
144
145
# File 'lib/discorb/voice_state.rb', line 143

def guild
  @client.guilds[@data[:guild_id]]
end

#guild_only? -> Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/discorb/voice_state.rb', line 159

def guild_only?
  @privacy_level == :guild_only
end

#inspect -> Object



163
164
165
# File 'lib/discorb/voice_state.rb', line 163

def inspect
  "#<#{self.class} topic=#{@topic.inspect}>"
end

#public? -> Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/discorb/voice_state.rb', line 155

def public?
  @privacy_level == :public
end