Discord.NET を利用した Voice Channel に対する音声データ再生
DRANK

友人に「Bot で Voice Channel に音楽流せない?」と相談を受けました。Discord Bot で音声を扱う実装はしたことがなく、気になったのでパパッと調べてみました。覚書ということで丁寧な解説などはありません。事前準備Discord.Audio を利用するためには ibsodium.dll と opus.dll を実行時フォルダ (= パスが通ったところ) に置いておく必要があります。これは Discord.NET のドキュメントにも明記されています。Audio requires two native libraries, libsodium and opus. Both of these libraries must be placed in the runtime directory of your bot. (When developing on .NET Framework, this would be bin/debug, when developing on .NET Core, this is where you execute dotnet run from; typically the same directory as your csproj).特にドキュメントも読まずに実装して、いざ実行しようとしたら「opus.dll がない」と怒られ続けてしばらく悩みました。ドキュメントはちゃんと読みましょう。実装Step.1 : Voice Channel への接続Discord API への接続処理などは割愛し、Voice Channel に参加して音声データを流す部分だけをピックアップします。 DiscordSock…

zenn.dev
Related Topics: