using Discord;
using Discord.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Terrabot
{
    /// <summary>
    /// This Class file is the You Command of Terrabot. It does direct play and queuing when the player is in uses.
    /// You can also search for youtube videos by doing !you search
    /// </summary>
    [Group("You")]
    public class You : ModuleBase<ICommandContext>
    {
        private readonly AudioService _service;
        public You(AudioService service)
        {
            _service = service;
        }
        [Command(RunMode = RunMode.Async)]
        [Priority(0)]
        public async Task YouCmd([Remainder] string url)
            // Direct Play or Queue
        {
            Predicate<IGuild> guildFinder = (IGuild lockgf) => { return lockgf == Context.Guild; };
            IGuild Line = _service.LLock.Find(guildFinder);
            if (Line == Context.Guild)
            {
                await _service.YoutubeExDL(Context.Guild, (Context.User as IVoiceState).VoiceChannel, Context.Channel, url,"yes");
                return;
            }
            else
            {
                await _service.YoutubeExDL(Context.Guild, (Context.User as IVoiceState).VoiceChannel, Context.Channel, url);
                return;
            }
        }
        [Command("search", RunMode = RunMode.Async)]
        [Priority(1)]
        public async Task SearchCmd([Remainder] string query)
            // Search youtube function for play or queue
        {
            Predicate<IGuild> guildFinder = (IGuild lockgf) => { return lockgf == Context.Guild; };
            IGuild Line = _service.LLock.Find(guildFinder);
            if (Line == Context.Guild)
            {
                await _service.YouSearch(Context.Guild, (Context.User as IVoiceState).VoiceChannel, Context.Channel, query, "yes");
                return;
            }
            else
            {
                await _service.YouSearch(Context.Guild, (Context.User as IVoiceState).VoiceChannel, Context.Channel, query);
            }
        }
        [Command("dl", RunMode = RunMode.Async)]
        [Priority(1)]
        public async Task DownloadCmd([Remainder] string query)
        // Download youtube function for terrabot
        {
            if (System.Environment.MachineName.Equals("Leos-Server"))
            {

            }
            else
            {

            }
        }
    }
}
