Ejemplo n.º 1
0
        public async Task ConfusedAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/RCotXAK.png",
                "http://i.imgur.com/yN5cwQq.jpg",
                "http://i.imgur.com/5TkmRWv.png",
                "http://i.imgur.com/QBFQzCQ.png",
                "http://i.imgur.com/KjSp1W4.png",
                "http://i.imgur.com/mX6D68m.jpg",
                "http://i.imgur.com/ogA5GeN.jpg",
                "http://i.imgur.com/eCHsHQZ.jpg",
                "http://i.imgur.com/r0u2dBx.jpg",
                "http://i.imgur.com/d8oMJUg.jpg",
                "http://i.imgur.com/dkV331J.jpg",
                "http://i.imgur.com/U9N4oGR.jpg",
                "http://i.imgur.com/GA0ZtvR.jpg",
                "http://i.imgur.com/NQ2e3Dq.gif",
                "http://i.imgur.com/5HTugJ6.jpg",
                "http://i.imgur.com/MJrBLij.png",
                "http://i.imgur.com/JgjCHPd.jpg",
                "http://i.imgur.com/KIDXXHw.gif",
                "http://i.imgur.com/Eu0Yyqq.jpg",
                "http://i.imgur.com/P5V369I.png",
                "http://i.imgur.com/DtVEGde.gif",
                "http://i.imgur.com/xxNH850.jpg",
                "http://i.imgur.com/gytATzW.jpg",
                "http://i.imgur.com/UrDJVC0.jpg",
                "http://i.imgur.com/3GkAnYo.png",
                "http://i.imgur.com/qTXPgyI.jpg",
                "http://i.imgur.com/GmIXuso.png",
                "http://i.imgur.com/UM8XpgR.gif",
                "http://i.imgur.com/GhoKM0u.gif",
                "http://i.imgur.com/ehskzgF.gif",
                "http://i.imgur.com/2biawgF.gif",
                "http://i.imgur.com/D2WXDbd.gif",
                "http://i.imgur.com/1ogeK3A.gif",
                "http://i.imgur.com/djNBrtj.jpg",
                "http://i.imgur.com/VyabzAv.jpg"
            };


            new EmbedBuilder()
            {
                ImageUrl = images[MikiRandom.Next(0, images.Length)]
            }.ToEmbed().QueueToChannel(e.Channel);
        }
Ejemplo n.º 2
0
        public async Task <List <Tuple <string, IDiscordMessageChannel> > > GetMessage(IDiscordGuild guild, EventMessageType type, IDiscordUser user)
        {
            long guildId = guild.Id.ToDbLong();
            List <IDiscordMessageChannel> channels = await guild.GetChannels();

            List <Tuple <string, IDiscordMessageChannel> > output = new List <Tuple <string, IDiscordMessageChannel> >();

            using (var context = new MikiContext())
            {
                foreach (IDiscordMessageChannel c in channels)
                {
                    EventMessage messageObject = await context.EventMessages.FindAsync(c.Id.ToDbLong(), (int)type);

                    if (messageObject == null)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(messageObject.Message))
                    {
                        continue;
                    }

                    string modifiedMessage       = messageObject.Message;
                    List <IDiscordUser> allUsers = await c.GetUsersAsync();

                    modifiedMessage = modifiedMessage.Replace("-um", user.Mention);
                    modifiedMessage = modifiedMessage.Replace("-uc", user.Guild.UserCount.ToString());
                    modifiedMessage = modifiedMessage.Replace("-u", string.IsNullOrEmpty(user.Nickname) ? user.Username : user.Nickname);

                    modifiedMessage = modifiedMessage.Replace("-ru", allUsers[MikiRandom.Next(0, allUsers.Count)].Nickname);

                    modifiedMessage = modifiedMessage.Replace("-now", DateTime.Now.ToShortDateString());
                    modifiedMessage = modifiedMessage.Replace("-s", user.Guild.Name);

                    modifiedMessage = modifiedMessage.Replace("-om", user.Guild.Owner.Mention);
                    modifiedMessage = modifiedMessage.Replace("-o", string.IsNullOrEmpty(user.Guild.Owner.Nickname) ? user.Guild.Owner.Username : user.Guild.Owner.Nickname);

                    modifiedMessage = modifiedMessage.Replace("-cc", user.Guild.ChannelCount.ToString());
                    modifiedMessage = modifiedMessage.Replace("-vc", user.Guild.VoiceChannelCount.ToString());

                    output.Add(new Tuple <string, IDiscordMessageChannel>(modifiedMessage, c));
                }
                return(output);
            }
        }
Ejemplo n.º 3
0
        private async Task OnMessageCreateAsync(IDiscordMessage arg)
        {
            if (!(app is MikiBotApp botApp))
            {
                return;
            }

            switch (arg.Content.ToLowerInvariant())
            {
            case "here come dat boi":
            {
                var a = achievementService.GetAchievement(AchievementIds.FrogId);
                await botApp.CreateFromMessageAsync(
                    arg,
                    async ctx => await achievementService.UnlockAsync(a, arg.Author.Id));
            }
            break;

            case "( ͡° ͜ʖ ͡°)":
            {
                var a = achievementService.GetAchievement(AchievementIds.LennyId);
                await botApp.CreateFromMessageAsync(
                    arg,
                    async ctx => await achievementService.UnlockAsync(a, arg.Author.Id));
            }
            break;

            case "poi":
            {
                var a = achievementService.GetAchievement(AchievementIds.ShipId);
                await botApp.CreateFromMessageAsync(
                    arg,
                    async ctx => await achievementService.UnlockAsync(a, arg.Author.Id));
            }
            break;
            }

            if (MikiRandom.Next(0, 10000000000) == 5234210)
            {
                var a = achievementService.GetAchievement(AchievementIds.LuckId);
                await botApp.CreateFromMessageAsync(
                    arg,
                    async ctx => await achievementService.UnlockAsync(a, arg.Author.Id));
            }
        }
Ejemplo n.º 4
0
        public async Task PokeAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/WG8EKwM.gif",
                "http://i.imgur.com/dfoxby7.gif",
                "http://i.imgur.com/TzD1Ngz.gif",
                "http://i.imgur.com/i1hwvQu.gif",
                "http://i.imgur.com/bStOFsM.gif",
                "http://i.imgur.com/1PBeB9H.gif",
                "http://i.imgur.com/3kerpju.gif",
                "http://i.imgur.com/uMBRFjX.gif",
                "http://i.imgur.com/YDJFoBV.gif",
                "http://i.imgur.com/urC9B1H.gif"
            };

            await QueueAction(e, "pokes", images[MikiRandom.Next(images.Length)]);
        }
Ejemplo n.º 5
0
        public async Task SmugAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/zUwqrhM.png",
                "http://i.imgur.com/TYqPh89.jpg",
                "http://i.imgur.com/xyOSaCt.png",
                "http://i.imgur.com/gyw0ifl.png",
                "http://i.imgur.com/kk0xvtx.png",
                "http://i.imgur.com/UIuyUne.jpg",
                "http://i.imgur.com/9zgIjY1.jpg",
                "http://i.imgur.com/Ku1ONAD.jpg",
                "http://i.imgur.com/7lB5bRT.jpg",
                "http://i.imgur.com/BoVHipF.jpg",
                "http://i.imgur.com/vN48mwz.png",
                "http://i.imgur.com/fGI4zLe.jpg",
                "http://i.imgur.com/Gc4gmwQ.jpg",
                "http://i.imgur.com/JMrmKt7.jpg",
                "http://i.imgur.com/a7sbJz2.jpg",
                "http://i.imgur.com/NebmjhR.png",
                "http://i.imgur.com/5ccbrFI.png",
                "http://i.imgur.com/XJL4Vmo.jpg",
                "http://i.imgur.com/eg0q1ez.png",
                "http://i.imgur.com/JJFxxmA.jpg",
                "http://i.imgur.com/2cTDF3b.jpg",
                "http://i.imgur.com/Xc0Duqv.png",
                "http://i.imgur.com/YgMdPkd.jpg",
                "http://i.imgur.com/BvAv6an.jpg",
                "http://i.imgur.com/KRLP5JT.jpg",
                "http://i.imgur.com/yXcsCK3.jpg",
                "http://i.imgur.com/QXG56kG.png",
                "http://i.imgur.com/OFBz1YJ.png",
                "http://i.imgur.com/9ulVckY.png",
                "http://i.imgur.com/VLXeSJK.png",
                "http://i.imgur.com/baiMBP6.png"
            };

            RuntimeEmbed em = new RuntimeEmbed(new Discord.EmbedBuilder())
            {
                ImageUrl = images[MikiRandom.Next(0, images.Length)]
            };

            em.QueueToChannel(e.Channel);
        }
Ejemplo n.º 6
0
        public async Task SlapAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/GQtzDsV.gif",
                "http://i.imgur.com/rk8eqnt.gif",
                "http://i.imgur.com/UnzGS24.gif",
                "http://i.imgur.com/CHbRGnV.gif",
                "http://i.imgur.com/DvwnC0r.gif",
                "http://i.imgur.com/Ksy8dvd.gif",
                "http://i.imgur.com/b75B4qM.gif",
                "http://i.imgur.com/d9thUdx.gif",
                "http://i.imgur.com/iekwz4h.gif",
                "http://i.imgur.com/q7AmR8n.gif",
                "http://i.imgur.com/pDohPrm.gif",
            };

            await QueueAction(e, "slaps", images[MikiRandom.Next(images.Length)]);
        }
Ejemplo n.º 7
0
        public async Task PunchAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://imgur.com/jVc3GGv.gif",
                "http://imgur.com/iekwz4h.gif",
                "http://imgur.com/AbRmlAo.gif",
                "http://imgur.com/o5MoMYi.gif",
                "http://imgur.com/yNfMX9B.gif",
                "http://imgur.com/bwXvfKE.gif",
                "http://imgur.com/6wKJVHy.gif",
                "http://imgur.com/kokCK1I.gif",
                "http://imgur.com/E3CtvPV.gif",
                "http://imgur.com/q7AmR8n.gif",
                "http://imgur.com/pDohPrm.gif",
            };

            await QueueAction(e, "punches", images[MikiRandom.Next(images.Length)]);
        }
Ejemplo n.º 8
0
        public Task ComplimentAsync(IContext e)
        {
            string[] I_LIKE =
            {
                "I like ",
                "I love ",
                "I admire ",
                "I really enjoy ",
                "For some reason I like "
            };

            string[] BODY_PART =
            {
                "that silly fringe of yours",
                "the lower part of your lips",
                "the smallest toe on your left foot",
                "the smallest toe on your right foot",
                "the second eyelash from your left eye",
                "the lower part of your chin",
                "your creepy finger on your left hand",
                "your cute smile",
                "those dazzling eyes of yours",
                "your creepy finger on your right hand",
                "the special angles your elbows make",
                "the dimples on your cheeks",
                "your smooth hair"
            };

            string[] SUFFIX =
            {
                " a lot.",
                " a bit.",
                " quite a bit.",
                " a lot, is that weird?",
            };

            e.GetChannel().QueueMessage(e, null,
                                        I_LIKE[MikiRandom.Next(0, I_LIKE.Length)]
                                        + BODY_PART[MikiRandom.Next(0, BODY_PART.Length)]
                                        + SUFFIX[MikiRandom.Next(0, SUFFIX.Length)]);
            return(Task.CompletedTask);
        }
Ejemplo n.º 9
0
        private AccountManager(Bot bot)
        {
            this.bot = bot;

            OnLocalLevelUp += async(a, e, l) =>
            {
                Locale locale = Locale.GetEntity(e.Id.ToDbLong());

                int randomNumber  = MikiRandom.Next(0, 10);
                int currencyAdded = (l * 10 + randomNumber);

                using (var context = new MikiContext())
                {
                    User user = await context.Users.FindAsync(a.Id);

                    if (user != null)
                    {
                        await user.AddCurrencyAsync(currencyAdded, e);

                        await context.SaveChangesAsync();
                    }
                    else
                    {
                        Log.Warning("User levelled up was null.");
                    }
                }

                IDiscordEmbed embed = new RuntimeEmbed(new EmbedBuilder())
                {
                    Title       = locale.GetString("miki_accounts_level_up_header"),
                    Description = locale.GetString("miki_accounts_level_up_content", a.Name, l),
                    Color       = new IA.SDK.Color(1, 0.7f, 0.2f)
                };

                embed.AddField(locale.GetString("miki_generic_reward"), "🔸" + currencyAdded.ToString());
                await Notification.SendChannel(e, embed);
            };

            Bot.instance.Client.GuildUpdated += Client_GuildUpdated;
            Bot.instance.Client.UserJoined   += Client_UserJoined;
            Bot.instance.Client.UserLeft     += Client_UserLeft;
        }
Ejemplo n.º 10
0
        public async Task PoutAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/hsjBcz1.jpg",
                "http://i.imgur.com/oJSVNzT.jpg",
                "http://i.imgur.com/gWtmHoN.jpg",
                "http://i.imgur.com/VFG9zKV.png",
                "http://i.imgur.com/BUBiL0f.jpg",
                "http://i.imgur.com/UdlZ69E.gif",
                "http://i.imgur.com/yhryAf9.png",
                "http://i.imgur.com/d9DG2sJ.png",
                "http://i.imgur.com/uTB2HIY.png",
                "http://i.imgur.com/dVtR9vI.png",
                "http://i.imgur.com/rt7Vgn3.jpg",
                "http://i.imgur.com/uTB2HIY.png"
            };

            new EmbedBuilder()
            {
                ImageUrl = images[MikiRandom.Next(0, images.Length)]
            }.ToEmbed().QueueToChannel(e.Channel);
        }
Ejemplo n.º 11
0
 public async Task DogAsync(EventContext e)
 {
     string[] dog =
     {
         "http://i.imgur.com/KOjUbMQ.jpg",
         "http://i.imgur.com/owJKr7y.jpg",
         "http://i.imgur.com/rpQdRoY.jpg",
         "http://i.imgur.com/xrVXDQ2.jpg",
         "http://i.imgur.com/Bt6zrhq.jpg",
         "http://i.imgur.com/sNm8hRR.jpg",
         "http://i.imgur.com/TeTwhxN.jpg",
         "http://i.imgur.com/zMs8Sx6.jpg",
         "http://i.imgur.com/bWioilW.jpg",
         "http://i.imgur.com/q6UTI0W.jpg",
         "http://i.imgur.com/e9aTxh7.jpg",
         "http://i.imgur.com/lvH26a9.jpg",
         "http://i.imgur.com/0Q8E82b.jpg",
         "http://i.imgur.com/oMm6Zba.jpg",
         "http://i.imgur.com/aA4kvJE.jpg",
         "http://i.imgur.com/FJRTLZR.jpg",
         "http://i.imgur.com/EHYhgJk.jpg",
         "http://i.imgur.com/QiudnCT.jpg",
         "http://i.imgur.com/2nYIwTd.jpg",
         "http://i.imgur.com/NnFZVPC.jpg",
         "http://i.imgur.com/uEHtSpB.jpg",
         "http://i.imgur.com/5DPqIi0.jpg",
         "http://i.imgur.com/ZkxnaRE.jpg",
         "http://i.imgur.com/kCWMUgk.jpg",
         "http://i.imgur.com/X8FO7Ds.jpg",
         "http://i.imgur.com/yKAXiyl.jpg",
         "http://i.imgur.com/A4eVQQF.jpg",
         "http://i.imgur.com/Wtjxxiv.jpg",
         "http://i.imgur.com/uIX5RVf.jpg",
         "http://i.imgur.com/49Da81l.jpg"
     };
     await e.Channel.SendMessage(dog[MikiRandom.Next(0, dog.Length)]);
 }
Ejemplo n.º 12
0
        public async Task PoutAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/hsjBcz1.jpg",
                "http://i.imgur.com/oJSVNzT.jpg",
                "http://i.imgur.com/gWtmHoN.jpg",
                "http://i.imgur.com/VFG9zKV.png",
                "http://i.imgur.com/BUBiL0f.jpg",
                "http://i.imgur.com/UdlZ69E.gif",
                "http://i.imgur.com/yhryAf9.png",
                "http://i.imgur.com/d9DG2sJ.png",
                "http://i.imgur.com/uTB2HIY.png",
                "http://i.imgur.com/dVtR9vI.png",
                "http://i.imgur.com/rt7Vgn3.jpg",
                "http://i.imgur.com/uTB2HIY.png"
            };

            RuntimeEmbed em = new RuntimeEmbed(new Discord.EmbedBuilder());

            em.ImageUrl = images[MikiRandom.Next(0, images.Length)];

            await em.SendToChannel(e.Channel);
        }
Ejemplo n.º 13
0
        public async Task PruneAsync(EventContext e, int _amount = 100, ulong _target = 0, string _filter = null)
        {
            IDiscordGuildUser invoker = await e.Guild.GetSelfAsync();

            if (!(await(e.Channel as IDiscordGuildChannel).GetPermissionsAsync(invoker)).HasFlag(GuildPermission.ManageMessages))
            {
                e.Channel.QueueMessage(e.Locale.GetString("miki_module_admin_prune_error_no_access"));
                return;
            }

            if (e.Arguments.Pack.Length < 1)
            {
                await new EmbedBuilder()
                .SetTitle("♻ Prune")
                .SetColor(119, 178, 85)
                .SetDescription(e.Locale.GetString("miki_module_admin_prune_no_arg"))
                .ToEmbed()
                .QueueToChannelAsync(e.Channel);
                return;
            }

            int    amount = _amount;
            string filter = _filter;

            string[] argsSplit = e.Arguments.ToString().Split(' ');
            ulong    target    = e.message.MentionedUserIds.Count > 0 ? (await e.Guild.GetMemberAsync(e.message.MentionedUserIds.First())).Id : _target;

            if (int.TryParse(argsSplit[0], out amount))
            {
                if (amount < 0)
                {
                    await Utils.ErrorEmbed(e, e.Locale.GetString("miki_module_admin_prune_error_negative"))
                    .ToEmbed().QueueToChannelAsync(e.Channel);

                    return;
                }
                if (amount > 100)
                {
                    await Utils.ErrorEmbed(e, e.Locale.GetString("miki_module_admin_prune_error_max"))
                    .ToEmbed().QueueToChannelAsync(e.Channel);

                    return;
                }
            }
            else
            {
                await Utils.ErrorEmbed(e, e.Locale.GetString("miki_module_admin_prune_error_parse"))
                .ToEmbed().QueueToChannelAsync(e.Channel);

                return;
            }

            if (Regex.IsMatch(e.Arguments.ToString(), "\"(.*?)\""))
            {
                Regex regex = new Regex("\"(.*?)\"");
                filter = regex.Match(e.Arguments.ToString()).ToString().Trim('"', ' ');
            }

            await e.message.DeleteAsync();             // Delete the calling message before we get the message history.

            IEnumerable <IDiscordMessage> messages = await e.Channel.GetMessagesAsync(amount);

            List <IDiscordMessage> deleteMessages = new List <IDiscordMessage>();

            amount = messages.Count();

            if (amount < 1)
            {
                await e.message.DeleteAsync();

                await e.ErrorEmbed(e.Locale.GetString("miki_module_admin_prune_no_messages", ">"))
                .ToEmbed().QueueToChannelAsync(e.Channel);

                return;
            }
            for (int i = 0; i < amount; i++)
            {
                if (target != 0 && messages.ElementAt(i)?.Author.Id != target)
                {
                    continue;
                }

                if (filter != null && messages.ElementAt(i)?.Content.IndexOf(filter) < 0)
                {
                    continue;
                }

                if (messages.ElementAt(i).Timestamp.AddDays(14) > DateTime.Now)
                {
                    deleteMessages.Add(messages.ElementAt(i));
                }
            }

            if (deleteMessages.Count > 0)
            {
                await e.Channel.DeleteMessagesAsync(deleteMessages.ToArray());
            }

            string[] titles = new string[]
            {
                "POW!",
                "BANG!",
                "BAM!",
                "KAPOW!",
                "BOOM!",
                "ZIP!",
                "ZING!",
                "SWOOSH!",
                "POP!"
            };

            (await new EmbedBuilder
            {
                Title = titles[MikiRandom.Next(titles.Length - 1)],
                Description = e.Locale.GetString("miki_module_admin_prune_success", deleteMessages.Count),
                Color = new Color(1, 1, 0.5f)
            }.ToEmbed().QueueToChannelAsync(e.Channel))
            .ThenWait(5000)
            .ThenDelete();
        }
Ejemplo n.º 14
0
        public async Task <List <EventMessageObject> > GetMessage(IGuild guild, EventMessageType type, IUser user)
        {
            long guildId = guild.Id.ToDbLong();

            var channels = await guild.GetTextChannelsAsync();

            var channelIds = channels.Select(x => x.Id.ToDbLong());

            var guildCount = (await guild.GetUsersAsync()).Count;

            IGuildUser owner = await guild.GetOwnerAsync();

            var ownerMention = owner.Mention;
            var ownerName    = owner.Username;

            List <EventMessageObject> output = new List <EventMessageObject>();

            using (var context = new MikiContext())
            {
                var messageObjects = await context.EventMessages.Where(x => channelIds.Contains(x.ChannelId) && (short)type == x.EventType).ToListAsync();

                var allUsers = await guild.GetUsersAsync();

                foreach (var c in messageObjects)
                {
                    if (c == null)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(c.Message))
                    {
                        continue;
                    }

                    string modifiedMessage = c.Message;

                    modifiedMessage = modifiedMessage.Replace("-um", user.Mention);
                    modifiedMessage = modifiedMessage.Replace("-uc", (await(user as IGuildUser).Guild.GetUsersAsync()).Count.ToString());
                    modifiedMessage = modifiedMessage.Replace("-u", user.Username);

                    modifiedMessage = modifiedMessage.Replace("-ru", allUsers.ElementAt(MikiRandom.Next(0, allUsers.Count)).Username);

                    modifiedMessage = modifiedMessage.Replace("-now", DateTime.Now.ToShortDateString());
                    modifiedMessage = modifiedMessage.Replace("-sc", guildCount.ToString());
                    modifiedMessage = modifiedMessage.Replace("-s", (user as IGuildUser).Guild.Name);


                    modifiedMessage = modifiedMessage.Replace("-om", ownerMention);
                    modifiedMessage = modifiedMessage.Replace("-o", ownerName);

                    modifiedMessage = modifiedMessage.Replace("-cc", (await(user as IGuildUser).Guild.GetChannelsAsync()).Count.ToString());
                    modifiedMessage = modifiedMessage.Replace("-vc", (await(user as IGuildUser).Guild.GetVoiceChannelsAsync()).Count.ToString());

                    output.Add(new EventMessageObject()
                    {
                        message            = modifiedMessage,
                        destinationChannel = channels.FirstOrDefault(x => x.Id.ToDbLong() == c.ChannelId)
                    });
                }
                return(output);
            }
        }
Ejemplo n.º 15
0
        public async Task PruneAsync(EventContext e, int _amount = 100, ulong _target = 0)
        {
            IDiscordGuildUser invoker = await e.Guild.GetSelfAsync();

            if (!(await(e.Channel as IDiscordGuildChannel).GetPermissionsAsync(invoker)).HasFlag(GuildPermission.ManageMessages))
            {
                e.Channel.QueueMessageAsync(e.GetResource("miki_module_admin_prune_error_no_access"));
                return;
            }

            int amount = _amount;

            string[] argsSplit = e.Arguments.ToString().Split(' ');
            ulong    target    = e.message.MentionedUserIds.Count > 0 ? (await e.Guild.GetUserAsync(e.message.MentionedUserIds.First())).Id : _target;

            if (!string.IsNullOrEmpty(argsSplit[0]))
            {
                if (int.TryParse(argsSplit[0], out amount))
                {
                    if (amount < 0)
                    {
                        Utils.ErrorEmbed(e, e.GetResource("miki_module_admin_prune_error_negative"))
                        .ToEmbed().QueueToChannel(e.Channel);
                        return;
                    }
                    if (amount > 100)
                    {
                        Utils.ErrorEmbed(e, e.GetResource("miki_module_admin_prune_error_max"))
                        .ToEmbed().QueueToChannel(e.Channel);
                        return;
                    }
                }
                else
                {
                    Utils.ErrorEmbed(e, e.GetResource("miki_module_admin_prune_error_parse"))
                    .ToEmbed().QueueToChannel(e.Channel);
                    return;
                }
            }

            await e.message.DeleteAsync();             // Delete the calling message before we get the message history.

            //IEnumerable<IDiscordMessage> messages = await e.Channel.GetMessagesAsync(amount).FlattenAsync();
            List <IDiscordMessage> deleteMessages = new List <IDiscordMessage>();

            //amount = messages.Count(); // Checks if the amount of messages to delete is more than the amount of messages availiable.

            //if (amount < 1)
            //{
            //	string prefix = await e.commandHandler.GetPrefixAsync(e.Guild.Id);
            //	await e.message.DeleteAsync();

            //	e.ErrorEmbed(e.GetResource("miki_module_admin_prune_no_messages", prefix))
            //		.ToEmbed().QueueToChannel(e.Channel);
            //	return;
            //}

            //for (int i = 0; i < amount; i++)
            //{
            //	if (target != 0 && messages.ElementAt(i)?.Author.Id != target)
            //		continue;

            //	if (messages.ElementAt(i).Timestamp.AddDays(14) > DateTime.Now)
            //	{
            //		deleteMessages.Add(messages.ElementAt(i));
            //	}
            //}

            //if (deleteMessages.Count > 0)
            //{
            //	await e.Channel.DeleteMessagesAsync(deleteMessages);
            //}

            Task.WaitAll();

            string[] titles = new string[]
            {
                "POW!",
                "BANG!",
                "BAM!",
                "KAPOW!",
                "BOOM!",
                "ZIP!",
                "ZING!",
                "SWOOSH!",
                "POP!"
            };

            EmbedBuilder embed = Utils.Embed;

            embed.Title       = titles[MikiRandom.Next(titles.Length - 1)];
            embed.Description = e.GetResource("miki_module_admin_prune_success", deleteMessages.Count);

            embed.Color = new Color(1, 1, 0.5f);

            IDiscordMessage _dMessage = await embed.ToEmbed().SendToChannel(e.Channel);

            Task.Run(async() =>
            {
                await Task.Delay(5000);
                await _dMessage.DeleteAsync();
            });
        }
Ejemplo n.º 16
0
        public async Task GiveawayAsync(EventContext e)
        {
            DiscordEmoji emoji = new DiscordEmoji();

            emoji.Name = "🎁";

            e.Arguments.Take(out string giveawayText);

            while (!e.Arguments.Pack.Peek().StartsWith("-"))
            {
                giveawayText += " " + e.Arguments.Pack.Take();
            }

            var mml = new MMLParser(e.Arguments.Pack.TakeAll()).Parse();

            int      amount   = mml.Get("amount", 1);
            TimeSpan timeLeft = mml.Get("time", "1h").GetTimeFromString();

            if (amount > 10)
            {
                await e.ErrorEmbed("We can only allow up to 10 picks per giveaway")
                .ToEmbed().QueueToChannelAsync(e.Channel);

                return;
            }

            giveawayText = giveawayText + ((amount > 1) ? " x " + amount : "");

            List <IDiscordUser> winners = new List <IDiscordUser>();

            IDiscordMessage msg = await CreateGiveawayEmbed(e, giveawayText)
                                  .AddField("Time", timeLeft.ToTimeString(e.Locale), true)
                                  .AddField("React to participate", "good luck", true)
                                  .ToEmbed().SendToChannel(e.Channel);

            await msg.CreateReactionAsync(emoji);

            int updateTask = -1;

            int task = taskScheduler.AddTask(e.Author.Id, async(desc) =>
            {
                msg = await e.Channel.GetMessageAsync(msg.Id);

                if (msg != null)
                {
                    await msg.DeleteReactionAsync(emoji);

                    await Task.Delay(1000);

                    var reactions = await msg.GetReactionsAsync(emoji);

                    //do
                    //{
                    //	reactions.AddRange();
                    //	reactionsGained += 100;
                    //} while (reactions.Count == reactionsGained);

                    // Select random winners
                    for (int i = 0; i < amount; i++)
                    {
                        if (reactions.Count == 0)
                        {
                            break;
                        }

                        int index = MikiRandom.Next(reactions.Count);
                        winners.Add(reactions[index]);
                    }

                    if (updateTask != -1)
                    {
                        taskScheduler.CancelReminder(e.Author.Id, updateTask);
                    }

                    string winnerText = string.Join("\n", winners.Select(x => x.Username + "#" + x.Discriminator).ToArray());
                    if (string.IsNullOrEmpty(winnerText))
                    {
                        winnerText = "nobody!";
                    }

                    await msg.EditAsync(new EditMessageArgs
                    {
                        embed = CreateGiveawayEmbed(e, giveawayText)
                                .AddField("Winners", winnerText)
                                .ToEmbed()
                    });
                }
            }, "description var", timeLeft);
        }
Ejemplo n.º 17
0
        public async Task CheckAsync(IDiscordMessage e)
        {
            if (e.Author.IsBot)
            {
                return;
            }

            if (isSyncing)
            {
                return;
            }

            try
            {
                if (await e.GetChannelAsync() is IDiscordGuildChannel channel)
                {
                    string key = GetContextKey(channel.GuildId, e.Author.Id);

                    if (lastTimeExpGranted.GetOrAdd(e.Author.Id, DateTime.Now).AddMinutes(1) < DateTime.Now)
                    {
                        int currentExp = 0;
                        if (!await Global.RedisClient.ExistsAsync(key))
                        {
                            using (var context = new MikiContext())
                            {
                                LocalExperience user = await LocalExperience.GetAsync(
                                    context,
                                    (long)channel.GuildId,
                                    e.Author
                                    );

                                await Global.RedisClient.AddAsync(key, user.Experience);

                                currentExp = user.Experience;
                            }
                        }
                        else
                        {
                            currentExp = await Global.RedisClient.GetAsync <int>(key);
                        }

                        var bonusExp = MikiRandom.Next(1, 4);
                        currentExp += bonusExp;

                        if (!experienceQueue.ContainsKey(e.Author.Id))
                        {
                            var expObject = new ExperienceAdded()
                            {
                                UserId     = e.Author.Id.ToDbLong(),
                                GuildId    = channel.GuildId.ToDbLong(),
                                Experience = bonusExp,
                                Name       = e.Author.Username,
                            };

                            experienceQueue.AddOrUpdate(e.Author.Id, expObject, (u, eo) =>
                            {
                                eo.Experience += expObject.Experience;
                                return(eo);
                            });
                        }
                        else
                        {
                            experienceQueue[e.Author.Id].Experience += bonusExp;
                        }

                        int level = User.CalculateLevel(currentExp);

                        if (User.CalculateLevel(currentExp - bonusExp) != level)
                        {
                            await LevelUpLocalAsync(e, level);
                        }

                        lastTimeExpGranted.AddOrUpdate(e.Author.Id, DateTime.Now, (x, d) => DateTime.Now);

                        await Global.RedisClient.AddAsync(key, currentExp);
                    }
                }

                if (DateTime.Now >= lastDbSync + new TimeSpan(0, 1, 0))
                {
                    isSyncing = true;
                    Log.Message($"Applying Experience for {experienceQueue.Count} users");
                    lastDbSync = DateTime.Now;

                    try
                    {
                        await UpdateGlobalDatabase();
                        await UpdateLocalDatabase();
                        await UpdateGuildDatabase();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.Message + "\n" + ex.StackTrace);
                    }
                    finally
                    {
                        experienceQueue.Clear();
                        isSyncing = false;
                    }
                    Log.Message($"Done Applying!");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
Ejemplo n.º 18
0
 public async Task CakeAsync(CommandContext e)
 => await QueueAction(e, "feeds", cakeImages[MikiRandom.Next(cakeImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 19
0
 public async Task SlapAsync(CommandContext e)
 => await QueueAction(e, "slaps", slapImages[MikiRandom.Next(slapImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 20
0
 public async Task KissAsync(CommandContext e)
 => await QueueAction(e, "kisses", kissImages[MikiRandom.Next(kissImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 21
0
 public async Task LickAsync(CommandContext e)
 => await QueueAction(e, "licks", lickImages[MikiRandom.Next(lickImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 22
0
 public async Task HugAsync(CommandContext e)
 => await QueueAction(e, "hugs", hugImages[MikiRandom.Next(hugImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 23
0
 public async Task PunchAsync(CommandContext e)
 => await QueueAction(e, "punches", punchImages[MikiRandom.Next(punchImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 24
0
 public async Task HighFiveAsync(CommandContext e)
 => await QueueAction(e, "high-fives", highFiveImages[MikiRandom.Next(highFiveImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 25
0
 public async Task PunAsync(EventContext e)
 {
     e.Channel.QueueMessageAsync(e.GetResource(puns[MikiRandom.Next(0, puns.Length)]));
 }
Ejemplo n.º 26
0
 public async Task CuddleAsync(CommandContext e)
 => await QueueAction(e, "cuddles", cuddleImages[MikiRandom.Next(cuddleImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 27
0
        public async Task CryAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/TTUBf2r.gif",
                "http://i.imgur.com/TP6dYGh.gif",
                "http://i.imgur.com/o66oQyX.png",
                "http://i.imgur.com/6AP78bD.png",
                "http://i.imgur.com/IvMvs2K.gif",
                "http://i.imgur.com/0kdQ38I.gif",
                "http://i.imgur.com/0kdQ38I.gif",
                "http://i.imgur.com/YHYLO4E.gif",
                "http://i.imgur.com/wXqxiDs.gif",
                "http://i.imgur.com/jzafqAh.gif",
                "http://i.imgur.com/2HPoWSf.gif",
                "http://i.imgur.com/W7prbbo.gif",
                "http://i.imgur.com/cKqKcG3.gif",
                "http://i.imgur.com/GKO0EQD.gif",
                "http://i.imgur.com/cu825ub.gif",
                "http://i.imgur.com/TP6dYGh.gif",
                "http://i.imgur.com/uZ2WXyL.mp4",
                "http://i.imgur.com/DhkvnpB.gif",
                "http://i.imgur.com/LbpaJMG.gif",
                "http://i.imgur.com/V7iS3ZR.gif",
                "http://i.imgur.com/TLoHpfE.gif",
                "http://i.imgur.com/35tYOoB.gif",
                "http://i.imgur.com/Q6I2fiy.gif",
                "http://i.imgur.com/7Tw9dPP.gif",
                "http://i.imgur.com/aIiuJg8.gif",
                "http://i.imgur.com/0xIG1kG.gif",
                "http://i.imgur.com/nE0Tdp0.gif",
                "http://i.imgur.com/mvyAx5q.gif",
                "http://i.imgur.com/diq8LxU.mp4",
                "http://i.imgur.com/Zv7au0h.gif",
                "http://i.imgur.com/sOyqImI.gif",
                "http://i.imgur.com/ZRbHJcb.gif",
                "http://i.imgur.com/kysvK28.gif",
                "http://i.imgur.com/6tGAJ75.mp4",
                "http://i.imgur.com/5k6aD7Z.gif",
                "http://i.imgur.com/B29MytB.gif",
                "http://i.imgur.com/FQx8zRj.gif",
                "http://i.imgur.com/5vUBsz4.gif",
                "http://i.imgur.com/rBMTG5o.gif",
                "http://i.imgur.com/qfcReCj.gif",
                "http://i.imgur.com/CRdCCoH.gif",
                "http://i.imgur.com/FVt8Jqr.gif",
                "http://i.imgur.com/mjziZGI.gif",
                "http://i.imgur.com/DEgkwBe.gif",
                "http://i.imgur.com/hfRw1my.mp4",
                "http://i.imgur.com/Sus5vcM.gif",
                "http://i.imgur.com/HLmnS6S.gif",
                "http://i.imgur.com/w9UjKVR.gif",
                "http://i.imgur.com/QZvnKHs.gif",
                "http://i.imgur.com/Mw49bFm.gif",
                "http://i.imgur.com/UVxws3C.gif",
                "http://i.imgur.com/ekhYSVB.gif",
                "http://i.imgur.com/VOMpsf6.mp4",
                "http://i.imgur.com/ZFnoy0i.gif",
                "http://i.imgur.com/180yuVH.gif",
                "http://i.imgur.com/3zVAY49.gif",
                "http://i.imgur.com/AFDevRo.gif",
                "http://i.imgur.com/T23nHVO.mp4",
                "http://i.imgur.com/qZWhIOw.gif",
                "http://i.imgur.com/Iy2VjHw.gif",
                "http://i.imgur.com/DbUYdpj.gif",
                "http://i.imgur.com/XqYZOiv.gif",
                "http://i.imgur.com/sYV2GBp.gif",
                "http://i.imgur.com/hxbNeGL.gif",
                "http://i.imgur.com/RXdJczP.gif",
                "http://i.imgur.com/JzmQgZq.gif",
                "http://i.imgur.com/NkLgdj8.gif",
                "http://i.imgur.com/kMzX2d4.gif",
                "http://i.imgur.com/WLNfW3d.gif",
                "http://i.imgur.com/Oxk8HUp.gif",
                "http://i.imgur.com/HTlRErM.gif",
                "http://i.imgur.com/KKgROec.gif",
                "http://i.imgur.com/W0WetV3.gif",
                "http://i.imgur.com/Ny9alj7.gif",
                "http://i.imgur.com/HNBYRZb.gif",
                "http://i.imgur.com/WOqFHee.gif",
                "http://i.imgur.com/rmlZXaP.gif",
                "http://i.imgur.com/mcVLAXi.gif",
                "http://i.imgur.com/SalWtcC.gif",
                "http://i.imgur.com/pkT7JFw.gif",
                "http://i.imgur.com/Tx15hPX.gif",
                "http://i.imgur.com/YANiZ2a.gif",
                "http://i.imgur.com/31WnXZ7.gif"
            };

            RuntimeEmbed em = new RuntimeEmbed(new Discord.EmbedBuilder())
            {
                ImageUrl = images[MikiRandom.Next(0, images.Length)]
            };
            await em.SendToChannel(e.Channel);
        }
Ejemplo n.º 28
0
 public async Task PetAsync(CommandContext e)
 => await QueueAction(e, "pats", patImages[MikiRandom.Next(patImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 29
0
 public async Task GlareAsync(CommandContext e)
 => await QueueAction(e, "glares at", glareImages[MikiRandom.Next(glareImages.Length)])
 .ConfigureAwait(false);
Ejemplo n.º 30
0
 public async Task BiteAsync(CommandContext e)
 => await QueueAction(e, "bites", biteImages[MikiRandom.Next(biteImages.Length)])
 .ConfigureAwait(false);