当前位置: 首页>>代码示例>>C#>>正文


C# DiscordClient.UsingAudio方法代码示例

本文整理汇总了C#中Discord.DiscordClient.UsingAudio方法的典型用法代码示例。如果您正苦于以下问题:C# DiscordClient.UsingAudio方法的具体用法?C# DiscordClient.UsingAudio怎么用?C# DiscordClient.UsingAudio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Discord.DiscordClient的用法示例。


在下文中一共展示了DiscordClient.UsingAudio方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Startup

        internal static void Startup(DiscordClient c)
        {
            c.UsingAudio(x =>
            {
                x.Mode = AudioMode.Outgoing;
                x.EnableEncryption = true;
            });

            Music.Load(c);
        }
开发者ID:Kusoneko,项目名称:Nekobot,代码行数:10,代码来源:Voice.cs

示例2: ShowDialog

        public override async void ShowDialog()
        {
            LoginDialog dialog = new LoginDialog();

            if (dialog.ShowDialog() == true)
            {
                _client = new DiscordClient();
                _client.UsingAudio(x =>
                {
                    x.Mode = AudioMode.Outgoing;
                    x.Bitrate = null;
                    x.Channels = 2;
                });

                await _client.Connect(dialog.Username, dialog.Password);
                var voiceChannel = CurrentServer.VoiceChannels.FirstOrDefault(d => d.Name == "Bot Test");

                _voiceClient = await _client.GetService<AudioService>()
                    .Join(voiceChannel);
            }
        }
开发者ID:jmazouri,项目名称:Picofy,代码行数:21,代码来源:PicofyDiscord.cs

示例3: Start

        public void Start()
        {
            Console.WriteLine("Initializing...");
            _client = new DiscordClient();

            _client.UsingAudio(x => // Opens an AudioConfigBuilder so we can configure our AudioService
            { x.Mode = AudioMode.Outgoing; // Tells the AudioService that we will only be sending audio
            });

            // _vClient = _client.GetService<AudioService>();

            _client.MessageReceived += async (s, e) =>
            {
                if (!e.Message.IsAuthor)
                {
                    Console.WriteLine(e.Message.User.Name + "> " + e.Message.Text);
                    if (e.Message.Text.StartsWith("!!"))
                    {
                        string command = e.Message.Text.Replace("!!", "");
                        //   if (command.Equals(""))
                        //      {
                        //                 await e.Channel.SendMessage("I am Jukebot. Do !!info for more details.");
                        //
                        //          }
                        string[] words = command.Split(' ');
                        switch (words[0])
                        {
                            case "info":
                                await
                                    e.Channel.SendMessage(
                                        "```diff\n!====== [Jukebot] ======!" +
                                        "\nA shitty ass music bot made by Ratismal (stupid cat)" +
                                        "\nIt plays music. lol what did u expect" +
                                        "\n!== [Features] ==!" +
                                        "\n+ a shitty looking unintuitive piece of shit GUI that only the host can see (lol)" +
                                        "\n+ plays music" +
                                        "\n!== [Commands] ==!" +
                                        "\n+ !!info - shows this" +
                                        "\n+ !!summon - summons bot to current voice channel" +
                                        "\n+ !!banish - tells the bot to piss off" +
                                        "\n+ !!volume - shows the current volume" +
                                        "\n+ !!volume <amount> - set the volume" +
                                        "\n+ !!volume +-<amount> - add/subtract the volume" +
                                        "\n!== [Conclusi] ==!" +
                                        "\n+ '-on' cut off from title for consistancy spacing sake" +
                                        "\n+ fuck my life" +
                                        "\n+ you want to play something? GOOD LUCK WITH THAT LOL ONLY I CAN" +
                                        "\n- This is red text!" +
                                        "\n- its really late i should go to bed lol fml smfh lmao kms" +
                                        "\n```");
                                break;
                            case "summon":
                                Console.WriteLine("Joining a voice channel");
                                await e.Channel.SendMessage("Joining channel");
                                var voiceChannel = e.User.VoiceChannel;
                                _vClient = await _client.GetService<AudioService>().Join(voiceChannel);
                                //await _vClient.Join(voiceChannel);
                                break;
                            case "banish":
                                Console.WriteLine("Leaving a voice channel");

                                await e.Channel.SendMessage("Leaving channel");
                                await _client.GetService<AudioService>().Leave(e.Server);
                                break;
                            case "volume":
                                if (words.Length == 1)
                                {
                                    e.Channel.SendMessage("Current volume: " + MainWindow.volume);
                                }
                                else
                                {
                                    //  string goodstuff;
                                    if (words[1].StartsWith("+") || words[1].StartsWith("-"))
                                    {
                                        int addVolume = Int32.Parse(words[1]);
                                        MainWindow.volume += addVolume;
                                        e.Channel.SendMessage("New volume: " + MainWindow.volume);
                                    }
                                    else
                                    {
                                        MainWindow.volume = Int32.Parse(words[1]);
                                        e.Channel.SendMessage("New volume: " + MainWindow.volume);
                                    }
                                }

                                break;
                            default:
                                await e.Channel.SendMessage("I am Jukebot. Do !!info for more details.");
                                break;
                        }
                    }
                }
            };

            _client.ExecuteAndWait(async () =>
            {
                await
                    _client.Connect(token
                        );
            });
//.........这里部分代码省略.........
开发者ID:Ratismal,项目名称:jukebot,代码行数:101,代码来源:MainWindow.xaml.cs


注:本文中的Discord.DiscordClient.UsingAudio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。