Class: RubyCord::Guild::VoiceChannel

Inherits:
Channel show all
Includes:
Internal::Connectable, Internal::Messageable
Defined in:
lib/rubycord/guild/channel/voice.rb,
lib/rubycord/guild/channel/voice/voice_state.rb

Defined Under Namespace

Classes: VoiceState

Instance Attribute Summary collapse

Attributes inherited from Channel

#permission_overwrites, #position

Attributes inherited from Channel

#id, #name

Instance Method Summary collapse

Methods included from Internal::Messageable

#delete_message, #edit_message, #fetch_message, #fetch_messages, #fetch_pins, #pin_message, #post, #typing, #unpin_message

Methods included from Internal::Connectable

#connect

Methods inherited from Channel

#<=>, #==, #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

#bitrateInteger (readonly)

Returns The bitrate of the voice channel.

Returns:

  • (Integer)

    The bitrate of the voice channel.



13
14
15
# File 'lib/rubycord/guild/channel/voice.rb', line 13

def bitrate
  @bitrate
end

#user_limitInteger? (readonly)

Returns:

  • (Integer)

    The user limit of the voice channel.

  • (nil)

    If the user limit is not set.



16
17
18
# File 'lib/rubycord/guild/channel/voice.rb', line 16

def user_limit
  @user_limit
end

Instance Method Details

#edit(name: RubyCord::Unset, position: RubyCord::Unset, bitrate: RubyCord::Unset, user_limit: RubyCord::Unset, rtc_region: RubyCord::Unset, reason: nil) ⇒ Async::Task<self> Also known as: modify

Note:

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

Edit the voice channel.

Parameters:

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

    The name of the voice channel.

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

    The position of the voice channel.

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

    The bitrate of the voice channel.

  • user_limit (Integer) (defaults to: RubyCord::Unset)

    The user limit of the voice channel.

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

    The region of the voice channel.

  • reason (String) (defaults to: nil)

    The reason of editing the voice channel.

Returns:

  • (Async::Task<self>)

    The edited voice channel.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rubycord/guild/channel/voice.rb', line 38

def edit(
  name: RubyCord::Unset,
  position: RubyCord::Unset,
  bitrate: RubyCord::Unset,
  user_limit: RubyCord::Unset,
  rtc_region: RubyCord::Unset,
  reason: nil
)
  Async do
    payload = {}
    payload[:name] = name if name != RubyCord::Unset
    payload[:position] = position if position != RubyCord::Unset
    payload[:bitrate] = bitrate if bitrate != RubyCord::Unset
    payload[:user_limit] = user_limit if user_limit != RubyCord::Unset
    payload[:rtc_region] = rtc_region if rtc_region != RubyCord::Unset

    @client
      .http
      .request(
        RubyCord::Internal::Route.new("/channels/#{@id}", "//channels/:channel_id", :patch),
        payload,
        audit_log_reason: reason
      )
      .wait
    self
  end
end

#membersArray<RubyCord::Guild::Member>

Returns:



74
75
76
# File 'lib/rubycord/guild/channel/voice.rb', line 74

def members
  voice_states.map(&:member)
end

#voice_statesArray<RubyCord::Guild::VoiceChannel::VoiceState>



69
70
71
# File 'lib/rubycord/guild/channel/voice.rb', line 69

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