Exemplo n.º 1
0
        public async Task Waifu([Remainder] string extraTags = null)
        {
            DateTime curTime = DateTime.Now;
            DateTime lastMessage;

            lastMessage = _cooldowns.GetUserCooldownsForCommand("NSFW", Context.User.Id);

            if (lastMessage + new TimeSpan(0, 2, 0) > curTime)
            {
                var msg = await Context.Channel.SendErrorAsync("You may only use one of these NSFW commands every two minutes.");

                Context.Message.DeleteAfter(3);
                msg.DeleteAfter(3);
                return;
            }

            string waifu = null;

            using (var uow = DBHandler.UnitOfWork())
            {
                waifu = uow.Waifus.GetRandomWaifu();
            }

            if (waifu == null)
            {
                return;
            }

            if (extraTags != null)
            {
                if (extraTags.StartsWith("+"))
                {
                    extraTags = extraTags.Substring(1);
                }

                waifu += " + " + extraTags;
            }

            string parsedWaifu = waifu.ParseBooruTags();

            var message = await Context.Channel.SendSuccessAsync("Searching...");

            string imageURL = await GetImageURL(parsedWaifu);

            EmbedBuilder eb = new EmbedBuilder();

            //Big issue?!
            if (imageURL == null)
            {
                await message.ModifyAsync(x => x.Embed = eb.EmbedErrorAsync($"No images found. The specified tags probably don't exist: {waifu}."));

                return;
            }

            _cooldowns.AddUserCooldowns("NSFW", Context.User.Id, curTime);

            //We have the URL let us use it
            await message.ModifyAsync(x => x.Embed = eb.PictureEmbed($"{waifu}", "", $"{imageURL}"));
        }
Exemplo n.º 2
0
        public async Task PersonalWaifu()
        {
            DateTime curTime = DateTime.Now;
            DateTime lastMessage;

            lastMessage = _cooldowns.GetUserCooldownsForCommand("NSFW", Context.User.Id);

            if (lastMessage + new TimeSpan(0, 2, 0) > curTime)
            {
                var msg = await Context.Channel.SendErrorAsync("You may only use one of these NSFW commands every two minutes.");

                Context.Message.DeleteAfter(3);
                msg.DeleteAfter(3);
                return;
            }

            string pwaifu = null;

            using (var uow = DBHandler.UnitOfWork())
            {
                pwaifu = uow.User.GetPersonalWaifu(Context.User.Id);
            }

            if (pwaifu == "")
            {
                using (var uow = DBHandler.UnitOfWork())
                {
                    string waifuToAttribute = uow.Waifus.GetRandomWaifu();
                    pwaifu = uow.User.SetPersonalWaifu(Context.User.Id, waifuToAttribute);
                }
            }

            var message = await Context.Channel.SendSuccessAsync("Searching...");

            string imageURL = await GetImageURL(pwaifu.Replace(' ', '_').ToLower());

            EmbedBuilder eb = new EmbedBuilder();

            //Big issue?!
            if (imageURL == null)
            {
                await message.ModifyAsync(x => x.Embed = eb.EmbedErrorAsync("No images found. Most likely a mistake with your tags."));

                return;
            }

            _cooldowns.AddUserCooldowns("NSFW", Context.User.Id, curTime);

            //We have the URL let us use it
            await message.ModifyAsync(x => x.Embed = eb.PictureEmbed($"{pwaifu}", "", $"{imageURL}"));
        }
Exemplo n.º 3
0
        public async Task GelbooruSearch([Remainder] string tags)
        {
            DateTime curTime = DateTime.Now;
            DateTime lastMessage;

            lastMessage = _cooldowns.GetUserCooldownsForCommand("NSFW", Context.User.Id);

            if (lastMessage + new TimeSpan(0, 2, 0) > curTime)
            {
                var msg = await Context.Channel.SendErrorAsync("You may only use one of these NSFW commands every two minutes.");

                Context.Message.DeleteAfter(3);
                msg.DeleteAfter(3);
                return;
            }

            //Lets start by perfecting the tags
            string ParsedTags = tags.ParseBooruTags();

            var message = await Context.Channel.SendSuccessAsync("Searching...");

            string imageURL = await GetImageURL(ParsedTags.ToLower());

            EmbedBuilder eb = new EmbedBuilder();

            //Big issue?!
            if (imageURL == null)
            {
                await message.ModifyAsync(x => x.Embed = eb.EmbedErrorAsync("No images found. Most likely a mistake with your tags."));

                return;
            }

            _cooldowns.AddUserCooldowns("NSFW", Context.User.Id, curTime);

            //We have the URL let us use it
            await message.ModifyAsync(x => x.Embed = eb.PictureEmbed($"{tags}", "", $"{imageURL}"));
        }