Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        public async Task IdentifyPasta(EventContext e)
        {
            string pastaArg = e.Arguments.Pack.TakeAll();

            if (string.IsNullOrWhiteSpace(pastaArg))
            {
                await e.ErrorEmbed(e.Locale.GetString("infopasta_error_no_arg"))
                .ToEmbed().QueueToChannelAsync(e.Channel);

                return;
            }

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

                if (pasta == null)
                {
                    await e.ErrorEmbed(e.Locale.GetString("miki_module_pasta_error_null")).ToEmbed().QueueToChannelAsync(e.Channel);

                    return;
                }

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

                EmbedBuilder b = new EmbedBuilder();

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

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

                b.AddInlineField(e.Locale.GetString("miki_module_pasta_identify_date_created"), pasta.CreatedAt.ToShortDateString());

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

                VoteCount v = await pasta.GetVotesAsync(context);

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

                await b.ToEmbed().QueueToChannelAsync(e.Channel);
            }
        }