Ejemplo n.º 1
0
        public async Task SetProfileBackgroundAsync(EventContext e)
        {
            int?backgroundId = e.Arguments.First().AsInt();

            if (backgroundId == null)
            {
                throw new ArgumentNullException("background");
            }

            long userId = e.Author.Id.ToDbLong();

            using (var context = new MikiContext())
            {
                BackgroundsOwned bo = await context.BackgroundsOwned.FindAsync(userId, backgroundId ?? 0);

                if (bo == null)
                {
                    throw new BackgroundNotOwnedException();
                }

                ProfileVisuals v = await ProfileVisuals.GetAsync(userId, context);

                v.BackgroundId = bo.BackgroundId;

                await context.SaveChangesAsync();
            }

            Utils.SuccessEmbed(e.Channel.Id, "Successfully set background.")
            .QueueToChannel(e.Channel);
        }
Ejemplo n.º 2
0
        public async Task SetProfileForeColorAsync(EventContext e)
        {
            using (var context = new MikiContext())
            {
                User user = await DatabaseHelpers.GetUserAsync(context, e.Author);

                var x = Regex.Matches(e.Arguments.ToString().ToUpper(), "(#)?([A-F0-9]{6})");

                if (x.Count > 0)
                {
                    ProfileVisuals visuals = await ProfileVisuals.GetAsync(e.Author.Id, context);

                    var hex = x.First().Groups.Last().Value;

                    visuals.ForegroundColor = hex;
                    user.RemoveCurrency(250);
                    await context.SaveChangesAsync();

                    e.SuccessEmbed($"Your foreground color has been successfully changed to `{hex}`")
                    .QueueToChannel(e.Channel);
                }
                else
                {
                    new EmbedBuilder()
                    .SetTitle("🖌 Setting a foreground color!")
                    .SetDescription("Changing your foreground(text) color costs 250 mekos. use `>setfrontcolor (e.g. #00FF00)` to purchase")
                    .ToEmbed().QueueToChannel(e.Channel);
                }
            }
        }
Ejemplo n.º 3
0
        public async Task SetProfileBackgroundAsync(CommandContext e)
        {
            if (!e.Arguments.Take(out int backgroundId))
            {
                throw new ArgumentNullException("background");
            }

            long userId = e.Author.Id.ToDbLong();

            var context = e.GetService <MikiDbContext>();

            BackgroundsOwned bo = await context.BackgroundsOwned.FindAsync(userId, backgroundId);

            if (bo == null)
            {
                throw new BackgroundNotOwnedException();
            }

            ProfileVisuals v = await ProfileVisuals.GetAsync(userId, context);

            v.BackgroundId = bo.BackgroundId;
            await context.SaveChangesAsync();

            await e.SuccessEmbed("Successfully set background.")
            .QueueToChannelAsync(e.Channel);
        }
Ejemplo n.º 4
0
        public async Task SetProfileBackColorAsync(CommandContext e)
        {
            var  context = e.GetService <MikiDbContext>();
            User user    = await DatabaseHelpers.GetUserAsync(context, e.Author);

            var x = Regex.Matches(e.Arguments.Pack.TakeAll().ToUpper(), "(#)?([A-F0-9]{6})");

            if (x.Count > 0)
            {
                ProfileVisuals visuals = await ProfileVisuals.GetAsync(e.Author.Id, context);

                var hex = x.First().Groups.Last().Value;

                visuals.BackgroundColor = hex;
                user.RemoveCurrency(250);
                await context.SaveChangesAsync();

                await e.SuccessEmbed($"Your foreground color has been successfully changed to `{hex}`")
                .QueueToChannelAsync(e.Channel);
            }
            else
            {
                await new EmbedBuilder()
                .SetTitle("🖌 Setting a background color!")
                .SetDescription("Changing your background color costs 250 mekos. use `>setbackcolor (e.g. #00FF00)` to purchase")
                .ToEmbed().QueueToChannelAsync(e.Channel);
            }
        }
Ejemplo n.º 5
0
        public async Task SetProfileBackColorAsync(EventContext e)
        {
            using (var context = new MikiContext())
            {
                User user = await User.GetAsync(context, e.Author);

                new EmbedBuilder()
                .SetTitle("Hold on!")
                .SetDescription("Changing your background color costs 250 mekos. type a hex to purchase")
                .ToEmbed().QueueToChannel(e.Channel);

                IDiscordMessage msg = await e.EventSystem.GetCommandHandler <MessageListener>().WaitForNextMessage(e.CreateSession());

                var x = Regex.Matches(msg.Content.ToUpper(), "(#)?([A-F0-9]{6})");

                if (x.Count > 0)
                {
                    ProfileVisuals visuals = await ProfileVisuals.GetAsync(e.Author.Id, context);

                    var hex = x.First().Groups.Last().Value;

                    visuals.BackgroundColor = hex;
                    await user.AddCurrencyAsync(-250, e.Channel);

                    await context.SaveChangesAsync();

                    e.SuccessEmbed($"Your background color has been successfully changed to `{hex}`")
                    .QueueToChannel(e.Channel);
                }
                else
                {
                    throw new ArgumentException("Argument was not a hex color");
                }
            }
        }