Exemple #1
0
        public async Task CuddleAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "https://67.media.tumblr.com/f50da0e6874bc235383fc435e61cd1dc/tumblr_inline_o34yoyT60F1tlr3az_500.gif",
                "https://66.media.tumblr.com/tumblr_ly6n2dCYM41rnw7hko1_500.gif",
                "http://imgur.com/8kLQ55E.gif",
                "https://66.media.tumblr.com/cb6bb8d0da432035722cd96835f20f0f/tumblr_nq2cyx3qYr1sa6ma2o1_500.gif",
                "http://i824.photobucket.com/albums/zz162/dovaiv/tumblr_mxbswzL1qT1sq9yswo1_500.gif",
                "http://33.media.tumblr.com/510818c33b426e9ba73f809daec3f045/tumblr_n2bye1AaeQ1tv44eho1_500.gif",
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} cuddles with {e.message.RemoveMentions(e.arguments)}";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} cuddles with {e.Author.Username}";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await e.Channel.SendMessage(embed);
        }
Exemple #2
0
        public async Task GlareAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/4pD5sX6.gif",
                "https://s-media-cache-ak0.pinimg.com/originals/22/b4/0c/22b40c79d48026cf62c95c31428a89a9.gif",
                "http://media.tumblr.com/a0a6f568bece2e789ec55304b049eb91/tumblr_inline_nmctxxyNkr1qf6el3.gif",
                "http://i.imgur.com/7dQBZ1l.gif",
                "http://33.media.tumblr.com/tumblr_m7xqc0bBeb1r56lqu.gif",
                "http://static.tumblr.com/3a85b35bec4523001cff5230d241632f/oistman/ABrmmaavy/tumblr_static_tumblr_mchtm5jbjo1rdol9po1_500.gif",
                "https://media.giphy.com/media/pKvo8d1PSpOOA/giphy.gif",
                "https://m.popkey.co/cd04de/eA1Re.gif",
                "https://media.tenor.co/images/386fb4996e952415422e4de3f7ff9273/tenor.gif",
                "http://68.media.tumblr.com/585b32983c5e57a30d3509b2e469bb7e/tumblr_ni8qhvXhcm1sr6y44o1_500.gif",
                "http://1.bp.blogspot.com/-2aRBZDBrkXA/U0xOOGakkII/AAAAAAAAA-M/0iwPpVvejGE/s1600/GEB08YD.gif",
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} glares at {e.message.RemoveMentions(e.arguments)}";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} glares at {e.Author.Username}";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await e.Channel.SendMessage(embed);
        }
Exemple #3
0
        public async Task KissAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://imgur.com/QIPaYW3.gif",
                "http://imgur.com/wx3WXZu.gif",
                "http://imgur.com/ZzIQwHP.gif",
                "http://imgur.com/z3TEGxp.gif",
                "http://imgur.com/kJEr7Vu.gif",
                "http://imgur.com/IsIR4V0.gif",
                "http://imgur.com/bmeCqLM.gif",
                "http://imgur.com/LBWIJpu.gif",
                "http://imgur.com/p6hNamc.gif",
                "http://imgur.com/PPw83Ug.gif",
                "http://imgur.com/lZ7gAES.gif",
                "http://imgur.com/Bftud8V.gif",
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} kisses {e.message.RemoveMentions(e.arguments)}";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} kisses {e.Author.Username}";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await e.Channel.SendMessage(embed);
        }
Exemple #4
0
        public async Task PetAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://imgur.com/Y2DrXtT.gif",
                "http://imgur.com/G7b4OnS.gif",
                "http://imgur.com/nQqH0Xa.gif",
                "http://imgur.com/mCtyWEr.gif",
                "http://imgur.com/Cju6UX3.gif",
                "http://imgur.com/0YkOcUC.gif",
                "http://imgur.com/QxZjpbV.gif",
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} pats {e.message.RemoveMentions(e.arguments)}";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} pats {e.Author.Username}";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await e.Channel.SendMessage(embed);
        }
Exemple #5
0
 public static async Task SendPM(IDiscordUser user, IDiscordEmbed embed, DatabaseSettingId settingId = DatabaseSettingId.PERSONALMESSAGE)
 {
     if (CanSendNotification(user.Id, DatabaseEntityType.USER, settingId))
     {
         await user.SendMessage(embed);
     }
 }
Exemple #6
0
        public async Task ConfigAsync(EventContext e)
        {
            IModule module = e.commandHandler.GetModule(e.arguments);

            if (module != null)
            {
                IDiscordEmbed embed = Utils.Embed.SetTitle(e.arguments.ToUpper());

                string content = "";

                foreach (RuntimeCommandEvent ev in module.Events.OrderBy((x) => x.Name))
                {
                    content += (await ev.IsEnabled(e.Channel.Id) ? "<:iconenabled:341251534522286080>" : "<:icondisabled:341251533754728458>") + " " + ev.Name + "\n";
                }

                embed.AddInlineField("Events", content);

                content = "";

                foreach (IService ev in module.Services.OrderBy((x) => x.Name))
                {
                    content += (await ev.IsEnabled(e.Channel.Id) ? "<:iconenabled:341251534522286080>" : "<:icondisabled:341251533754728458>") + " " + ev.Name + "\n";
                }

                if (!string.IsNullOrEmpty(content))
                {
                    embed.AddInlineField("Services", content);
                }

                embed.QueueToChannel(e.Channel);
            }
        }
Exemple #7
0
        public async Task InfoAsync(EventContext e)
        {
            IDiscordEmbed embed  = Utils.Embed;
            Locale        locale = new Locale(e.Channel.Id);

            embed.Author      = embed.CreateAuthor();
            embed.Author.Name = "Miki " + Bot.Instance.Information.Version;
            embed.SetColor(0.6f, 0.6f, 1.0f);

            embed.AddField(locale.GetString("miki_module_general_info_made_by_header"),
                           locale.GetString("miki_module_general_info_made_by_description") + " Drummss, Fuzen, IA, Luke, Milk, n0t, Phanrazak, Rappy, Tal, Vallode, GrammarJew");


            embed.AddField(e.GetResource("miki_module_general_info_links"),
                           $"`{locale.GetString("miki_module_general_info_docs").PadRight(15)}:` [documentation](https://www.github.com/velddev/miki/wiki)\n" +
                           $"`{"donate".PadRight(15)}:` [patreon](https://www.patreon.com/mikibot) | [ko-fi](https://ko-fi.com/velddy)\n" +
                           $"`{locale.GetString("miki_module_general_info_twitter").PadRight(15)}:` [veld](https://www.twitter.com/velddev) | [miki](https://www.twitter.com/miki_discord)\n" +
                           $"`{locale.GetString("miki_module_general_info_reddit").PadRight(15)}:` [/r/mikibot](https://www.reddit.com/r/mikibot) \n" +
                           $"`{locale.GetString("miki_module_general_info_server").PadRight(15)}:` [discord](https://discord.gg/55sAjsW)\n" +
                           $"`{locale.GetString("miki_module_general_info_website").PadRight(15)}:` [link](https://miki.ai)");

            embed.QueueToChannel(e.Channel);

            await Task.Yield();
        }
Exemple #8
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",
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} punches {e.message.RemoveMentions(e.arguments)}";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} punches {e.Author.Username}";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await embed.QueueToChannel(e.Channel);
        }
Exemple #9
0
        public async Task GetUserSeason(EventContext e)
        {
            int platform = 1;

            string[] arg      = e.arguments.Split(' ');
            int      seasonId = int.Parse(arg[1]);

            if (arg.Length > 2)
            {
                platform = GetPlatform(arg[2]);
            }

            IDiscordEmbed    embed = Utils.Embed;
            RocketLeagueUser user  = await TryGetUser(arg[0], platform);

            if (user == null)
            {
                embed.Title        = "Uh oh!";
                embed.Description  = $"We couldn't find a user with the name `{arg[0]}`. Please look up yourself on https://rlstats.com/ to create your profile!";
                embed.ThumbnailUrl = "http://miki.veld.one/assets/img/rlstats-logo.png";
                await e.Channel.SendMessage(embed);

                return;
            }

            embed.Title = $"{user.DisplayName}'s Season {arg[1]}";

            if (user.RankedSeasons.ContainsKey(seasonId))
            {
                Dictionary <int, RocketLeagueRankedStats> rankedseason = user.RankedSeasons[seasonId];

                foreach (RocketLeaguePlaylist playlist in api.playlists.Data)
                {
                    if (rankedseason.ContainsKey(playlist.Id))
                    {
                        if (playlist.PlatformId == platform)
                        {
                            RocketLeagueRankedStats stats = rankedseason[playlist.Id];

                            string           rank = "";
                            RocketLeagueTier t    = api.tiers.Data.Find(z => { return(z.Id == stats.Tier); });

                            if (t != null)
                            {
                                rank = t.Name + " " + stats.Division;

                                embed.AddField(f =>
                                {
                                    f.Name     = playlist.Name.Substring(7);
                                    f.Value    = $"Rank: {rank}\n\nMMR: {stats.RankPoints}\nMatches Played: {stats.MatchesPlayed}";
                                    f.IsInline = true;
                                });
                            }
                        }
                    }
                }
            }

            await e.Channel.SendMessage(embed);
        }
Exemple #10
0
        public static void SendAchievement(BaseAchievement d, IDiscordMessageChannel channel, IDiscordUser user)
        {
            IDiscordEmbed embed = Utils.Embed.SetTitle("Achievement Unlocked")
                                  .SetDescription($"{d.Icon} **{user.Username}#{user.Discriminator}** has unlocked the achievement **{d.Name}**! {d.Icon}");

            embed.QueueToChannel(channel);
        }
Exemple #11
0
        public async Task AchievementsAsync(EventContext e)
        {
            using (var context = new MikiContext())
            {
                long id = (e.message.MentionedUserIds.Count > 0) ? e.message.MentionedUserIds.First().ToDbLong() : e.Author.Id.ToDbLong();
                User u  = await context.Users.FindAsync(id);

                IDiscordUser discordUser = await e.Guild.GetUserAsync(id.FromDbLong());

                List <Achievement> achievements = await context.Achievements
                                                  .Where(x => x.Id == id)
                                                  .ToListAsync();

                IDiscordEmbed embed = Utils.Embed;

                embed.SetAuthor(u.Name + " | " + "Achievements", discordUser.AvatarUrl, "https://miki.ai/profiles/ID/achievements");

                StringBuilder leftBuilder = new StringBuilder();

                int totalScore = 0;

                foreach (var a in achievements)
                {
                    BaseAchievement metadata = AchievementManager.Instance.GetContainerById(a.Name).Achievements[a.Rank];
                    leftBuilder.AppendLine(metadata.Icon + " | `" + metadata.Name.PadRight(15) + $"{metadata.Points.ToString().PadLeft(3)} pts` | 📅 {a.UnlockedAt.ToShortDateString()}");
                    totalScore += metadata.Points;
                }

                await embed.AddInlineField("Total Pts: " + totalScore, leftBuilder.ToString())
                .SendToChannel(e.Channel);
            }
        }
Exemple #12
0
        public async Task ToggleGuildNotifications(EventContext e)
        {
            using (var context = new MikiContext())
            {
                Setting setting = await context.Settings.FindAsync(e.Guild.Id.ToDbLong(), DatabaseSettingId.CHANNELMESSAGE);

                if (setting == null)
                {
                    setting = context.Settings.Add(new Setting()
                    {
                        EntityId  = e.Guild.Id.ToDbLong(),
                        IsEnabled = true,
                        SettingId = DatabaseSettingId.CHANNELMESSAGE
                    }).Entity;
                }

                IDiscordEmbed embed  = Utils.Embed;
                Locale        locale = Locale.GetEntity(e.Channel.Id.ToDbLong());
                setting.IsEnabled = !setting.IsEnabled;

                string aa = (!setting.IsEnabled) ? locale.GetString("miki_generic_disabled") : locale.GetString("miki_generic_enabled");

                embed.Description = locale.GetString("miki_module_settings_guild_notifications", aa);
                embed.Color       = (setting.IsEnabled) ? new IA.SDK.Color(1, 0, 0) : new IA.SDK.Color(0, 1, 0);

                await context.SaveChangesAsync();

                await embed.QueueToChannel(e.Channel);
            }
        }
Exemple #13
0
        public async Task ToggleErrors(EventContext e)
        {
            using (var context = new MikiContext())
            {
                Setting setting = await context.Settings.FindAsync(e.Author.Id.ToDbLong(), DatabaseEntityType.USER, DatabaseSettingId.ERRORMESSAGE);

                if (setting == null)
                {
                    setting = context.Settings.Add(new Setting()
                    {
                        EntityId = e.Author.Id.ToDbLong(), EntityType = DatabaseEntityType.USER, IsEnabled = true, SettingId = DatabaseSettingId.ERRORMESSAGE
                    });
                }

                IDiscordEmbed embed  = Utils.Embed;
                Locale        locale = Locale.GetEntity(e.Channel.Id.ToDbLong());
                setting.IsEnabled = !setting.IsEnabled;

                string aa = (!setting.IsEnabled) ? locale.GetString("miki_generic_disabled") : locale.GetString("miki_generic_enabled");

                embed.Description = locale.GetString("miki_module_settings_error_dm", aa);
                embed.Color       = (setting.IsEnabled) ? new IA.SDK.Color(1, 0, 0) : new IA.SDK.Color(0, 1, 0);

                await context.SaveChangesAsync();

                await embed.SendToChannel(e.Channel);
            }
        }
Exemple #14
0
 public async Task ModifyAsync(IDiscordEmbed embed)
 {
     await(messageData as IUserMessage)?.ModifyAsync(x =>
     {
         x.Embed = ((embed as RuntimeEmbed) as IProxy <EmbedBuilder>).ToNativeObject().Build();
     });
 }
Exemple #15
0
        public async Task UrbanAsync(EventContext e)
        {
            if (string.IsNullOrEmpty(e.arguments))
            {
                return;
            }

            Locale               locale = new Locale(e.Channel.Id);
            UrbanDictionaryApi   api    = new UrbanDictionaryApi(Global.Config.UrbanKey);
            UrbanDictionaryEntry entry  = await api.GetEntryAsync(e.arguments);

            if (entry != null)
            {
                IDiscordEmbed embed = Utils.Embed
                                      .SetAuthor(entry.Term,
                                                 "http://cdn9.staztic.com/app/a/291/291148/urban-dictionary-647813-l-140x140.png",
                                                 "http://www.urbandictionary.com/define.php?term=" + e.arguments)
                                      .SetDescription(locale.GetString("miki_module_general_urban_author", entry.Author));

                embed.AddInlineField(locale.GetString("miki_module_general_urban_definition"), entry.Definition);
                embed.AddInlineField(locale.GetString("miki_module_general_urban_example"), entry.Example);
                embed.AddInlineField(locale.GetString("miki_module_general_urban_rating"), "👍 " + entry.ThumbsUp + "  👎 " + entry.ThumbsDown);

                embed.QueueToChannel(e.Channel);
            }
            else
            {
                e.ErrorEmbed(e.GetResource("error_term_invalid"))
                .QueueToChannel(e.Channel.Id);
            }
        }
Exemple #16
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"
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} pokes {e.message.RemoveMentions(e.arguments)}";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} pokes {e.Author.Username}";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await embed.QueueToChannel(e.Channel);
        }
Exemple #17
0
        public async Task HighFiveAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://imgur.com/LOoXzd9.gif",
                "http://imgur.com/Kwe6pAn.gif",
                "http://imgur.com/JeWzGGl.gif",
                "http://imgur.com/dqVx2oM.gif",
                "http://imgur.com/4n1K6kV.gif",
                "http://imgur.com/206dwM0.gif",
                "http://imgur.com/4ybFKuz.gif",
                "http://imgur.com/21e7SHD.gif",
                "http://imgur.com/LOCVVvL.gif",
                "http://imgur.com/h2KJJUA.gif",
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} high fives at {e.message.RemoveMentions(e.arguments)}";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} high fives at {e.Author.Username}";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await e.Channel.SendMessage(embed);
        }
Exemple #18
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",
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} slaps {e.message.RemoveMentions(e.arguments)}";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} slaps {e.Author.Username}";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await embed.QueueToChannel(e.Channel);
        }
Exemple #19
0
        public async Task CakeAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/CYyrjRQ.gif",
                "http://i.imgur.com/3nWbcNT.gif",
                "http://i.imgur.com/AhOVdff.gif",
                "http://i.imgur.com/QRJ6xqB.gif",
                "http://i.imgur.com/Fuc4BX7.gif",
                "http://i.imgur.com/VQjMsms.gif",
                "http://i.imgur.com/ZwJJzQu.gif",
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} feeds {e.message.RemoveMentions(e.arguments)} cake";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} feeds {e.Author.Username} cake";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await e.Channel.SendMessage(embed);
        }
Exemple #20
0
 public static async Task SendChannel(IDiscordMessageChannel channel, IDiscordEmbed message)
 {
     if (CanSendNotification(channel.Guild.Id, DatabaseEntityType.GUILD, DatabaseSettingId.CHANNELMESSAGE))
     {
         await channel.SendMessage(message);
     }
 }
Exemple #21
0
        public async Task CuddleAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/CEkg7K3.gif",
                "http://i.imgur.com/K4lYduH.gif",
                "http://i.imgur.com/8kLQ55E.gif",
                "http://i.imgur.com/kd0F5bV.gif",
                "http://i.imgur.com/zG60zPk.gif",
                "http://i.imgur.com/ct76LIg.gif",
                "http://i.imgur.com/guBWT22.gif",
                "http://i.imgur.com/Asnv32U.gif"
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

            if (e.arguments.Length > 0)
            {
                embed.Title = $"{e.Author.Username} cuddles with {e.message.RemoveMentions(e.arguments)}";
            }
            else
            {
                embed.Title = $"{e.message.Bot.Username} cuddles with {e.Author.Username}";
            }
            embed.ImageUrl = images[r.Next(0, images.Length)];

            await embed.QueueToChannel(e.Channel);
        }
Exemple #22
0
        public async Task WhoIsAsync(EventContext e)
        {
            ulong id = 0;

            if (string.IsNullOrEmpty(e.arguments))
            {
                id = e.Author.Id;
            }
            else if (e.message.MentionedUserIds.Count == 0)
            {
                id = ulong.Parse(e.arguments);
            }
            else
            {
                id = e.message.MentionedUserIds.First();
            }

            IDiscordUser user = await e.Guild.GetUserAsync(id);

            Locale l = Locale.GetEntity(e.Channel.Id.ToDbLong());

            IDiscordEmbed embed = Utils.Embed;

            embed.Title = $"Who is {(string.IsNullOrEmpty(user.Nickname) ? user.Username : user.Nickname)}!?";
            embed.Color = new Color(0.5f, 0, 1);

            embed.ImageUrl = (await e.Guild.GetUserAsync(id)).AvatarUrl;

            embed.AddInlineField(
                l.GetString("miki_module_whois_tag_personal"),
                $"User Id      : **{user.Id}**\nUsername: **{user.Username}#{user.Discriminator} {(string.IsNullOrEmpty(user.Nickname) ? "" : $"({user.Nickname})")}**\nCreated at: **{user.CreatedAt.ToString()}**\nJoined at   : **{user.JoinedAt.ToString()}**\n");
Exemple #23
0
        public async Task GuildTop(EventContext e)
        {
            int amountToSkip = 0;
            int amountToTake = 12;

            int.TryParse(e.arguments, out amountToSkip);

            using (var context = new MikiContext())
            {
                List <GuildUser> leaderboards = context.GuildUsers.OrderByDescending(x => x.Experience)
                                                .Skip(amountToSkip * amountToTake)
                                                .Take(amountToTake)
                                                .ToList();

                IDiscordEmbed embed = Utils.Embed
                                      .SetTitle(e.GetResource("guildtop_title"));

                foreach (GuildUser i in leaderboards)
                {
                    embed.AddInlineField(i.Name, i.Experience.ToString());
                }

                embed.SetFooter(e.GetResource("pasta_page_index", amountToSkip, "#"), null);

                await embed.SendToChannel(e.Channel);
            }
        }
Exemple #24
0
        public async Task GuildTop(EventContext e)
        {
            int amountToTake = 12;

            int.TryParse(e.arguments, out int amountToSkip);

            using (var context = new MikiContext())
            {
                int totalGuilds = (int)Math.Ceiling((double)await context.GuildUsers.CountAsync() / amountToTake);

                List <GuildUser> leaderboards = await context.GuildUsers.OrderByDescending(x => x.Experience)
                                                .Skip(amountToSkip * amountToTake)
                                                .Take(amountToTake)
                                                .ToListAsync();

                IDiscordEmbed embed = Utils.Embed
                                      .SetTitle(e.GetResource("guildtop_title"));

                foreach (GuildUser i in leaderboards)
                {
                    embed.AddInlineField(i.Name, i.Experience.ToString());
                }

                embed.SetFooter(e.GetResource("page_index", amountToSkip + 1, totalGuilds), null);
                await embed.QueueToChannel(e.Channel);
            }
        }
Exemple #25
0
        public async Task UrbanAsync(EventContext e)
        {
            if (string.IsNullOrEmpty(e.arguments))
            {
                return;
            }

            Locale               locale = Locale.GetEntity(e.Channel.Id.ToDbLong());
            UrbanDictionaryApi   api    = new UrbanDictionaryApi(Global.UrbanKey);
            UrbanDictionaryEntry entry  = api.GetEntry(e.arguments);

            if (entry != null)
            {
                IDiscordEmbed embed = Utils.Embed
                                      .SetAuthor(entry.Term,
                                                 "http://cdn9.staztic.com/app/a/291/291148/urban-dictionary-647813-l-140x140.png",
                                                 "http://www.urbandictionary.com/define.php?term=" + e.arguments)
                                      .SetDescription(locale.GetString("miki_module_general_urban_author", entry.Author));

                embed.AddInlineField(locale.GetString("miki_module_general_urban_definition"), entry.Definition);
                embed.AddInlineField(locale.GetString("miki_module_general_urban_example"), entry.Example);
                embed.AddInlineField(locale.GetString("miki_module_general_urban_rating"), "👍 " + entry.ThumbsUp + "  👎 " + entry.ThumbsDown);

                await embed.SendToChannel(e.Channel);
            }
            else
            {
                await Utils.ErrorEmbed(locale, "This term couldn't been found!")
                .SendToChannel(e.Channel.Id);
            }
        }
Exemple #26
0
 public static async Task SendPM(IDiscordUser user, IDiscordEmbed embed, DatabaseSettingId settingId = DatabaseSettingId.PERSONALMESSAGE)
 {
     if (CanSendNotification(user.Id, settingId))
     {
         await embed.QueueToUser(user);
     }
 }
Exemple #27
0
        public async Task PrefixAsync(EventContext e)
        {
            Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong());

            if (string.IsNullOrEmpty(e.arguments))
            {
                await e.Channel.SendMessage(Utils.ErrorEmbed(locale, locale.GetString("miki_module_general_prefix_error_no_arg")));

                return;
            }

            await PrefixInstance.Default.ChangeForGuildAsync(e.Guild.Id, e.arguments);

            IDiscordEmbed embed = Utils.Embed;

            embed.Title       = locale.GetString("miki_module_general_prefix_success_header");
            embed.Description = locale.GetString("miki_module_general_prefix_success_message", e.arguments);

            embed.AddField(f =>
            {
                f.Name  = locale.GetString("miki_module_general_prefix_example_command_header");
                f.Value = $"{e.arguments}profile";
            });

            await e.Channel.SendMessage(embed);
        }
Exemple #28
0
        public async Task SpellCheckAsync(EventContext context)
        {
            IDiscordEmbed embed = Utils.Embed;

            embed.SetTitle("Spellcheck - top results");

            API.StringComparison.StringComparer          sc   = new API.StringComparison.StringComparer(context.commandHandler.GetAllEventNames());
            List <API.StringComparison.StringComparison> best = sc.CompareToAll(context.arguments)
                                                                .OrderBy(z => z.score)
                                                                .ToList();
            int x = 1;

            foreach (API.StringComparison.StringComparison c in best)
            {
                embed.AddInlineField($"#{x}", c);
                x++;
                if (x > 16)
                {
                    break;
                }
            }

            embed.QueueToChannel(context.Channel);

            await Task.Yield();
        }
Exemple #29
0
 public static IDiscordEmbed RenderLeaderboards(IDiscordEmbed embed, List <LeaderboardsItem> items)
 {
     for (int i = 0; i < (items.Count > 12 ? 12 : items.Count); i++)
     {
         embed.AddInlineField($"#{i+1}: " + items[i].Name, items[i].Value);
     }
     return(embed);
 }
Exemple #30
0
        public async Task SteamRequestHandler(EventContext context)
        {
            IDiscordEmbed embed = Utils.Embed;

            embed.SetAuthor(steamAuthorName, steamAuthorIcon, "");
            embed.Description = "Steam API at your fingertips.\nYou can find a list of commands by typing `" + ">" + "help steam`!";
            embed.QueueToChannel(context.Channel);
        }