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?

Class Attribute Details

.privacy_level -> Object (readonly)

Returns the value of attribute privacy_level.



265
266
267
# File 'lib/discorb/voice_state.rb', line 265

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:



129
130
131
# File 'lib/discorb/voice_state.rb', line 129

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.



133
134
135
# File 'lib/discorb/voice_state.rb', line 133

def privacy_level
  @privacy_level
end

#topic -> String (readonly)

Returns The topic of the stage instance.

Returns:

  • (String)

    The topic of the stage instance.



131
132
133
# File 'lib/discorb/voice_state.rb', line 131

def topic
  @topic
end

Instance Method Details

#channel -> Object



169
170
171
# File 'lib/discorb/voice_state.rb', line 169

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

#delete(reason: nil) -> Async::Task<void> Also known as: destroy, end

Deletes the stage instance.

Parameters:

  • reason (String) (defaults to: nil)

    The reason for deleting the stage instance.

Returns:

  • (Async::Task<void>)

    The task.



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/discorb/voice_state.rb', line 232

def delete(reason: nil)
  Async do
    @client
      .http
      .request(
        Route.new(
          "/stage-instances/#{@channel_id}",
          "//stage-instances/:stage_instance_id",
          :delete
        ),
        {},
        audit_log_reason: reason
      )
      .wait
    self
  end
end

#discoverable? -> Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/discorb/voice_state.rb', line 173

def discoverable?
  !@discoverable_disabled
end

#edit(topic: Discorb::Unset, privacy_level: Discorb::Unset, reason: nil) -> Async::Task<void> Also known as: modify

Note:

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

Edits the stage instance.

Parameters:

  • topic (String) (defaults to: Discorb::Unset)

    The new topic of the stage instance.

  • privacy_level (:public, :guild_only) (defaults to: Discorb::Unset)

    The new privacy level of the stage instance.

  • reason (String) (defaults to: nil)

    The reason for editing the stage instance.

Returns:

  • (Async::Task<void>)

    The task.



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/discorb/voice_state.rb', line 200

def edit(topic: Discorb::Unset, privacy_level: Discorb::Unset, reason: nil)
  Async do
    payload = {}
    payload[:topic] = topic if topic != Discorb::Unset
    payload[:privacy_level] = PRIVACY_LEVEL.key(
      privacy_level
    ) if privacy_level != Discorb::Unset
    @client
      .http
      .request(
        Route.new(
          "/stage-instances/#{@channel_id}",
          "//stage-instances/:channel_id",
          :patch
        ),
        payload,
        audit_log_reason: reason
      )
      .wait
    self
  end
end

#guild -> Object



165
166
167
# File 'lib/discorb/voice_state.rb', line 165

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

#guild_only? -> Boolean

Returns:

  • (Boolean)


181
182
183
# File 'lib/discorb/voice_state.rb', line 181

def guild_only?
  @privacy_level == :guild_only
end

#inspect -> Object



185
186
187
# File 'lib/discorb/voice_state.rb', line 185

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

#public? -> Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/discorb/voice_state.rb', line 177

def public?
  @privacy_level == :public
end