C#bot不';t连接到语音频道(Discord.Net)

C#bot不';t连接到语音频道(Discord.Net),c#,discord,discord.net,C#,Discord,Discord.net,如标题中所述,我似乎无法让我的机器人加入我的discord中的语音频道。 命令的代码为: _commands.CreateCommand("join") .Description("Makes the bot join the first or default voice channel.") .Do(async (e) => { await e.Chan

如标题中所述,我似乎无法让我的机器人加入我的discord中的语音频道。 命令的代码为:

_commands.CreateCommand("join")
                .Description("Makes the bot join the first or default voice channel.")
                .Do(async (e) =>
                {
                    await e.Channel.SendIsTyping();
                    var voiceChannel = _client.FindServers("mealroom V2").FirstOrDefault().VoiceChannels.FirstOrDefault(); // Finds the first VoiceChannel on the server 'Music Bot Server'

                    var _vClient = await _client.GetService<AudioService>() // We use GetService to find the AudioService that we installed earlier. In previous versions, this was equivelent to _client.Audio()
                            .Join(VoiceChannel); // Join the Voice Channel, and return the IAudioClient.
                });

因为编写代码作为注释看起来不太好,而且您在try-catch方面遇到了麻烦:

try
{
    //your code here
}
catch(Exception exception)
{
    //error handling or breakpoint to check the exception
}

您需要具有最新的libnaude.dll和opus.dll,bot才能加入频道,否则bot将无法连接到语音频道。我有一个与您的命令完全相同的命令,它可以正常工作,如果我删除这两个命令,或者可能使它们过时,bot将不会加入。

您有错误吗?您是否尝试过将代码放入try-catch子句中,以查看是否出现异常以了解更多详细信息?没有错误,bot运行得非常好,只是没有连接到vc。我会照你说的去做,我试着做一个try-catch子句,但我对C#还是很陌生,而且很累,我无法让它工作。try{always connected to class MyBot{的结束括号请查看我的答案。异步错误处理不是很直观,欢迎您。如果它起作用,我会很高兴向上投票;)@CaramelPanda您没有足够的声誉来向上投票答案,但通过单击绿色复选标记接受答案来感谢回答者。
try
{
    //your code here
}
catch(Exception exception)
{
    //error handling or breakpoint to check the exception
}