Class SocketVoiceChannel
Represents a WebSocket-based voice channel in a guild.
public class SocketVoiceChannel : SocketTextChannel, IUpdateable, ISocketMessageChannel, IVoiceChannel, ITextChannel, INestedChannel, IGuildChannel, IDeletable, IMentionable, IMessageChannel, ISocketAudioChannel, IAudioChannel, IChannel, IEntity<ulong>, IDisposable
- Inheritance
-
SocketVoiceChannel
- Implements
- Inherited Members
- Extension Methods
Properties
AudioClient
Gets the IAudioClient associated with this guild.
public IAudioClient? AudioClient { get; }
Property Value
ConnectedUsers
Gets a collection of users that are currently connected to this voice channel.
public IReadOnlyCollection<SocketGuildUser> ConnectedUsers { get; }
Property Value
- IReadOnlyCollection<SocketGuildUser>
A read-only collection of users that are currently connected to this voice channel.
Remarks
warning
This property may not always return all the members that are connected to this voice channel, because uses may connected this voice channel before the bot has connected to the gateway. To ensure accuracy, you may need to enable AlwaysDownloadVoiceStates to fetch the full voice states upon startup, or use DownloadVoiceStatesAsync(RequestOptions?) on the guild this voice channel belongs to to manually download the users voice states, or use GetConnectedUsersAsync(CacheMode, RequestOptions?) to fetch the connected users from the API.
HasPassword
Gets whether this voice channel is locked by a password.
public bool HasPassword { get; }
Property Value
- bool
A bool representing whether this voice channel is locked by a password.
IsVoiceRegionOverwritten
Gets whether the voice region of this audio channel is overwritten.
public bool? IsVoiceRegionOverwritten { get; }
Property Value
- bool?
ServerUrl
Gets the server url that clients should connect to to join this voice channel.
public string? ServerUrl { get; }
Property Value
- string
A string representing the url that clients should connect to to join this voice channel.
UserLimit
Gets the max number of users allowed to be connected to this channel at once.
public int UserLimit { get; }
Property Value
- int
An int representing the maximum number of users that are allowed to be connected to this channel at once;
0
if a limit is not set.
Users
Gets a collection of users that are able to view the channel.
public override IReadOnlyCollection<SocketGuildUser> Users { get; }
Property Value
- IReadOnlyCollection<SocketGuildUser>
A read-only collection of users that can access the channel (i.e. the users seen in the user list).
- See Also
VoiceQuality
Gets the voice quality that the clients in this voice channel are requested to use.
public VoiceQuality? VoiceQuality { get; }
Property Value
- VoiceQuality?
A VoiceQuality representing the voice quality that this voice channel defines and requests the client(s) to use.
VoiceRegion
Gets the voice region for this audio channel.
public string? VoiceRegion { get; }
Property Value
Remarks
warning
This property may be empty if the voice channel is created before this feature was released.
Methods
ConnectAsync(bool, bool, string?)
Connects to this audio channel.
public Task<IAudioClient?> ConnectAsync(bool external = false, bool disconnect = true, string? password = null)
Parameters
external
boolDetermines whether the audio client is an external one or not.
disconnect
boolDetermines whether the client should send a disconnect call before connecting to a new voice channel.
password
stringThe password to use when connecting to the audio channel.
Returns
- Task<IAudioClient>
A task representing the asynchronous connection operation. The task result contains the IAudioClient responsible for the connection.
DisconnectAsync()
Disconnects from this audio channel.
public Task DisconnectAsync()
Returns
- Task
A task representing the asynchronous operation for disconnecting from the audio channel.
GetConnectedUsersAsync(CacheMode, RequestOptions?)
Gets a collection of users that are currently connected to this voice channel.
public Task<IReadOnlyCollection<SocketGuildUser>> GetConnectedUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions? options = null)
Parameters
mode
CacheModeThe CacheMode that determines whether the object should be fetched from cache.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task<IReadOnlyCollection<SocketGuildUser>>
A task that represents the asynchronous get operation. The task result contains a read-only collection of users that are currently connected to this voice channel.
GetMessagesAsync(IMessage, Direction, int, RequestOptions?)
Gets a collection of messages in this channel.
public override IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage referenceMessage, Direction dir, int limit = 50, RequestOptions? options = null)
Parameters
referenceMessage
IMessageThe starting message to get the messages from.
dir
DirectionThe direction of the messages to be gotten from.
limit
intThe numbers of message to be gotten from.
options
RequestOptionsThe options to be used when sending the request.
Returns
- IAsyncEnumerable<IReadOnlyCollection<IMessage>>
Paged collection of messages.
Remarks
This method follows the same behavior as described in GetMessagesAsync(IMessage, Direction, int, CacheMode, RequestOptions?). Please visit its documentation for more details on this method.
Exceptions
- NotSupportedException
Getting messages from a voice channel is not supported.
GetMessagesAsync(Guid, Direction, int, RequestOptions?)
Gets a collection of messages in this channel.
public override IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(Guid referenceMessageId, Direction dir, int limit = 50, RequestOptions? options = null)
Parameters
referenceMessageId
GuidThe ID of the starting message to get the messages from.
dir
DirectionThe direction of the messages to be gotten from.
limit
intThe numbers of message to be gotten from.
options
RequestOptionsThe options to be used when sending the request.
Returns
- IAsyncEnumerable<IReadOnlyCollection<IMessage>>
Paged collection of messages.
Remarks
This method follows the same behavior as described in GetMessagesAsync(Guid, Direction, int, CacheMode, RequestOptions?). Please visit its documentation for more details on this method.
Exceptions
- NotSupportedException
Getting messages from a voice channel is not supported.
GetMessagesAsync(int, RequestOptions?)
Gets the last N messages from this message channel.
public override IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = 50, RequestOptions? options = null)
Parameters
limit
intThe numbers of message to be gotten from.
options
RequestOptionsThe options to be used when sending the request.
Returns
- IAsyncEnumerable<IReadOnlyCollection<IMessage>>
Paged collection of messages.
Remarks
This method follows the same behavior as described in GetMessagesAsync(int, CacheMode, RequestOptions?). Please visit its documentation for more details on this method.
Exceptions
- NotSupportedException
Getting messages from a voice channel is not supported.
GetUser(ulong)
Gets a SocketGuildUser from this channel.
public override SocketGuildUser? GetUser(ulong id)
Parameters
id
ulongThe user's identifier.
Returns
- SocketGuildUser
A SocketGuildUser with the provided identifier;
null
if none is found.
ModifyAsync(Action<ModifyVoiceChannelProperties>, RequestOptions?)
Modifies this voice channel.
public Task ModifyAsync(Action<ModifyVoiceChannelProperties> func, RequestOptions? options = null)
Parameters
func
Action<ModifyVoiceChannelProperties>The properties to modify the channel with.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous modification operation.
- See Also