Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public async Task KickAsync(EventContext e)
        {
            List <string> arg        = e.arguments.Split(' ').ToList();
            IDiscordUser  bannedUser = null;
            Locale        locale     = Locale.GetEntity(e.Channel.Id.ToDbLong());

            if (e.message.MentionedUserIds.Count > 0)
            {
                bannedUser = await e.Guild.GetUserAsync(e.message.MentionedUserIds.First());
            }
            else
            {
                bannedUser = await e.Guild.GetUserAsync(ulong.Parse(e.arguments.Split(' ')[0]));
            }

            arg.RemoveAt(0);

            string reason = string.Join(" ", arg);

            IDiscordEmbed embed = Utils.Embed;

            embed.Title       = locale.GetString("miki_module_admin_kick_header");
            embed.Description = locale.GetString("miki_module_admin_kick_description", new object[] { e.Guild.Name });

            if (!string.IsNullOrWhiteSpace(reason))
            {
                embed.AddField(f =>
                {
                    f.Name     = locale.GetString("miki_module_admin_kick_reason");
                    f.Value    = reason;
                    f.IsInline = true;
                });
            }

            embed.AddField(f =>
            {
                f.Name     = locale.GetString("miki_module_admin_kick_by");
                f.Value    = e.Author.Username + "#" + e.Author.Discriminator;
                f.IsInline = true;
            });

            embed.Color = new Color(1, 1, 0);

            await bannedUser.SendMessage(embed);

            await bannedUser.Kick();
        }
Ejemplo n.º 5
0
        public async Task SoftbanAsync(EventContext e)
        {
            List <string> arg        = e.arguments.Split(' ').ToList();
            IDiscordUser  bannedUser = null;

            if (e.message.MentionedUserIds.Count > 0)
            {
                bannedUser = await e.Guild.GetUserAsync(e.message.MentionedUserIds.First());
            }
            else
            {
                bannedUser = await e.Guild.GetUserAsync(ulong.Parse(e.arguments.Split(' ')[0]));
            }

            arg.RemoveAt(0);

            string reason = string.Join(" ", arg);

            IDiscordEmbed embed = Utils.Embed;

            embed.Title       = "⚠ SOFTBAN";
            embed.Description = $"You've been banned from **{e.Guild.Name}**!";

            if (!string.IsNullOrWhiteSpace(reason))
            {
                embed.AddField(f =>
                {
                    f.Name     = "💬 Reason";
                    f.Value    = reason;
                    f.IsInline = true;
                });
            }

            embed.AddField(f =>
            {
                f.Name     = "💁 Banned by";
                f.Value    = e.Author.Username + "#" + e.Author.Discriminator;
                f.IsInline = true;
            });

            await bannedUser.SendMessage(embed);

            await bannedUser.Ban(e.Guild);

            await bannedUser.Unban(e.Guild);
        }
Ejemplo n.º 6
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();
                        playlist.Id                 = p.Id;
                        playlist.Name               = p.Name;
                        playlist.PlatformId         = p.PlatformId;
                        playlist.Population         = new RocketLeaguePopulation();
                        playlist.Population.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(f =>
                {
                    f.Name     = api.playlists.Data.Find(z => { return(z.Id == p.Id); }).Name;
                    f.Value    = p.Population.Players.ToString();
                    f.IsInline = true;
                });
            }

            await e.Channel.SendMessage(embed);
        }
Ejemplo n.º 7
0
        public void 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());
            }

            embed.QueueToChannel(e.Channel);
        }
Ejemplo n.º 8
0
        public async Task ShowProposalsAsync(EventContext e)
        {
            using (var context = new MikiContext())
            {
                List <Marriage> proposals = await Marriage.GetProposalsReceived(context, e.Author.Id.ToDbLong());

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

                foreach (Marriage p in proposals)
                {
                    User u = await context.Users.FindAsync(p.GetOther(e.Author.Id.ToDbLong()));

                    proposalNames.Add($"{u.Name} [{u.Id}]");
                }

                IDiscordEmbed embed = Utils.Embed;
                embed.Title       = e.Author.Username;
                embed.Description = "Here it shows both the people who you've proposed to and who have proposed to you.";

                string output = string.Join("\n", proposalNames);

                embed.AddField("Proposals Recieved", string.IsNullOrEmpty(output) ? "none (yet!)" : output);

                proposals = await Marriage.GetProposalsSent(context, e.Author.Id.ToDbLong());

                proposalNames = new List <string>();

                foreach (Marriage p in proposals)
                {
                    User u = await context.Users.FindAsync(p.GetOther(e.Author.Id.ToDbLong()));

                    proposalNames.Add($"{u.Name} [{u.Id}]");
                }

                output = string.Join("\n", proposalNames);

                embed.AddField("Proposals Sent", string.IsNullOrEmpty(output) ? "none (yet!)" : output);

                embed.Color        = new Miki.Common.Color(1, 0.5f, 0);
                embed.ThumbnailUrl = (await e.Guild.GetUserAsync(e.Author.Id)).AvatarUrl;
                embed.QueueToChannel(e.Channel);
            }
        }
Ejemplo n.º 9
0
        public async Task InfoAsync(EventContext e)
        {
            IDiscordEmbed embed  = Utils.Embed;
            Locale        locale = Locale.GetEntity(e.Channel.Id.ToDbLong());

            embed.Author      = embed.CreateAuthor();
            embed.Author.Name = "Miki " + Bot.instance.Version;
            embed.Color       = new Color(1, 0.6f, 0.6f);

            embed.AddField(locale.GetString("miki_module_general_info_made_by_header"), locale.GetString("miki_module_general_info_made_by_description"));

            embed.AddField("Links",
                           $"**{locale.GetString("miki_module_general_info_docs")}:** https://www.github.com/velddev/miki/wiki \n" +
                           $"**{locale.GetString("miki_module_general_info_patreon")}:** https://www.patreon.com/mikibot \n" +
                           $"**{locale.GetString("miki_module_general_info_twitter")}:** https://www.twitter.com/velddev / https://www.twitter.com/miki_discord \n" +
                           $"**{locale.GetString("miki_module_general_info_reddit")}:** https://www.reddit.com/r/mikibot \n" +
                           $"**{locale.GetString("miki_module_general_info_server")}:** https://discord.gg/55sAjsW \n" +
                           $"**{locale.GetString("miki_module_general_info_website")}:** http://miki.veld.one");

            await embed.SendToChannel(e.Channel);
        }
Ejemplo n.º 10
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 e.Channel.SendMessage(embed);

                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.AddField(f => { f.Name = "Season" + season.Id; f.Value = s; f.IsInline = true; });
                }
            }

            embed.ThumbnailUrl = user.AvatarUrl;
            embed.ImageUrl     = user.SignatureUrl;
            await e.Channel.SendMessage(embed);
        }
Ejemplo n.º 11
0
        public async Task PrefixAsync(EventContext e)
        {
            Locale locale = new Locale(e.Channel.Id);

            if (string.IsNullOrEmpty(e.arguments))
            {
                e.ErrorEmbed(locale.GetString("miki_module_general_prefix_error_no_arg")).QueueToChannel(e.Channel);
                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(locale.GetString("miki_module_general_prefix_example_command_header"), $"{e.arguments}profile");

            embed.QueueToChannel(e.Channel);
        }
Ejemplo n.º 12
0
        public async Task HelpAsync(EventContext e)
        {
            Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong());

            if (!string.IsNullOrEmpty(e.arguments))
            {
                ICommandEvent ev = Bot.instance.Events.CommandHandler.GetCommandEvent(e.arguments);

                if (ev == null)
                {
                    IDiscordEmbed helpListEmbed = Utils.Embed;
                    helpListEmbed.Title       = locale.GetString("miki_module_help_error_null_header");
                    helpListEmbed.Description = locale.GetString("miki_module_help_error_null_message", await Bot.instance.Events.GetPrefixInstance(">").GetForGuildAsync(e.Guild.Id));
                    helpListEmbed.Color       = new Color(1.0f, 0, 0);

                    API.StringComparison.StringComparer   comparer = new API.StringComparison.StringComparer(e.commandHandler.GetAllEventNames());
                    API.StringComparison.StringComparison best     = comparer.GetBest(e.arguments);

                    helpListEmbed.AddField(locale.GetString("miki_module_help_didyoumean"), best.text);

                    await helpListEmbed.SendToChannel(e.Channel);
                }
                else
                {
                    if (Bot.instance.Events.CommandHandler.GetUserAccessibility(e.message) < ev.Accessibility)
                    {
                        return;
                    }

                    IDiscordEmbed explainedHelpEmbed = Utils.Embed
                                                       .SetTitle(ev.Name.ToUpper());

                    if (ev.Aliases.Length > 0)
                    {
                        explainedHelpEmbed.AddInlineField(
                            locale.GetString("miki_module_general_help_aliases"),
                            string.Join(", ", ev.Aliases));
                    }

                    explainedHelpEmbed.AddField(
                        locale.GetString("miki_module_general_help_description"),
                        (locale.HasString("miki_command_description_" + ev.Name.ToLower())) ? locale.GetString("miki_command_description_" + ev.Name.ToLower()) : locale.GetString("miki_placeholder_null"));

                    explainedHelpEmbed.AddField(
                        locale.GetString("miki_module_general_help_usage"),
                        (locale.HasString("miki_command_usage_" + ev.Name.ToLower())) ? locale.GetString("miki_command_usage_" + ev.Name.ToLower()) : locale.GetString("miki_placeholder_null"));

                    await explainedHelpEmbed.SendToChannel(e.Channel);
                }
                return;
            }
            IDiscordEmbed embed = Utils.Embed;

            embed.Description = locale.GetString("miki_module_general_help_dm");

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

            await embed.SendToChannel(e.Channel);

            await(await Bot.instance.Events.ListCommandsInEmbedAsync(e.message)).SendToUser(e.Author);
        }
Ejemplo n.º 13
0
        public async Task StartSlots(EventContext e, int bet)
        {
            using (var context = new MikiContext())
            {
                User u = await context.Users.FindAsync(e.Author.Id.ToDbLong());

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

                int moneyReturned = 0;

                if (bet <= 0)
                {
                    return;
                }

                string[] objects =
                {
                    "🍒", "🍒", "🍒", "🍒",
                    "🍊", "🍊", "🍊",
                    "🍓", "🍓",
                    "🍍", "🍍",
                    "🍇", "🍇",
                    "🍉", "🍉",
                    "⭐", "⭐",
                    "🍉",
                    "🍍", "🍍",
                    "🍓", "🍓",
                    "🍊", "🍊", "🍊",
                    "🍒", "🍒", "🍒", "🍒",
                };

                IDiscordEmbed embed = Utils.Embed
                                      .SetAuthor(locale.GetString(Locale.SlotsHeader) + " | " + e.Author.Username, e.Author.AvatarUrl, "https://patreon.com/mikibot");

                string[] objectsChosen =
                {
                    objects[MikiRandom.Next(objects.Length)],
                    objects[MikiRandom.Next(objects.Length)],
                    objects[MikiRandom.Next(objects.Length)]
                };

                Dictionary <string, int> score = new Dictionary <string, int>();

                foreach (string o in objectsChosen)
                {
                    if (score.ContainsKey(o))
                    {
                        score[o]++;
                        continue;
                    }
                    score.Add(o, 1);
                }

                if (score.ContainsKey("🍒"))
                {
                    if (score["🍒"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 0.5f);
                    }
                    else if (score["🍒"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 1f);
                    }
                }
                if (score.ContainsKey("🍊"))
                {
                    if (score["🍊"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 0.8f);
                    }
                    else if (score["🍊"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 1.5f);
                    }
                }
                if (score.ContainsKey("🍓"))
                {
                    if (score["🍓"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 1f);
                    }
                    else if (score["🍓"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 2f);
                    }
                }
                if (score.ContainsKey("🍍"))
                {
                    if (score["🍍"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 1f);
                    }
                    if (score["🍍"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 4f);
                    }
                }
                if (score.ContainsKey("🍇"))
                {
                    if (score["🍇"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 1.2f);
                    }
                    if (score["🍇"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 6f);
                    }
                }
                if (score.ContainsKey("🍉"))
                {
                    if (score["🍉"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 1.5f);
                    }
                    if (score["🍉"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 10f);
                    }
                }
                if (score.ContainsKey("⭐"))
                {
                    if (score["⭐"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 2f);
                    }
                    if (score["⭐"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(bet * 12f);
                    }
                }

                if (moneyReturned == 0)
                {
                    moneyReturned = -bet;
                    embed.AddField(locale.GetString("miki_module_fun_slots_lose_header"),
                                   locale.GetString("miki_module_fun_slots_lose_amount", bet, u.Currency - bet));
                }
                else
                {
                    embed.AddField(locale.GetString(Locale.SlotsWinHeader),
                                   locale.GetString(Locale.SlotsWinMessage, moneyReturned, u.Currency + moneyReturned));
                }

                embed.Description = string.Join(" ", objectsChosen);
                await u.AddCurrencyAsync(moneyReturned, e.Channel);

                await context.SaveChangesAsync();

                await embed.SendToChannel(e.Channel);
            }
        }
Ejemplo n.º 14
0
        public async Task SteamUserAsync(EventContext context)
        {
            DateTime requestStart = DateTime.Now;

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

            IDiscordEmbed embed = Utils.Embed;

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

            SteamUserInfo user = await steam.GetSteamUser(args[0]);

            if (user == null)
            {
                embed = Utils.ErrorEmbed(context, "No user was found!");
                embed.QueueToChannel(context.Channel);
                return;
            }

            string userLevel = await steam.GetSteamLevel(user.SteamID);

            embed.SetThumbnailUrl(user.GetAvatarURL());

            /* Current Game & Embed Colour */
            if (user.IsPlayingGame())
            {
                if (user.CurrentGameName != "???")
                {
                    embed.SetDescription("Currently playing " + user.CurrentGameName);
                }
                else
                {
                    embed.SetDescription("Currently in-game");
                }
                embed.Color = new Color(0.5f, 1, 0.5f);
            }
            else if (user.PersonaState != 0)
            {
                embed.Color = new Color(0.5f, 0.5f, 1);
            }

            /* Name & ID */
            embed.AddInlineField("Name", user.GetUsername());
            embed.AddInlineField("ID", user.SteamID);

            /* Real Name & Country */
            embed.AddInlineField("Real Name", user.RealName);
            embed.AddInlineField("Country", (user.CountryCode != "???" ? ":flag_" + user.CountryCode.ToLower() + ": " : "") + user.CountryCode);

            /* Profile Link */
            embed.AddField("Link", user.ProfileURL);

            /* Created & Status */
            embed.AddInlineField("Created", String.Format("{0:MMMM d, yyyy}", user.TimeCreated));
            if (user.GetStatus() == "Offline")
            {
                embed.AddInlineField("Offline Since", ToTimeString(user.OfflineSince()));
            }
            else
            {
                embed.AddInlineField("Status", user.GetStatus());
            }

            /* Level */
            embed.AddInlineField("Level", userLevel);

            embed.SetFooter("Request took in " + Math.Round((DateTime.Now - requestStart).TotalMilliseconds) + "ms", "");
            embed.QueueToChannel(context.Channel);
        }
Ejemplo n.º 15
0
        private async Task InternalSlotsAsync(EventContext e, ulong userid, Locale locale, int amount)
        {
            int moneyBet = 0;

            using (var context = new MikiContext())
            {
                User u = await context.Users.FindAsync(userid.ToDbLong());

                int moneyReturned = 0;

                if (moneyBet <= 0)
                {
                    return;
                }

                string[] objects =
                {
                    "🍒", "🍒", "🍒", "🍒",
                    "🍊", "🍊",
                    "🍓", "🍓",
                    "🍍", "🍍",
                    "🍇", "🍇",
                    "⭐", "⭐",
                    "🍍", "🍍",
                    "🍓", "🍓",
                    "🍊", "🍊", "🍊",
                    "🍒", "🍒", "🍒", "🍒",
                };

                IDiscordEmbed b = Utils.Embed;
                b.Title = locale.GetString(Locale.SlotsHeader);

                Random r = new Random();

                string[] objectsChosen =
                {
                    objects[r.Next(objects.Length)],
                    objects[r.Next(objects.Length)],
                    objects[r.Next(objects.Length)]
                };

                Dictionary <string, int> score = new Dictionary <string, int>();

                foreach (string o in objectsChosen)
                {
                    if (score.ContainsKey(o))
                    {
                        score[o]++;
                        continue;
                    }
                    score.Add(o, 1);
                }

                if (score.ContainsKey("🍒"))
                {
                    if (score["🍒"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 0.5f);
                    }
                    else if (score["🍒"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 1f);
                    }
                }
                if (score.ContainsKey("🍊"))
                {
                    if (score["🍊"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 0.8f);
                    }
                    else if (score["🍊"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 1.5f);
                    }
                }
                if (score.ContainsKey("🍓"))
                {
                    if (score["🍓"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 1f);
                    }
                    else if (score["🍓"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 2f);
                    }
                }
                if (score.ContainsKey("🍍"))
                {
                    if (score["🍍"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 4f);
                    }
                }
                if (score.ContainsKey("🍇"))
                {
                    if (score["🍇"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 6f);
                    }
                }
                if (score.ContainsKey("⭐"))
                {
                    if (score["⭐"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 12f);
                    }
                }

                if (moneyReturned == 0)
                {
                    moneyReturned = -moneyBet;
                }
                else
                {
                    b.AddField(locale.GetString(Locale.SlotsWinHeader), locale.GetString(Locale.SlotsWinMessage, moneyReturned));
                }

                b.Description = string.Join(" ", objectsChosen);
                u.Currency   += moneyReturned;
                await context.SaveChangesAsync();

                await b.SendToChannel(e.Channel);
            }
        }
Ejemplo n.º 16
0
        public async Task SlotsAsync(EventContext e)
        {
            int moneyBet = 0;

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

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

                if (!string.IsNullOrWhiteSpace(e.arguments))
                {
                    moneyBet = int.Parse(e.arguments);

                    if (moneyBet > u.Currency)
                    {
                        await e.Channel.SendMessage(locale.GetString(Locale.InsufficientMekos));

                        return;
                    }
                }

                int moneyReturned = 0;

                if (moneyBet <= 0)
                {
                    return;
                }

                string[] objects =
                {
                    "🍒", "🍒", "🍒", "🍒",
                    "🍊", "🍊",
                    "🍓", "🍓",
                    "🍍", "🍍",
                    "🍇", "🍇",
                    "⭐", "⭐",
                    "🍍", "🍍",
                    "🍓", "🍓",
                    "🍊", "🍊", "🍊",
                    "🍒", "🍒", "🍒", "🍒",
                };

                IDiscordEmbed embed = Utils.Embed;
                embed.Title = locale.GetString(Locale.SlotsHeader);

                string[] objectsChosen =
                {
                    objects[MikiRandom.Next(objects.Length)],
                    objects[MikiRandom.Next(objects.Length)],
                    objects[MikiRandom.Next(objects.Length)]
                };

                Dictionary <string, int> score = new Dictionary <string, int>();

                foreach (string o in objectsChosen)
                {
                    if (score.ContainsKey(o))
                    {
                        score[o]++;
                        continue;
                    }
                    score.Add(o, 1);
                }

                if (score.ContainsKey("🍒"))
                {
                    if (score["🍒"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 0.5f);
                    }
                    else if (score["🍒"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 1f);
                    }
                }
                if (score.ContainsKey("🍊"))
                {
                    if (score["🍊"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 0.8f);
                    }
                    else if (score["🍊"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 1.5f);
                    }
                }
                if (score.ContainsKey("🍓"))
                {
                    if (score["🍓"] == 2)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 1f);
                    }
                    else if (score["🍓"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 2f);
                    }
                }
                if (score.ContainsKey("🍍"))
                {
                    if (score["🍍"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 4f);
                    }
                }
                if (score.ContainsKey("🍇"))
                {
                    if (score["🍇"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 6f);
                    }
                }
                if (score.ContainsKey("⭐"))
                {
                    if (score["⭐"] == 3)
                    {
                        moneyReturned = (int)Math.Ceiling(moneyBet * 12f);
                    }
                }

                if (moneyReturned == 0)
                {
                    moneyReturned = -moneyBet;
                    embed.AddField(locale.GetString("miki_module_fun_slots_lose_header"), locale.GetString("miki_module_fun_slots_lose_amount", moneyBet, u.Currency - moneyBet));
                }
                else
                {
                    embed.AddField(locale.GetString(Locale.SlotsWinHeader), locale.GetString(Locale.SlotsWinMessage, moneyReturned, u.Currency + moneyReturned));
                }

                embed.Description = string.Join(" ", objectsChosen);
                await u.AddCurrencyAsync(e.Channel, null, moneyReturned);

                await context.SaveChangesAsync();

                await embed.SendToChannel(e.Channel);
            }
        }