Exemple #1
0
        //[Command("Pay", RunMode = RunMode.Async)]
        //public async Task PlayAsync(params string[] queries)
        //{
        //    foreach (var query in queries)
        //    {
        //        await PlayAsync(query);
        //    }
        //}

        public async Task <string> StopAsync()
        {
            await player.StopAsync();

            await lavaSocketClient.DisconnectAsync(player.VoiceChannel);

            return("Disconnected!");
        }
Exemple #2
0
 private async Task EndPlayer()
 {
     if (_player == null)
     {
         throw new InvalidPlayerException();
     }
     _queues.Remove(_player.VoiceChannel.GuildId);
     await _lavaClient.DisconnectAsync(_player.VoiceChannel);
 }
Exemple #3
0
        public async Task <Embed> LeaveAsync(SocketVoiceChannel voiceChannel, ulong guildId)
        {
            var player = _lavaSocketClient.GetPlayer(guildId);
            var embed  = new EmbedBuilder();

            if (player == null)
            {
                embed.WithDescription("Cannot leave a voice channel if not in one!");
                return(embed.Build());
            }
            else
            {
                await _lavaSocketClient.DisconnectAsync(voiceChannel);

                embed.WithDescription($"Disconnected from: {voiceChannel.Name}");
                return(embed.Build());
            }
        }
Exemple #4
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}");
        }
Exemple #5
0
 public async Task LeaveAsync(SocketVoiceChannel voiceChannel)
 => await _lavaSocketClient.DisconnectAsync(voiceChannel);