26 lines
789 B
C#
26 lines
789 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Discord;
|
|
using Discord.WebSocket;
|
|
|
|
public static class VocalManager
|
|
{
|
|
public static async Task ConnectToVoiceChannelAsync(DiscordSocketClient client, ulong guildId, ulong vocalId)
|
|
{
|
|
var guild = client.GetGuild(guildId);
|
|
if (guild == null)
|
|
{
|
|
throw new InvalidOperationException($"Guild with ID {guildId} not found.");
|
|
}
|
|
|
|
var channel = guild.GetVoiceChannel(vocalId);
|
|
if (channel == null)
|
|
{
|
|
throw new InvalidOperationException($"Voice channel with ID {vocalId} not found.");
|
|
}
|
|
|
|
await channel.ConnectAsync();
|
|
Console.WriteLine($"[Voice] Successfully connected to voice channel '{channel.Name}' in guild '{guild.Name}'.");
|
|
}
|
|
}
|