コード例 #1
0
ファイル: AudioService.cs プロジェクト: ZitaRR/Nix
        private async Task OnReady()
        {
            if (!lavaNode.IsConnected)
            {
                await lavaNode.ConnectAsync();
            }

            if (data.Count <= 0)
            {
                return;
            }

            foreach (KeyValuePair <ulong, LavalinkData> data in data)
            {
                await lavaNode.LeaveAsync(data.Value.VoiceChannel);

                NixPlayer player = await CreatePlayerForGuildAsync(
                    data.Value.VoiceChannel.Guild,
                    data.Value.VoiceChannel,
                    data.Value.TextChannel);

                players.TryAdd(data.Key, player);
                await player.PlayAsync(data.Value);
            }

            data.Clear();
        }
コード例 #2
0
ファイル: AudioService.cs プロジェクト: ZitaRR/Nix
 public bool TryGetPlayer(IGuild guild, out NixPlayer player)
 {
     if (!players.TryGetValue(guild.Id, out player))
     {
         return(false);
     }
     return(true);
 }
コード例 #3
0
        public async Task JoinAsync()
        {
            NixPlayer player = await Audio.CreatePlayerForGuildAsync(
                Context.Guild,
                Context.VoiceChannel,
                Context.TextChannel);

            if (player is null)
            {
                await Context.TextChannel.SendMessageAsync("Oh no, something happened...");

                return;
            }

            await Context.TextChannel.SendMessageAsync(
                $"Joined **{player.VoiceChannel.Name}** and bound to **{player.TextChannel.Name}**");
        }