Class: Discorb::StageChannel

Inherits:
GuildChannel show all
Includes:
Connectable
Defined in:
lib/discorb/channel/stage.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 included from Connectable

#connect

Methods inherited from GuildChannel

#<=>, #==, #create_invite, #delete, #delete_permissions, #fetch_invites, #guild, #inspect, #mention, #move, #parent, #set_permissions, #to_s

Methods inherited from Channel

#==, #inspect, #type

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Attribute Details

#bitrate -> Integer (readonly)

Returns The bitrate of the voice channel.

Returns:

  • (Integer)

    The bitrate of the voice channel.



9
10
11
# File 'lib/discorb/channel/stage.rb', line 9

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.



11
12
13
# File 'lib/discorb/channel/stage.rb', line 11

def user_limit
  @user_limit
end

Instance Method Details

#audiences -> Object



142
143
144
# File 'lib/discorb/channel/stage.rb', line 142

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.

Parameters:

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

    The name of the stage channel.

  • position (Integer) (defaults to: Discorb::Unset)

    The position of the stage channel.

  • bitrate (Integer) (defaults to: Discorb::Unset)

    The bitrate of the stage channel.

  • rtc_region (Symbol) (defaults to: Discorb::Unset)

    The region of the stage channel.

  • reason (String) (defaults to: nil)

    The reason of editing the stage channel.

Returns:

  • (Async::Task<self>)

    The edited stage channel.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/discorb/channel/stage.rb', line 51

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.

Returns:

  • (Async::Task<StageInstance>)

    The current stage instance.

  • (Async::Task<nil>)

    If there is no current stage instance.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/discorb/channel/stage.rb', line 110

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



134
135
136
# File 'lib/discorb/channel/stage.rb', line 134

def members
  voice_states.map(&:member)
end

#speakers -> Object



138
139
140
# File 'lib/discorb/channel/stage.rb', line 138

def speakers
  voice_states.reject(&:suppress?).map(&:member)
end

#stage_instance -> Object



34
35
36
# File 'lib/discorb/channel/stage.rb', line 34

def stage_instance
  @stage_instances[0]
end

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

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:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/discorb/channel/stage.rb', line 88

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



130
131
132
# File 'lib/discorb/channel/stage.rb', line 130

def voice_states
  guild.voice_states.select { |state| state.channel&.id == @id }
end