#ConnectAsync() returns null
1 messages · Page 1 of 1 (latest)
method:
full code:
Installed packages:
Discord.Net 3.8.1
Microsoft.Extensions.DependencyInjection 7.0.0
screenshot from \hk417\bin\Debug\net6.0
@frozen burrow
First of all, I don't think you need to set external to true.
Secondly, try doing it the way that the documentation example does it (https://discordnet.dev/guides/voice/sending-voice.html)
private async Task SlashCommandHandler(SocketSlashCommand command)
{
if (command.CommandName == "name")
{
var channel = (command.User as IGuildUser)?.VoiceChannel;
using (var ffmpeg = CreateStream("C:\audiofile.mp3"))
using (var output = ffmpeg.StandardOutput.BaseStream)
using (var discord = client.CreatePCMStream(AudioApplication.Mixed))
{
try { await output.CopyToAsync(discord); }
finally { await discord.FlushAsync(); }
}
}
}
private Process CreateStream(string path)
{
return Process.Start(new ProcessStartInfo
{
FileName = "ffmpeg",
Arguments = $"-hide_banner -loglevel panic -i \"{path}\" -ac 2 -f s16le -ar 48000 pipe:1",
UseShellExecute = false,
RedirectStandardOutput = true,
});
}
Third, although unrelated to your question, you do not need all the files for libopus/libsodium. You only need the two binary files, libopus.dll and libsodium.dll. You can delete the rest
Thanks, but:
Compiler Error CS1061
'DiscordSocketClient' does not contain a definition for 'CreatePCMStream' and no accessible extension method 'CreatePCMStream' accepting a first argument of type 'DiscordSocketClient' could be found (are you missing a using directive or an assembly reference?).
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1061?f1url=%3FappId%3Droslyn%26k%3Dk(CS1061)
If I use audioClient without external:true bot joins to voice and doesnt execute any code until it disconnects with this error