示例#1
0
文件: Music.cs 项目: Chronojam/Mute
        [NotNull] private async Task Enqueue([NotNull] ITrack track)
        {
            // Get music queue
            var channel = await _queueCollection.Get(Context.Guild.Id);

            // Move into channel with user
            if (!(Context.User is IVoiceState vs) || vs.VoiceChannel == null)
            {
                await ReplyAsync("You must be in a voice channel!");

                return;
            }
            await channel.VoicePlayer.Move(vs.VoiceChannel);

            // Enqueue track
            var completion = await channel.Enqueue(track, new AudioFileReader(track.Path));

            // Create embed for this track (with no colour)
            var embed = await track.DiscordEmbed();

            //Show embed with green border (indicates it is playing)
            var message = await ReplyAsync(embed.WithColor(Color.Green));

            //Wait for track to finish
            await completion;

            //Change embed colour
            await message.ModifyAsync(a => a.Embed = embed.WithColor(Color.DarkPurple).Build());
        }