コード例 #1
0
        public async Task QueueAsync()
        {
            var    audioQueue = AudioQueues.GetAudioQueue(Context.Guild);
            string avatar     = Context.Message.Author.GetAvatarUrl() ?? Context.Message.Author.GetDefaultAvatarUrl();

            if (audioQueue.Queue.ElementAtOrDefault(0) == null)
            {
                EmbedBuilder builderNull = new EmbedBuilder();
                builderNull
                .WithAuthor(Context.Message.Author.Username, avatar)
                .WithDescription("\n Kolejka jest pusta")
                .WithColor(Color.DarkRed);

                await ReplyAsync("", false, builderNull.Build());

                return;
            }

            List <string>         queue        = new List <string>();
            List <List <string> > pagesContent = new List <List <string> >(5);

            queue        = AudioQueuesManagment.CreateListOfSongs(Context.Channel, audioQueue.Queue, Context.Message.Author.Username, avatar);
            pagesContent = AudioQueuesManagment.CreateListOfPages(queue);
            string[] pages = new string[5];
            pages = AudioQueuesManagment.AssignContentToPages(pages, pagesContent);

            await PagedReplyAsync(pages);
        }
コード例 #2
0
        private static async Task RemoveAllTracks(SocketGuild guild)
        {
            var audioQueue = AudioQueues.GetAudioQueue(guild);

            audioQueue.Queue.Clear();
            AudioQueues.SaveQueues();
            await Task.CompletedTask;
        }
コード例 #3
0
        public async Task SkipAsync()
        {
            var    audioQueue        = AudioQueues.GetAudioQueue(Context.Guild);
            string skippedTrackTitle = audioQueue.Queue[audioQueue.PlayingTrackIndex].Title;
            await AudioService.SkipAsync(Context.Guild);

            await ReplyAsync($":fast_forward: {skippedTrackTitle} skipped");
        }
コード例 #4
0
        public static async Task RemoveAndPlay(LavalinkPlayer player, LavalinkTrack track)
        {
            var audioQueue = AudioQueues.GetAudioQueue(player.VoiceChannel.Guild as SocketGuild);

            RemoveTrack(audioQueue, track);
            await player.StopAsync();

            await PlayNextAfterRemove(audioQueue, player);
        }
コード例 #5
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);
            }
        }