discord.net c#bot退出语音频道

发布于 2025-02-08 08:42:30 字数 1947 浏览 3 评论 0原文

机器人进入并立即退出语音频道。同时,如果语音聊天中没有人,那么机器人将悄悄留在那里。如果有的话,我下载了opus.dll并将其与exe文件一起放置,我不知道问题出在哪里。请帮忙。

错误,

20:54:58 App Command System.BadImageFormatException: An attempt was made to load a program with an invalid format. (0x8007000B)
   at Discord.Audio.OpusDecoder.CreateDecoder(Int32 Fs, Int32 channels, OpusError& error)
   at Discord.Audio.OpusDecoder..ctor()
   at Discord.Audio.Streams.OpusDecodeStream..ctor(AudioStream next)
   at Discord.Audio.AudioClient.CreateInputStreamAsync(UInt64 userId)
   at Discord.WebSocket.SocketGuild.RepopulateAudioStreamsAsync()
   at Discord.WebSocket.SocketGuild.FinishConnectAudio(String url, String token)
   at Discord.WebSocket.SocketGuild.ConnectAudioAsync(UInt64 channelId, Boolean selfDeaf, Boolean selfMute, Boolean external)
   at Discord.WebSocket.SocketGuild.ConnectAudioAsync(UInt64 channelId, Boolean selfDeaf, Boolean selfMute, Boolean external)
   at Discord.WebSocket.SocketVoiceChannel.ConnectAsync(Boolean selfDeaf, Boolean selfMute, Boolean external)
   at discord_bot.Modules.ExampleCommands.JoinChannel(IVoiceChannel channel) in C:\Users\hybas\source\repos\discord-bot\discord-bot\Modules\ExampleCommands.cs:line 58
   at Discord.Interactions.Builders.ModuleClassBuilder.<>c__DisplayClass11_0.<<CreateCallback>g__ExecuteCallback|1>d.MoveNext()

我拿了代码以连接到官方ciscord.net文档的语音聊天

[Command("join", RunMode = RunMode.Async)] 
public async Task JoinChannel(IVoiceChannel channel = null)
{
    // Get the audio channel
    channel = channel ?? (Context.User as IGuildUser)?.VoiceChannel;
    if (channel == null) { await Context.Channel.SendMessageAsync("User must be in a voice channel, or a voice channel must be passed as an argument."); return; }

    // For the next step with transmitting audio, you would want to pass this Audio Client in to a service.
    var audioClient = await channel.ConnectAsync();
}

The bot enters and immediately exits the voice channel. At the same time, if there is no one in the voice chat, then the bot will quietly remain there. If anything, I downloaded opus.dll and put it along with the exe file, and I don’t know what the problem is. Please help.

Error

20:54:58 App Command System.BadImageFormatException: An attempt was made to load a program with an invalid format. (0x8007000B)
   at Discord.Audio.OpusDecoder.CreateDecoder(Int32 Fs, Int32 channels, OpusError& error)
   at Discord.Audio.OpusDecoder..ctor()
   at Discord.Audio.Streams.OpusDecodeStream..ctor(AudioStream next)
   at Discord.Audio.AudioClient.CreateInputStreamAsync(UInt64 userId)
   at Discord.WebSocket.SocketGuild.RepopulateAudioStreamsAsync()
   at Discord.WebSocket.SocketGuild.FinishConnectAudio(String url, String token)
   at Discord.WebSocket.SocketGuild.ConnectAudioAsync(UInt64 channelId, Boolean selfDeaf, Boolean selfMute, Boolean external)
   at Discord.WebSocket.SocketGuild.ConnectAudioAsync(UInt64 channelId, Boolean selfDeaf, Boolean selfMute, Boolean external)
   at Discord.WebSocket.SocketVoiceChannel.ConnectAsync(Boolean selfDeaf, Boolean selfMute, Boolean external)
   at discord_bot.Modules.ExampleCommands.JoinChannel(IVoiceChannel channel) in C:\Users\hybas\source\repos\discord-bot\discord-bot\Modules\ExampleCommands.cs:line 58
   at Discord.Interactions.Builders.ModuleClassBuilder.<>c__DisplayClass11_0.<<CreateCallback>g__ExecuteCallback|1>d.MoveNext()

I took the code for connecting to voice chat from the official Discord.NET documentation

[Command("join", RunMode = RunMode.Async)] 
public async Task JoinChannel(IVoiceChannel channel = null)
{
    // Get the audio channel
    channel = channel ?? (Context.User as IGuildUser)?.VoiceChannel;
    if (channel == null) { await Context.Channel.SendMessageAsync("User must be in a voice channel, or a voice channel must be passed as an argument."); return; }

    // For the next step with transmitting audio, you would want to pass this Audio Client in to a service.
    var audioClient = await channel.ConnectAsync();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独夜无伴 2025-02-15 08:42:30

好的,我刚刚构建了该应用程序,并在Opus和libsodium库中扔了

Ok, I just built the application and threw in the opus and libsodium library, and it worked

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文