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.



241
242
243
# File 'lib/discorb/voice_state.rb', line 241

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:



120
121
122
# File 'lib/discorb/voice_state.rb', line 120

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.



124
125
126
# File 'lib/discorb/voice_state.rb', line 124

def privacy_level
  @privacy_level
end

#topic -> String (readonly)

Returns The topic of the stage instance.

Returns:

  • (String)

    The topic of the stage instance.



122
123
124
# File 'lib/discorb/voice_state.rb', line 122

def topic
  @topic
end

Instance Method Details

#channel -> Object



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

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.



216
217
218
219
220
221
222
223
224
# File 'lib/discorb/voice_state.rb', line 216

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)


167
168
169
# File 'lib/discorb/voice_state.rb', line 167

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.



194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/discorb/voice_state.rb', line 194

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



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

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

#guild_only? -> Boolean

Returns:

  • (Boolean)


175
176
177
# File 'lib/discorb/voice_state.rb', line 175

def guild_only?
  @privacy_level == :guild_only
end

#inspect -> Object



179
180
181
# File 'lib/discorb/voice_state.rb', line 179

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

#public? -> Boolean

Returns:

  • (Boolean)


171
172
173
# File 'lib/discorb/voice_state.rb', line 171

def public?
  @privacy_level == :public
end