【问题标题】:C# bot doesn't connect to voice channels (Discord.Net)C# bot 不连接到语音通道 (Discord.Net)
【发布时间】:2017-07-31 16:02:36
【问题描述】:

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

_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.
                });

我正在使用 discord.Net 0.9.6。

任何帮助将不胜感激,谢谢!

P.S 我有 Iaudio 代码:

        _client.UsingAudio(x =>
        {
            x.Mode = AudioMode.Outgoing;
        });

【问题讨论】:

  • 您遇到错误了吗?您是否尝试过将代码放在 try catch 子句中以查看是否有异常以获取更多详细信息?
  • 没有错误,机器人运行得很好,只是没有连接到 vc。我会试试你说的
  • 我试图做一个 try catch 子句,但我对 C# 很陌生,而且很累,我无法让它工作。 try{ 的结束括号始终连接到 MyBot 类 {
  • 看看我的回答。
  • 异步错误处理不是很直观bartread.com/2014/02/13/…

标签: c# discord discord.net


【解决方案1】:

因为编写代码作为注释看起来不太好,而且你在 try catch 时遇到的麻烦:

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

【讨论】:

  • 欢迎您。如果它有效,我会很高兴赞成;)
  • @CaramelPanda 您没有足够的声望来支持答案,但请通过单击绿色复选标记接受答案来感谢回答者。
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2022-01-05
    • 2018-01-04
    • 2020-02-19
    • 2021-04-29
    • 2020-12-06
    • 2018-07-25
    • 1970-01-01
    • 2021-08-05
    • 2020-05-31
    相关资源
    最近更新 更多