예제 #1
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);
            }
        }
예제 #2
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);
        }
예제 #3
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>`");
            embed.QueueToChannel(context.Channel);
        }
예제 #4
0
파일: PastaModule.cs 프로젝트: Drummss/Miki
        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);
                }
            }
        }
예제 #5
0
        public async Task GuildInfoAsync(EventContext e)
        {
            IDiscordEmbed embed = Utils.Embed;
            Locale        l     = Locale.GetEntity(e.Channel.Id.ToDbLong());

            embed.SetAuthor(e.Guild.Name, e.Guild.AvatarUrl, e.Guild.AvatarUrl);

            IDiscordUser owner = await e.Guild.GetOwnerAsync();

            embed.AddInlineField(
                "👑" + l.GetString("miki_module_general_guildinfo_owned_by"),
                owner.Username + "#" + owner.Discriminator);

            embed.AddInlineField(
                "👉" + l.GetString("miki_label_prefix"),
                await PrefixInstance.Default.GetForGuildAsync(e.Guild.Id));

            embed.AddInlineField(
                "📺" + l.GetString("miki_module_general_guildinfo_channels"),
                (await e.Guild.GetChannelCountAsync()).ToString());

            embed.AddInlineField(
                "🔊" + l.GetString("miki_module_general_guildinfo_voicechannels"),
                (await e.Guild.GetVoiceChannelCountAsync()).ToString());

            embed.AddInlineField(
                "🙎" + l.GetString("miki_module_general_guildinfo_users"),
                (await e.Guild.GetUserCountAsync()).ToString());

            embed.AddInlineField(
                "🤖" + l.GetString("term_shard"),
                Bot.instance.Client.GetShardIdFor((e.Guild as IProxy <IGuild>).ToNativeObject()));

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

            foreach (IDiscordRole r in e.Guild.Roles)
            {
                roleNames.Add($"`{r.Name}`");
            }

            embed.AddInlineField(
                "#⃣" + l.GetString("miki_module_general_guildinfo_roles_count"),
                e.Guild.Roles.Count.ToString());

            string roles = string.Join(", ", roleNames);

            if (roles.Length <= 1000)
            {
                embed.AddInlineField(
                    "📜" + l.GetString("miki_module_general_guildinfo_roles"),
                    roles);
            }

            await embed.QueueToChannel(e.Channel);
        }
예제 #6
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"))
                .QueueToChannel(e.Channel.Id);

                return;
            }

            using (var context = new MikiContext())
            {
                GlobalPasta pasta = await context.Pastas.FindAsync(e.arguments);

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

                    return;
                }

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

                IDiscordEmbed b = Utils.Embed;

                b.SetAuthor(pasta.Id.ToUpper(), "", "");
                b.Color = new 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.CreatedAt.ToShortDateString());

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

                VoteCount v = await pasta.GetVotesAsync(context);

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

                await b.QueueToChannel(e.Channel);
            }
        }
예제 #7
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", "");
            embed.QueueToChannel(context.Channel);
        }
예제 #8
0
        public async Task GuildInfoAsync(EventContext e)
        {
            IDiscordEmbed embed = Utils.Embed;
            Locale        l     = Locale.GetEntity(e.Channel.Id.ToDbLong());

            embed.SetAuthor(e.Guild.Name, e.Guild.AvatarUrl, e.Guild.AvatarUrl);

            embed.AddInlineField(
                "👑" + l.GetString("miki_module_general_guildinfo_owned_by"),
                e.Guild.Owner.Username + "#" + e.Guild.Owner.Discriminator);

            embed.AddInlineField(
                "👉" + l.GetString("miki_label_prefix"),
                await PrefixInstance.Default.GetForGuildAsync(e.Guild.Id));

            embed.AddInlineField(
                "📺" + l.GetString("miki_module_general_guildinfo_channels"),
                e.Guild.ChannelCount.ToString());

            embed.AddInlineField(
                "🔊" + l.GetString("miki_module_general_guildinfo_voicechannels"),
                e.Guild.VoiceChannelCount.ToString());

            embed.AddInlineField(
                "🙎" + l.GetString("miki_module_general_guildinfo_users"),
                e.Guild.UserCount.ToString());

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

            foreach (IDiscordRole r in e.Guild.Roles)
            {
                roleNames.Add($"`{r.Name}`");
            }

            embed.AddInlineField(
                "#⃣" + l.GetString("miki_module_general_guildinfo_roles_count"),
                e.Guild.Roles.Count.ToString());

            embed.AddInlineField(
                "📜" + l.GetString("miki_module_general_guildinfo_roles"),
                string.Join(", ", roleNames));

            await embed.SendToChannel(e.Channel);
        }
예제 #9
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);
        }