Class: Discorb::VoiceChannel

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

Overview

Represents a voice 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

#<=>, #==, #delete!, #guild, #inspect, #mention, #move, #parent, #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.



618
619
620
# File 'lib/discorb/channel.rb', line 618

def bitrate
  @bitrate
end

#user_limit -> Integer? (readonly)

Returns:

  • (Integer)

    The user limit of the voice channel.

  • (nil)

    If the user limit is not set.



621
622
623
# File 'lib/discorb/channel.rb', line 621

def user_limit
  @user_limit
end

Instance Method Details

#edit(name: Discorb::Unset, position: Discorb::Unset, bitrate: Discorb::Unset, user_limit: 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 voice channel.

Parameters:

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

    The name of the voice channel.

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

    The position of the voice channel.

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

    The bitrate of the voice channel.

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

    The user limit of the voice channel.

  • rtc_region (Symbol) (defaults to: Discorb::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.



645
646
647
648
649
650
651
652
653
654
655
656
657
# File 'lib/discorb/channel.rb', line 645

def edit(name: Discorb::Unset, position: Discorb::Unset, bitrate: Discorb::Unset, user_limit: 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[:user_limit] = user_limit if user_limit != 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

#members -> Object



665
666
667
# File 'lib/discorb/channel.rb', line 665

def members
  voice_states.map(&:member)
end

#voice_states -> Object



661
662
663
# File 'lib/discorb/channel.rb', line 661

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