discord.net c#bot退出语音频道
机器人进入并立即退出语音频道。同时,如果语音聊天中没有人,那么机器人将悄悄留在那里。如果有的话,我下载了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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我刚刚构建了该应用程序,并在Opus和libsodium库中扔了
Ok, I just built the application and threw in the opus and libsodium library, and it worked