Esempio n. 1
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 embed.SendToChannel(e.Channel);

                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.AddInlineField(playlist.Name.Substring(7), $"Rank: {rank}\n\nMMR: {stats.RankPoints}\nMatches Played: {stats.MatchesPlayed}");
                            }
                        }
                    }
                }
            }

            await embed.SendToChannel(e.Channel);
        }
Esempio n. 2
0
        public async Task GetUser(EventContext e)
        {
            string[] arg      = e.arguments.Split(' ');
            int      platform = 1;

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

            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 embed.SendToChannel(e.Channel);

                return;
            }

            embed.Title = user.DisplayName;

            foreach (RocketLeagueSeason season in api.seasons.Data)
            {
                if (user.RankedSeasons.ContainsKey(season.Id))
                {
                    Dictionary <int, RocketLeagueRankedStats> rankedseason = user.RankedSeasons[season.Id];
                    string s = "";

                    foreach (RocketLeaguePlaylist playlist in api.playlists.Data)
                    {
                        if (rankedseason.ContainsKey(playlist.Id))
                        {
                            if (playlist.PlatformId == platform)
                            {
                                RocketLeagueRankedStats stats = rankedseason[playlist.Id];
                                s += "`" + playlist.Name.Substring(7).PadRight(13) + ":` " + stats.RankPoints.ToString() + " MMR\n";
                            }
                        }
                    }

                    embed.AddInlineField("Season" + season.Id, s);
                }
            }

            embed.ThumbnailUrl = user.AvatarUrl;
            embed.ImageUrl     = user.SignatureUrl;
            await embed.SendToChannel(e.Channel);
        }
Esempio n. 3
0
        public async Task ToggleGuildNotifications(EventContext e)
        {
            using (var context = new MikiContext())
            {
                Setting setting = await context.Settings.FindAsync(e.Guild.Id.ToDbLong(), DatabaseEntityType.GUILD, DatabaseSettingId.CHANNELMESSAGE);

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

                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.SendToChannel(e.Channel);
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        public async Task PokeAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://imgur.com/WG8EKwM.gif",
                "http://imgur.com/dfoxby7.gif",
                "http://imgur.com/TzD1Ngz.gif",
                "http://imgur.com/i1hwvQu.gif",
                "http://imgur.com/bStOFsM.gif",
                "http://imgur.com/1PBeB9H.gif",
                "http://imgur.com/3kerpju.gif",
                "http://imgur.com/uMBRFjX.gif",
                "http://imgur.com/YDJFoBV.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.SendToChannel(e.Channel);
        }
Esempio n. 6
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 embed.SendToChannel(e.Channel);
        }
Esempio n. 7
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://imgur.com/iekwz4h.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} 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.SendToChannel(e.Channel);
        }
Esempio n. 8
0
 public static async Task SendChannel(IDiscordMessageChannel channel, IDiscordEmbed message)
 {
     if (CanSendNotification(channel.Guild.Id, DatabaseEntityType.GUILD, DatabaseSettingId.CHANNELMESSAGE))
     {
         await message.SendToChannel(channel);
     }
 }
Esempio n. 9
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",
                "http://i.imgur.com/NupHmFh.gif",
                "http://i.imgur.com/5bnJJKq.gif",
                "http://i.imgur.com/eIMcqa9.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 embed.SendToChannel(e.Channel);
        }
Esempio n. 10
0
        public async Task CuddleAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/CEkg7K3.gif",
                "http://i.imgur.com/K4lYduH.gif",
                "http://imgur.com/8kLQ55E.gif",
                "http://i.imgur.com/kd0F5bV.gif",
                "http://imgur.com/zG60zPk.gif",
                "http://i.imgur.com/ct76LIg.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.SendToChannel(e.Channel);
        }
Esempio n. 11
0
        public async Task GuildTop(EventContext e)
        {
            int amountToTake = 12;

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

            using (var context = new MikiContext())
            {
                int totalGuilds = await context.GuildUsers.CountAsync() / 12;

                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, totalGuilds), null);
                await embed.SendToChannel(e.Channel);
            }
        }
Esempio n. 12
0
        public async Task ConfigAsync(EventContext e)
        {
            IModule module = e.commandHandler.GetModule(e.arguments);

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

                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";
                }

                embed.AddInlineField("Services", content);

                await embed.SendToChannel(e.Channel);
            }
        }
Esempio n. 13
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.SendToChannel(e.Channel);
        }
Esempio n. 14
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`!";
            await embed.SendToChannel(context.Channel);
        }
Esempio n. 15
0
        public async Task FavouritePastaList(EventContext e, bool lovedPastas = true)
        {
            Locale       locale       = Locale.GetEntity(e.Channel.Id.ToDbLong());
            IDiscordUser targetUser   = e.Author;
            float        totalPerPage = 25f;
            int          page         = 0;

            if (e.message.MentionedUserIds.Count() >= 1)
            {
                targetUser = await e.Guild.GetUserAsync(e.message.MentionedUserIds.First());

                string[] args = e.arguments.Split(' ');
                int.TryParse((args.Count() > 1 ? args[1] : "0"), out page);
                page -= page <= 0 ? 0 : 1;
            }
            else
            {
                int.TryParse(e.arguments, out page);
                page -= 1;
            }

            using (MikiContext context = new MikiContext())
            {
                long authorId = targetUser.Id.ToDbLong();
                IEnumerable <PastaVote> pastaVotes = context.Votes.Where(x => x.__UserId == authorId && x.PositiveVote == lovedPastas);

                int maxPage = (int)Math.Floor(pastaVotes.Count() / totalPerPage);
                page = page > maxPage ? maxPage : page;
                page = page < 0 ? 0 : page;


                if (pastaVotes.Count() <= 0)
                {
                    string loveString  = (lovedPastas ? locale.GetString("miki_module_pasta_loved") : locale.GetString("miki_module_pasta_hated"));
                    string errorString = locale.GetString("miki_module_pasta_favlist_self_none", loveString);
                    if (e.message.MentionedUserIds.Count() >= 1)
                    {
                        errorString = locale.GetString("miki_module_pasta_favlist_mention_none", loveString);
                    }
                    await Utils.ErrorEmbed(e, errorString).SendToChannel(e.Channel.Id);

                    return;
                }

                IDiscordEmbed    embed        = Utils.Embed;
                List <PastaVote> neededPastas = pastaVotes.Skip((int)totalPerPage * page).Take((int)totalPerPage).ToList();

                string resultString = "";
                neededPastas.ForEach(x => { resultString += "`" + x.Id + "` "; });

                string useName = string.IsNullOrEmpty(targetUser.Nickname) ? targetUser.Username : targetUser.Nickname;
                embed.SetTitle($"{( lovedPastas ? locale.GetString( "miki_module_pasta_loved_header" ) : locale.GetString( "miki_module_pasta_hated_header" ) )} - {useName}");
                embed.SetDescription(resultString);
                embed.SetFooter(locale.GetString("page_index", page + 1, Math.Ceiling(pastaVotes.Count() / totalPerPage)), "");

                await embed.SendToChannel(e.Channel);
            }
        }
Esempio n. 16
0
        public async Task SearchPasta(EventContext e)
        {
            Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong());

            if (string.IsNullOrWhiteSpace(e.arguments))
            {
                await Utils.ErrorEmbed(locale, e.GetResource("searchpasta_error_no_arg"))
                .SendToChannel(e.Channel.Id);

                return;
            }

            List <string> arguments = e.arguments.Split(' ').ToList();
            int           page      = 0;

            if (arguments.Count > 1)
            {
                if (int.TryParse(arguments[arguments.Count - 1], out page))
                {
                    page -= 1;
                }
            }

            string query = arguments[0];

            using (var context = new MikiContext())
            {
                var pastasFound = await context.Pastas.Where(x => x.Id.Contains(query))
                                  .OrderByDescending(x => x.Id)
                                  .Skip(25 * page)
                                  .Take(25)
                                  .ToListAsync();


                var totalCount = await context.Pastas.Where(x => x.Id.Contains(query))
                                 .CountAsync();

                if (pastasFound?.Count > 0)
                {
                    string resultString = "";

                    pastasFound.ForEach(x => { resultString += "`" + x.Id + "` "; });

                    IDiscordEmbed embed = Utils.Embed;
                    embed.Title       = e.GetResource("miki_module_pasta_search_header");
                    embed.Description = resultString;
                    embed.CreateFooter();
                    embed.Footer.Text = e.GetResource("pasta_page_index", page + 1, (Math.Ceiling((double)totalCount / 25)).ToString());

                    await embed.SendToChannel(e.Channel);

                    return;
                }

                await Utils.ErrorEmbed(locale, e.GetResource("miki_module_pasta_search_error_no_results", arguments[0]))
                .SendToChannel(e.Channel);
            }
        }
Esempio n. 17
0
        public async Task GetNowPlaying(EventContext e)
        {
            int platform = -1;

            if (!string.IsNullOrWhiteSpace(e.arguments))
            {
                platform = GetPlatform(e.arguments);
            }

            Dictionary <int, RocketLeaguePlaylist> d = new Dictionary <int, RocketLeaguePlaylist>();

            if (platform == -1)
            {
                foreach (RocketLeaguePlaylist p in api.playlists.Data)
                {
                    if (d.ContainsKey(p.Id))
                    {
                        d[p.Id].Population.Players += p.Population.Players;
                    }
                    else
                    {
                        RocketLeaguePlaylist playlist = new RocketLeaguePlaylist()
                        {
                            Id         = p.Id,
                            Name       = p.Name,
                            PlatformId = p.PlatformId,
                            Population = new RocketLeaguePopulation()
                            {
                                Players = p.Population.Players
                            }
                        };

                        d.Add(p.Id, playlist);
                    }
                }
            }
            else
            {
                foreach (RocketLeaguePlaylist p in api.playlists.Data)
                {
                    if (p.PlatformId == platform)
                    {
                        d.Add(p.Id, p);
                    }
                }
            }

            IDiscordEmbed embed = Utils.Embed;

            embed.Title = "Now Playing!";
            foreach (RocketLeaguePlaylist p in d.Values)
            {
                embed.AddField(api.playlists.Data.Find(z => { return(z.Id == p.Id); }).Name, p.Population.Players.ToString());
            }

            await embed.SendToChannel(e.Channel);
        }
Esempio n. 18
0
        [Command(Name = "steamhelp")]           // TODO: Kill this command. >help steam should be used instead.
        public async Task SteamHelpAsync(EventContext context)
        {
            IDiscordEmbed embed = Utils.Embed;

            embed.SetAuthor(steamAuthorName, steamAuthorIcon, "");
            embed.Description = "Steam API at your fingertips.";
            embed.AddInlineField("Commands", "`>steam` \n`>steam user <vanity/steam64>`");
            await embed.SendToChannel(context.Channel);
        }
Esempio n. 19
0
        public async Task IdentifyPasta(EventContext e)
        {
            Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong());

            if (string.IsNullOrWhiteSpace(e.arguments))
            {
                await Utils.ErrorEmbed(locale, e.GetResource("infopasta_error_no_arg"))
                .SendToChannel(e.Channel.Id);

                return;
            }

            using (var context = MikiContext.CreateNoCache())
            {
                context.Set <GlobalPasta>().AsNoTracking();

                try
                {
                    GlobalPasta pasta = await context.Pastas.FindAsync(e.arguments);

                    if (pasta == null)
                    {
                        await Utils.ErrorEmbed(locale, e.GetResource("miki_module_pasta_error_null")).SendToChannel(e.Channel);

                        return;
                    }

                    User creator = await context.Users.FindAsync(pasta.creator_id);

                    IDiscordEmbed b = Utils.Embed;

                    b.SetAuthor(pasta.Id.ToUpper(), "", "");
                    b.Color = new IA.SDK.Color(47, 208, 192);

                    if (creator != null)
                    {
                        b.AddInlineField(e.GetResource("miki_module_pasta_identify_created_by"), $"{ creator.Name} [{creator.Id}]");
                    }

                    b.AddInlineField(e.GetResource("miki_module_pasta_identify_date_created"), pasta.date_created.ToShortDateString());

                    b.AddInlineField(e.GetResource("miki_module_pasta_identify_times_used"), pasta.TimesUsed.ToString());

                    VoteCount v = pasta.GetVotes(context);

                    b.AddInlineField(e.GetResource("infopasta_rating"), $"⬆️ { v.Upvotes} ⬇️ {v.Downvotes}");

                    await b.SendToChannel(e.Channel);
                }
                catch (Exception ex)
                {
                    Log.ErrorAt("IdentifyPasta", ex.Message);
                }
            }
        }
Esempio n. 20
0
        public async Task SetRoleLevelAsync(EventContext e)
        {
            using (var context = new MikiContext())
            {
                Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong());

                List <string> allArgs = new List <string>();
                allArgs.AddRange(e.arguments.Split(' '));
                if (allArgs.Count >= 2)
                {
                    int levelrequirement = int.Parse(allArgs[allArgs.Count - 1]);
                    allArgs.RemoveAt(allArgs.Count - 1);
                    IDiscordRole role = e.Guild.Roles.Find(r => r.Name.ToLower() == string.Join(" ", allArgs).TrimEnd(' ').TrimStart(' ').ToLower());

                    if (role == null)
                    {
                        await Utils.ErrorEmbed(locale, "Couldn't find this role. Please try again!").SendToChannel(e.Channel);

                        return;
                    }

                    LevelRole lr = await context.LevelRoles.FindAsync(e.Guild.Id.ToDbLong(), role.Id.ToDbLong());

                    if (lr == null)
                    {
                        lr = context.LevelRoles.Add(new LevelRole()
                        {
                            GuildId = e.Guild.Id.ToDbLong(), RoleId = role.Id.ToDbLong(), RequiredLevel = levelrequirement
                        });

                        IDiscordEmbed embed = Utils.Embed;
                        embed.Title       = "Added Role!";
                        embed.Description = $"I'll give someone the role {role.Name} when he/she reaches level {levelrequirement}!";
                        await embed.SendToChannel(e.Channel);
                    }
                    else
                    {
                        lr.RequiredLevel = levelrequirement;

                        IDiscordEmbed embed = Utils.Embed;
                        embed.Title       = "Updated Role!";
                        embed.Description = $"I'll give someone the role {role.Name} when he/she reaches level {levelrequirement}!";
                        await embed.SendToChannel(e.Channel);
                    }
                    await context.SaveChangesAsync();
                }
                else
                {
                    await Utils.ErrorEmbed(locale, "Make sure to fill out both the role and the level when creating this!").SendToChannel(e.Channel);
                }
            }
        }
Esempio n. 21
0
        public async Task DumpShards(EventContext context)
        {
            IDiscordEmbed embed = Utils.Embed;

            embed.Title = "Shards";

            foreach (DiscordSocketClient c in Bot.instance.Client.Shards)
            {
                embed.AddInlineField("Shard " + c.ShardId, $"State:  {c.ConnectionState}\nPing:   {c.Latency}\nGuilds: {c.Guilds.Count}");
            }

            await embed.SendToChannel(context.Channel);
        }
Esempio n. 22
0
        public async Task GuildProfile(EventContext context)
        {
            using (MikiContext database = new MikiContext())
            {
                GuildUser g = await database.GuildUsers.FindAsync(context.Guild.Id.ToDbLong());

                if (g == null)
                {
                    await GuildUser.Create(context.Guild);

                    g = await database.GuildUsers.FindAsync(context.Guild.Id.ToDbLong());
                }

                int rank  = g.GetGlobalRank();
                int level = g.CalculateLevel(g.Experience);

                EmojiBarSet onBarSet  = new EmojiBarSet("<:mbaronright:334479818924228608>", "<:mbaronmid:334479818848468992>", "<:mbaronleft:334479819003789312>");
                EmojiBarSet offBarSet = new EmojiBarSet("<:mbaroffright:334479818714513430>", "<:mbaroffmid:334479818504536066>", "<:mbaroffleft:334479818949394442>");

                EmojiBar expBar = new EmojiBar(g.CalculateMaxExperience(g.Experience), onBarSet, offBarSet, 6);

                IDiscordEmbed embed = Utils.Embed
                                      .SetAuthor(g.Name, context.Guild.AvatarUrl, "https://miki.veld.one")
                                      .SetColor(0.1f, 0.6f, 1)
                                      .SetThumbnailUrl("http://veld.one/assets/img/transparentfuckingimage.png")
                                      .AddInlineField(context.GetResource("miki_terms_level"), level.ToString());

                string expBarString = await expBar.Print(g.Experience, context.Channel);

                if (string.IsNullOrWhiteSpace(expBarString))
                {
                    embed.AddInlineField(context.GetResource("miki_terms_experience"), "[" + g.Experience + " / " + g.CalculateMaxExperience(g.Experience) + "]");
                }
                else
                {
                    embed.AddInlineField(context.GetResource("miki_terms_experience") + $" [{g.Experience} / {g.CalculateMaxExperience(g.Experience)}]", expBarString);
                }

                embed.AddInlineField(context.GetResource("miki_terms_rank"), "#" + ((rank <= 10) ? $"**{rank}**" : rank.ToString()))
                .AddInlineField(context.GetResource("miki_module_general_guildinfo_users"), g.UserCount.ToString());

                if (g.RivalId != 0)
                {
                    GuildUser rival = await g.GetRival();

                    embed.AddInlineField(context.GetResource("miki_terms_rival"), $"{rival.Name} [{rival.Experience}]");
                }

                await embed.SendToChannel(context.Channel);
            }
        }
Esempio n. 23
0
        public async Task SyncAvatarAsync(EventContext e)
        {
            string localFilename = @"c:\inetpub\miki.veld.one\assets\img\user\" + e.Author.Id + ".png";

            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(e.Author.GetAvatarUrl());
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            // Check that the remote file was found. The ContentType
            // check is performed since a request for a non-existent
            // image file might be redirected to a 404-page, which would
            // yield the StatusCode "OK", even though the image was not
            // found.
            if ((response.StatusCode == HttpStatusCode.OK ||
                 response.StatusCode == HttpStatusCode.Moved ||
                 response.StatusCode == HttpStatusCode.Redirect) &&
                response.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase))
            {
                // if the remote file was found, download oit
                using (Stream inputStream = response.GetResponseStream())
                    using (Stream outputStream = File.OpenWrite(localFilename))
                    {
                        byte[] buffer = new byte[4096];
                        int    bytesRead;
                        do
                        {
                            bytesRead = inputStream.Read(buffer, 0, buffer.Length);
                            outputStream.Write(buffer, 0, bytesRead);
                        } while (bytesRead != 0);
                    }
            }

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

                if (user == null)
                {
                    return;
                }
                user.AvatarUrl = e.Author.Id.ToString();
                await context.SaveChangesAsync();
            }

            IDiscordEmbed embed = Utils.Embed;

            embed.Title       = "👌 OKAY";
            embed.Description = "I've synchronized your current avatar to Miki's database!";
            await embed.SendToChannel(e.Channel);
        }
Esempio n. 24
0
        private async Task StartFlip(EventContext e, int bet)
        {
            string[] arguments = e.arguments.Split(' ');

            if (arguments.Length < 2)
            {
                return;
            }

            int pickedSide = -1;

            if (arguments[1].ToLower() == "heads" || arguments[1].ToLower() == "h")
            {
                pickedSide = 1;
            }
            else if (arguments[1].ToLower() == "tails" || arguments[1].ToLower() == "t")
            {
                pickedSide = 0;
            }

            if (pickedSide == -1)
            {
                return;
            }

            string headsUrl = "https://miki.ai/assets/img/miki-default-heads.png";
            string tailsUrl = "https://miki.ai/assets/img/miki-default-tails.png";

            if (e.arguments.Contains("-bonus"))
            {
                headsUrl = "https://miki.ai/assets/img/miki-secret-heads.png";
                tailsUrl = "https://miki.ai/assets/img/miki-secret-tails.png";
            }

            int    side     = MikiRandom.Next(2);
            string imageUrl = side == 1 ? headsUrl : tailsUrl;

            bool win = (side == pickedSide);



            IDiscordEmbed embed = Utils.Embed
                                  .SetAuthor(e.GetResource("flip_header") + " | " + e.Author.Username, e.Author.AvatarUrl,
                                             "https://patreon.com/mikibot")
                                  .SetImageUrl(imageUrl);

            await embed.SendToChannel(e.Channel);
        }
Esempio n. 25
0
        public async Task StatsAsync(EventContext e)
        {
            TimeSpan timeSinceStart = DateTime.Now.Subtract(Program.timeSinceStartup);

            IDiscordEmbed embed = Utils.Embed;

            embed.Title       = "⚙️ Miki stats";
            embed.Description = e.GetResource("stats_description");
            embed.Color       = new IA.SDK.Color(0.3f, 0.8f, 1);

            embed.AddInlineField($"🖥️ {e.GetResource("discord_servers")}", Bot.instance.Client.Guilds.Count.ToString());
            embed.AddInlineField("💬 Commands", Bot.instance.Events.CommandsUsed().ToString());
            embed.AddInlineField("⏰ Uptime", timeSinceStart.ToTimeString(e.Channel.GetLocale()));

            await embed.SendToChannel(e.Channel);
        }
Esempio n. 26
0
        public async Task HugAsync(EventContext e)
        {
            string[] images = new string[]
            {
                "http://i.imgur.com/FvSnQs8.gif",
                "http://i.imgur.com/rXEq7oU.gif",
                "http://i.imgur.com/b6vVMQO.gif",
                "http://i.imgur.com/KJNTXm3.gif",
                "http://i.imgur.com/gn18SX8.gif",
                "http://i.imgur.com/SUdqF9w.gif",
                "http://i.imgur.com/7C36d39.gif",
                "http://i.imgur.com/ZOINyyw.gif",
                "http://i.imgur.com/Imxjcio.gif",
                "http://i.imgur.com/GNUeLdo.gif",
                "http://i.imgur.com/K52NZ36.gif",
                "http://i.imgur.com/683fWwC.gif",
                "http://i.imgur.com/0RgdLt4.gif",
                "http://i.imgur.com/jxPPkM8.gif",
                "http://i.imgur.com/oExwffx.gif",
                "http://i.imgur.com/pCZpL5h.gif",
                "http://i.imgur.com/GvQOwuy.gif",
                "http://i.imgur.com/cLHRyeB.gif",
                "http://i.imgur.com/FVbzx1A.gif",
                "http://i.imgur.com/gMLlFNC.gif",
                "http://i.imgur.com/FOdbhav.gif",
                "http://i.imgur.com/CEkg7K3.gif",
                "http://i.imgur.com/MrEMpE6.gif",
                "http://i.imgur.com/Y9sMTP4.gif"
            };

            Random r = new Random();

            IDiscordEmbed embed = Utils.Embed;

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

            await embed.SendToChannel(e.Channel);
        }
Esempio n. 27
0
        public async Task SearchUser(EventContext e)
        {
            string[]                 arg   = e.arguments.Split(' ');
            IDiscordEmbed            embed = Utils.Embed;
            RocketLeagueSearchResult user  = await api.SearchUsersAsync(arg[0], (arg.Length >= 2)?int.Parse(arg[1]) : 0);

            embed.Title = $"Found {user.TotalResults} users with the name `{arg[0]}`";
            embed.CreateFooter();
            embed.Footer.Text = $"Page {user.Page} of ${(int)Math.Ceiling((double)user.TotalResults / user.MaxResultsPerPage)}";

            List <string> names = new List <string>();

            user.Data.ForEach(z => { names.Add(z.DisplayName); });

            embed.Description = string.Join(", ", names);

            await embed.SendToChannel(e.Channel);
        }
Esempio n. 28
0
        public async Task DoPastaLeaderboardsPopular(EventContext context)
        {
            using (var d = new MikiContext())
            {
                List <LeaderboardsItem> leaderboards = d.Database.SqlQuery <LeaderboardsItem>("select TOP 12 Id as Name, TimesUsed as Value from dbo.GlobalPastas as c order by Value DESC").ToList();

                IDiscordEmbed e = Utils.Embed
                                  .SetTitle("Most popular pastas")
                                  .SetColor(new IA.SDK.Color(1, 0.6f, 0.2f));

                foreach (LeaderboardsItem t in leaderboards)
                {
                    e.AddInlineField(t.Name, (t == leaderboards.First() ? "👑 " + t.Value.ToString() : "✨ " + t.Value.ToString()));
                }

                await e.SendToChannel(context.Channel.Id);
            }
        }
Esempio n. 29
0
        public async Task DoPastaLeaderboardsLove(EventContext context)
        {
            using (var d = new MikiContext())
            {
                List <LeaderboardsItem> leaderboards = d.Database.SqlQuery <LeaderboardsItem>("select TOP 12 Id as Name, ((SELECT Count(*) from Votes where Id = c.Id AND PositiveVote = 1) - (SELECT Count(*) from Votes where Id = c.Id AND PositiveVote = 0)) as Value from dbo.GlobalPastas as c order by Value DESC").ToList();

                IDiscordEmbed e = Utils.Embed
                                  .SetTitle("Top pastas")
                                  .SetColor(new IA.SDK.Color(1, 0, 0));

                foreach (LeaderboardsItem t in leaderboards)
                {
                    e.AddInlineField(t.Name, (t == leaderboards.First() ? "💖 " + t.Value.ToString() : (t.Value < 0 ? "💔 " : "❤ ") + t.Value.ToString()));
                }

                await e.SendToChannel(context.Channel.Id);
            }
        }
Esempio n. 30
0
        public async Task SteamGameAsync(EventContext context)
        {
            DateTime requestStart = DateTime.Now;

            string[] args = context.arguments.Split(' ');

            IDiscordEmbed embed = Utils.Embed;

            embed.SetAuthor("Steam Game", steamAuthorIcon, "");

            SteamGameInfo gameInfo = await steam.GetGameInfo(args[0]);

            embed.SetDescription(gameInfo.Name);
            embed.SetThumbnailUrl(gameInfo.HeaderImage);

            embed.SetFooter("Request took in " + Math.Round((DateTime.Now - requestStart).TotalMilliseconds) + "ms", "");
            await embed.SendToChannel(context.Channel);
        }