Пример #1
0
        public async Task Play(CommandContext ctx, LavalinkTrack track)
        {
            if (track == null)
            {
                return;
            }

            var lava = ctx.Client.GetLavalink();
            var node = lava.GetIdealNodeConnection();
            var conn = node.GetGuildConnection(ctx.Member.Guild);

            if (conn.CurrentState.CurrentTrack == null)
            {
                await conn.PlayAsync(track);

                await ctx.Message.Channel.SendMessageAsync($"Playing {track.Title}");
            }
            else
            {
                LavaSong s = new LavaSong(track, ctx.Message.Channel);

                m_Queue.Enqueue(s);
                await ctx.Message.Channel.SendMessageAsync($"Track added to queue. Currently there are {m_Queue.Count} tracks in the queue!");
            }
        }
Пример #2
0
        public async Task PlayTracksList(CommandContext ctx, List <LavalinkTrack> tracks)
        {
            if (tracks == null)
            {
                return;
            }

            var lava = ctx.Client.GetLavalink();
            var node = lava.GetIdealNodeConnection();
            var conn = node.GetGuildConnection(ctx.Member.Guild);

            if (conn.CurrentState.CurrentTrack == null)
            {
                int index = 0;
                foreach (LavalinkTrack track in tracks)
                {
                    if (index != 0)
                    {
                        LavaSong s = new LavaSong(track, ctx.Message.Channel);

                        m_Queue.Enqueue(s);
                    }
                    else
                    {
                        await conn.PlayAsync(track);

                        await ctx.Message.Channel.SendMessageAsync($"Playing {track.Title}");

                        index++;
                    }
                }
            }
            else
            {
                foreach (LavalinkTrack track in tracks)
                {
                    await conn.PlayAsync(track);

                    await ctx.Message.Channel.SendMessageAsync($"Playing {track.Title}");
                }
            }
        }