Пример #1
0
        public static async Task PlayAsync(SocketCommandContext context, string song, int choose, YoutubeVideo video = null)
        {
            // Create used objects
            SocketGuild           guild        = context.Guild;
            SocketUserMessage     message      = context.Message;
            IVoiceChannel         voiceChannel = (context.User as IVoiceState).VoiceChannel;
            ISocketMessageChannel channel      = context.Channel;
            Utilities             utilities    = new Utilities(guild);

            // Checking if voice channel is null (and sending an error message)
            // If not, creating or getting a lavalink player
            // Checking if a given string is empty (if true, and there is a song in queue that is stopped, resuming it
            if (await VoiceChannelIsNull(channel, voiceChannel, utilities) is true)
            {
                return;
            }
            LavalinkPlayer player = lavalinkManager.GetPlayer(guild.Id) ?? await lavalinkManager.JoinAsync(voiceChannel);

            var audioQueue = AudioQueues.GetAudioQueue(guild);

            if (await SongIsEmpty(channel, utilities, player, audioQueue, song) is true)
            {
                return;
            }

            LoadTracksResponse response = await lavalinkManager.GetTracksAsync(song);

            LavalinkTrack track = response.Tracks.First();

            // Maximum songs in queue is 50
            if (await QueueIsFull(channel, utilities, audioQueue.Queue.Count) is true)
            {
                return;
            }

            // Adding a track to queue
            audioQueue.Queue = AudioQueues.GetOrCreateGuildQueue(track, audioQueue);

            // A check if a song is first in the queue, or if it's been added
            string songAlert = "PLAY_ADDED_SONG";

            if (await SongIsFirst(player, audioQueue, track, video, context, songAlert, choose) is false)
            {
                return;
            }
            // If a user gives a link to a youtube video, we don't need to send song info
            if (choose != -1)
            {
                await SongInfo(channel, message, video, choose, songAlert);
            }
        }
Пример #2
0
        public async Task SeekTask(int position)
        {
            var player = _lavalinkManager.GetPlayer(Context.Guild.Id) ??
                         await _lavalinkManager.JoinAsync((Context.User as IGuildUser)?.VoiceChannel);

            Console.WriteLine(
                $"Track is seekable: {player.CurrentTrack.IsSeekable}\n" +
                $"Now at: {TimeSpan.FromMilliseconds(player.CurrentPosition)}" +
                $"/{TimeSpan.FromMilliseconds(player.CurrentTrack.Length.Milliseconds)}");
            if (player.CurrentTrack.IsSeekable)
            {
                await player.SeekAsync(position * 1000);
                await ReplyAsync("<:check:462378657114226695>");
            }
            else
            {
                await ReplyAndDeleteAsync("<:uncheck:462379632004562965> Cant seek this track.");
            }
        }
Пример #3
0
        public async Task SoundCloudCmd([Remainder] string query)
        {
            LavalinkPlayer p = _lavaManager.GetPlayer(Context.Guild.Id) ?? await _lavaManager.JoinAsync((Context.User as IVoiceState).VoiceChannel);

            LoadTracksResponse r = await _lavaManager.GetTracksAsync($"scsearch:{query}");

            LavalinkTrack tr = r.Tracks.First();

            await p.PlayAsync(tr);

            await ReplyAsync("", embed : GetTrackInfoEmbed(tr, Context.User));
        }