Class: Discorb::StageChannel
- Inherits:
-
GuildChannel
- Object
- DiscordModel
- Channel
- GuildChannel
- Discorb::StageChannel
- Includes:
- Connectable
- Defined in:
- lib/discorb/channel.rb
Overview
Represents a stage channel.
Instance Attribute Summary collapse
-
#bitrate -> Integer
readonly
The bitrate of the voice channel.
-
#user_limit -> Integer
readonly
The user limit of the voice channel.
Attributes inherited from GuildChannel
#permission_overwrites, #position
Attributes inherited from Channel
Instance Method Summary collapse
- #audiences -> Object
-
#edit(name: Discorb::Unset, position: Discorb::Unset, bitrate: Discorb::Unset, rtc_region: Discorb::Unset, reason: nil) -> Async::Task<self>
(also: #modify)
Edit the stage channel.
-
#fetch_stage_instance -> Async::Task<StageInstance>, Async::Task<nil>
Fetch a current stage instance.
- #members -> Object
- #speakers -> Object
- #stage_instance -> Object
-
#start(topic, public: false, reason: nil) -> Async::Task<Discorb::StageInstance>
Start a stage instance.
- #voice_states -> Object
Methods included from Connectable
Methods inherited from GuildChannel
#<=>, #==, #delete!, #guild, #inspect, #mention, #move, #parent, #to_s
Methods inherited from Channel
Methods inherited from DiscordModel
Instance Attribute Details
#bitrate -> Integer (readonly)
Returns The bitrate of the voice channel.
685 686 687 |
# File 'lib/discorb/channel.rb', line 685 def bitrate @bitrate end |
#user_limit -> Integer (readonly)
Returns The user limit of the voice channel.
687 688 689 |
# File 'lib/discorb/channel.rb', line 687 def user_limit @user_limit end |
Instance Method Details
#audiences -> Object
786 787 788 |
# File 'lib/discorb/channel.rb', line 786 def audiences voice_states.filter(&:suppress?).map(&:member) end |
#edit(name: Discorb::Unset, position: Discorb::Unset, bitrate: Discorb::Unset, rtc_region: Discorb::Unset, reason: nil) -> Async::Task<self> 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
.
Edit the stage channel.
726 727 728 729 730 731 732 733 734 735 736 |
# File 'lib/discorb/channel.rb', line 726 def edit(name: Discorb::Unset, position: Discorb::Unset, bitrate: Discorb::Unset, rtc_region: Discorb::Unset, reason: nil) Async do payload = {} payload[:name] = name if name != Discorb::Unset payload[:position] = position if position != Discorb::Unset payload[:bitrate] = bitrate if bitrate != Discorb::Unset payload[:rtc_region] = rtc_region if rtc_region != Discorb::Unset @client.http.request(Route.new("/channels/#{@id}", "//channels/:channel_id", :patch), payload, audit_log_reason: reason).wait self end end |
#fetch_stage_instance -> Async::Task<StageInstance>, Async::Task<nil>
Fetch a current stage instance.
764 765 766 767 768 769 770 771 772 |
# File 'lib/discorb/channel.rb', line 764 def fetch_stage_instance Async do _resp, data = @client.http.request(Route.new("/stage-instances/#{@id}", "//stage-instances/:stage_instance_id", :get)).wait rescue Discorb::NotFoundError nil else StageInstance.new(@client, data) end end |
#members -> Object
778 779 780 |
# File 'lib/discorb/channel.rb', line 778 def members voice_states.map(&:member) end |
#speakers -> Object
782 783 784 |
# File 'lib/discorb/channel.rb', line 782 def speakers voice_states.filter { |state| !state.suppress? }.map(&:member) end |
#stage_instance -> Object
709 710 711 |
# File 'lib/discorb/channel.rb', line 709 def stage_instance @stage_instances[0] end |
#start(topic, public: false, reason: nil) -> Async::Task<Discorb::StageInstance>
Start a stage instance.
750 751 752 753 754 755 |
# File 'lib/discorb/channel.rb', line 750 def start(topic, public: false, reason: nil) Async do _resp, data = @client.http.request(Route.new("/stage-instances", "//stage-instances", :post), { channel_id: @id, topic: topic, public: public ? 2 : 1 }, audit_log_reason: reason).wait StageInstance.new(@client, data) end end |
#voice_states -> Object
774 775 776 |
# File 'lib/discorb/channel.rb', line 774 def voice_states guild.voice_states.select { |state| state.channel&.id == @id } end |