Пример #1
0
        private async Task TrackFinished(LavaPlayer player, LavaTrack track, TrackEndReason reason)
        {
            if (!reason.ShouldPlayNext())
            {
                return;
            }

            if (!player.Queue.TryDequeue(out var item) || !(item is LavaTrack nextTrack))
            {
                await player.TextChannel.SendMessageAsync("There are no more tracks in the queue.");

                return;
            }

            await player.PlayAsync(nextTrack);
        }
Пример #2
0
        private async Task TrackFinished(LavaPlayer player, LavaTrack track, TrackEndReason reason)
        {
            if (!reason.ShouldPlayNext())
            {
                return;
            }

            if (!player.Queue.TryDequeue(out var item) || !(item is LavaTrack nextTrack))
            {
                await player.TextChannel.SendMessageAsync("⚠️ Ya no hay mas canciones en cola.");

                return;
            }

            await player.PlayAsync(nextTrack);
        }
Пример #3
0
        private async Task OnTrackFinished(LavaPlayer player, LavaTrack track, TrackEndReason reason)
        {
            if (!reason.ShouldPlayNext())
            {
                return;
            }

            if (!player.Queue.TryDequeue(out var item) || !(item is AudioTrack nextTrack))
            {
                await player.TextChannel?.SendMessageAsync($"There are no more items left in queue.");

                return;
            }

            await player.PlayAsync(nextTrack);

            await player.TextChannel.SendMessageAsync($"Finished playing: {track.ToString()}\nNow playing: {nextTrack.ToString()}");

            await player.TextChannel.SendMessageAsync(player.ObjectToString());
        }
Пример #4
0
        private async Task TrackFinished(LavaPlayer player, LavaTrack track, TrackEndReason reason)
        {
            if (!reason.ShouldPlayNext())
            {
                return;
            }

            if (!player.Queue.TryDequeue(out var item) || !(item is LavaTrack nextTrack))
            {
                await player.TextChannel.SendMessageAsync(Config.pre.error + " There are no more tracks in the queue.");

                return;
            }

            await player.PlayAsync(nextTrack);

            Embed embed = await EmbedHandler.CreateMusicEmbed(":musical_note: Now playing " + nextTrack.Title + " :musical_note:", nextTrack.Uri.ToString());

            await player.TextChannel.SendMessageAsync(null, false, embed);
        }
Пример #5
0
        private async Task OnTrackFinished(LavaPlayer player, LavaTrack track, TrackEndReason reason)
        {
            if (!reason.ShouldPlayNext())
            {
                return;
            }

            if (!player.Queue.TryDequeue(out var item) || !(item is LavaTrack nextTrack))
            {
                await player.TextChannel?.SendMessageAsync($"There are no more items left in queue.");

                await _lavaLink.DisconnectAsync(player.VoiceChannel);

                return;
            }

            await player.PlayAsync(nextTrack);

            await player.TextChannel?.SendMessageAsync($"Now playing: {nextTrack.Title}");
        }
Пример #6
0
        private async Task OnTrackFinished(LavaPlayer lavalink, ILavaTrack lavaTrack, TrackEndReason reason)
        {
            if (!reason.ShouldPlayNext())
            {
                return;
            }

            IEnergizePlayer ply = this.Players[lavalink.VoiceChannel.GuildId];

            if (ply.IsLooping)
            {
                lavaTrack.ResetPosition();
                await ply.Lavalink.PlayAsync(lavaTrack);
            }
            else
            {
                if (ply.Queue.TryDequeue(out IQueueObject obj))
                {
                    if (obj is ILavaTrack newTrack)
                    {
                        await ply.Lavalink.PlayAsync(newTrack);

                        await this.SendPlayerAsync(ply, newTrack);
                    }
                }
                else
                {
                    if (ply.Autoplay && ply.Queue.Count == 0)
                    {
                        await this.AddRelatedYtContentAsync(ply.VoiceChannel, ply.TextChannel, lavaTrack);
                    }
                    else
                    {
                        if (ply.TrackPlayer != null)
                        {
                            await ply.TrackPlayer.DeleteMessage();
                        }
                    }
                }
            }
        }
Пример #7
0
        private async Task OnTrackEnded(TrackEndedEventArgs args)
        {
            TrackEndReason reason = args.Reason;
            LavaPlayer     player = args.Player;
            LavaTrack      track  = args.Track;

            if (!reason.ShouldPlayNext())
            {
                return;
            }
            if (_loop)
            {
                await player.PlayAsync(track);

                await player.TextChannel.SendMessageAsync($":arrow_forward: Now playing: `{track.Title}`");

                return;
            }
            if (!player.Queue.TryDequeue(out IQueueable queueObject) || !(queueObject is LavaTrack nextTrack))
            {
                await player.TextChannel.SendMessageAsync(":x: There are no more tracks in the queue.");

                return;
            }
            if (_qloop)
            {
                await player.PlayAsync(nextTrack);

                player.Queue.Enqueue(track);
                await player.TextChannel.SendMessageAsync($":arrow_forward: Now playing: `{nextTrack.Title}`");

                return;
            }

            await player.PlayAsync(nextTrack);

            await player.TextChannel.SendMessageAsync($":arrow_forward: Now playing: `{nextTrack.Title}`");
        }
Пример #8
0
        public async Task OnTrackFinished(LavaPlayer player, LavaTrack track, TrackEndReason reason)
        {
            if (!reason.ShouldPlayNext())
            {
                return;
            }

            if (!player.Queue.TryDequeue(out var item) || !(item is LavaTrack nextTrack))
            {
                await player.TextChannel?.SendMessageAsync($"There are no more songs left in queue.");

                return;
            }

            await player.PlayAsync(nextTrack);

            EmbedBuilder embed = new EmbedBuilder();

            embed.WithDescription($"**Finished Playing: `{track.Title}`\nNow Playing: `{nextTrack.Title}`**");
            //embed.WithColor();
            await player.TextChannel.SendMessageAsync("", false, embed.Build());

            await player.TextChannel.SendMessageAsync(player.ToString());
        }