Class: Discorb::StageChannel

Inherits:
GuildChannel show all
Defined in:
lib/discorb/channel.rb

Overview

Represents a stage channel.

Instance Attribute Summary collapse

Attributes inherited from GuildChannel

#permission_overwrites, #position

Attributes inherited from Channel

#id, #name

Instance Method Summary collapse

Methods inherited from GuildChannel

#<=>, #==, #delete!, #guild, #inspect, #mention, #move, #parent, #to_s

Methods inherited from Channel

#==, #inspect, #type

Methods inherited from DiscordModel

#==, #eql?, #hash

Instance Attribute Details

#bitrate -> Integer (readonly)

Returns The bitrate of the voice channel.

Returns:

  • (Integer)

    The bitrate of the voice channel.



696
697
698
# File 'lib/discorb/channel.rb', line 696

def bitrate
  @bitrate
end

#user_limit -> Integer (readonly)

Returns The user limit of the voice channel.

Returns:

  • (Integer)

    The user limit of the voice channel.



698
699
700
# File 'lib/discorb/channel.rb', line 698

def user_limit
  @user_limit
end

Instance Method Details

#edit(name: :unset, position: :unset, bitrate: :unset, rtc_region: :unset, reason: nil) -> self 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.

Edit the stage channel.

Parameters:

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

    The name of the stage channel.

  • position (Integer) (defaults to: :unset)

    The position of the stage channel.

  • bitrate (Integer) (defaults to: :unset)

    The bitrate of the stage channel.

  • rtc_region (Symbol) (defaults to: :unset)

    The region of the stage channel.

  • reason (String) (defaults to: nil)

    The reason of editing the stage channel.

Returns:

  • (self)

    The edited stage channel.

Raises:



730
731
732
733
734
735
736
737
738
739
740
# File 'lib/discorb/channel.rb', line 730

def edit(name: :unset, position: :unset, bitrate: :unset, rtc_region: :unset, reason: nil)
  Async do
    payload = {}
    payload[:name] = name if name != :unset
    payload[:position] = position if position != :unset
    payload[:bitrate] = bitrate if bitrate != :unset
    payload[:rtc_region] = rtc_region if rtc_region != :unset
    @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
    self
  end
end

#fetch_stage_instance -> StageInstance?

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.

Fetch a current stage instance.

Returns:

  • (StageInstance)

    The current stage instance.

  • (nil)

    If there is no current stage instance.

Raises:



770
771
772
773
774
775
776
777
778
# File 'lib/discorb/channel.rb', line 770

def fetch_stage_instance
  Async do
    _resp, data = @client.http.get("/stage-instances/#{@id}").wait
  rescue Discorb::NotFoundError
    nil
  else
    StageInstance.new(@client, data)
  end
end

#stage_instance -> Object



712
713
714
# File 'lib/discorb/channel.rb', line 712

def stage_instance
  @stage_instances[0]
end

#start(topic, public: false, reason: nil) -> Discorb::StageInstance

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.

Start a stage instance.

Parameters:

  • topic (String)

    The topic of the stage instance.

  • public (Boolean) (defaults to: false)

    Whether the stage instance is public or not.

  • reason (String) (defaults to: nil)

    The reason of starting the stage instance.

Returns:

Raises:



755
756
757
758
759
760
# File 'lib/discorb/channel.rb', line 755

def start(topic, public: false, reason: nil)
  Async do
    _resp, data = @client.http.post("/stage-instances", { channel_id: @id, topic: topic, public: public ? 2 : 1 }, audit_log_reason: reason).wait
    StageInstance.new(@client, data)
  end
end