예제 #1
0
        public async Task DeclineMarriageAsync(EventContext e)
        {
            using (MikiContext context = new MikiContext())
            {
                MarriageRepository repository = new MarriageRepository(context);

                ArgObject selection   = e.Arguments.FirstOrDefault();
                int?      selectionId = null;

                if (selection != null)
                {
                    selectionId = selection.AsInt();
                }

                var marriages = await repository.GetProposalsReceived(e.Author.Id.ToDbLong());

                if (marriages.Count == 0)
                {
                    throw BotException.CreateCustom("error_proposals_empty");
                }

                marriages = marriages.OrderByDescending(x => x.Marriage.TimeOfMarriage).ToList();

                if (selectionId != null)
                {
                    var    m         = marriages[selectionId.Value - 1];
                    string otherName = (await Global.Client.Client.GetUserAsync(m.GetOther(e.Author.Id.ToDbLong()).FromDbLong())).Username;

                    new EmbedBuilder()
                    {
                        Title       = $"🔫 You shot down {otherName}!",
                        Description = $"Aww, don't worry {otherName}. There is plenty of fish in the sea!",
                        Color       = new Color(191, 105, 82)
                    }.ToEmbed().QueueToChannel(e.Channel);

                    m.Remove(context);
                    await context.SaveChangesAsync();
                }
                else
                {
                    var embed = new EmbedBuilder()
                    {
                        Title  = "💍 Proposals",
                        Footer = new EmbedFooter()
                        {
                            Text = $"Use {await e.Prefix.GetForGuildAsync(Global.RedisClient, e.Guild.Id)}declinemarriage <number> to decline",
                        },
                        Color = new Color(154, 170, 180)
                    };

                    await BuildMarriageEmbedAsync(embed, e.Author.Id.ToDbLong(), context, marriages);

                    embed.ToEmbed().QueueToChannel(e.Channel);
                }
            }
        }
예제 #2
0
        public async Task DivorceAsync(EventContext e)
        {
            using (MikiContext context = new MikiContext())
            {
                MarriageRepository repository = new MarriageRepository(context);

                ArgObject selection   = e.Arguments.FirstOrDefault();
                int?      selectionId = null;

                if (selection != null)
                {
                    selectionId = selection.AsInt();
                }

                var marriages = await repository.GetMarriagesAsync((long)e.Author.Id);

                if (marriages.Count == 0)
                {
                    throw BotException.CreateCustom("error_proposals_empty");
                }

                marriages = marriages.OrderByDescending(x => x.Marriage.TimeOfMarriage).ToList();

                if (selectionId != null)
                {
                    var m         = marriages[selectionId.Value - 1];
                    var otherUser = await Global.Client.Client.GetUserAsync(m.GetOther(e.Author.Id.ToDbLong()).FromDbLong());

                    EmbedBuilder embed = Utils.Embed;
                    embed.Title       = $"🔔 {e.Locale.GetString("miki_module_accounts_divorce_header")}";
                    embed.Description = e.Locale.GetString("miki_module_accounts_divorce_content", e.Author.Username, otherUser.Username);
                    embed.Color       = new Color(0.6f, 0.4f, 0.1f);
                    embed.ToEmbed().QueueToChannel(e.Channel);

                    m.Remove(context);
                    await context.SaveChangesAsync();
                }
                else
                {
                    var embed = new EmbedBuilder()
                    {
                        Title  = "💍 Marriages",
                        Footer = new EmbedFooter()
                        {
                            Text = $"Use {await e.Prefix.GetForGuildAsync(Global.RedisClient, e.Guild.Id)}divorce <number> to decline",
                        },
                        Color = new Color(154, 170, 180)
                    };

                    await BuildMarriageEmbedAsync(embed, e.Author.Id.ToDbLong(), context, marriages);

                    embed.ToEmbed().QueueToChannel(e.Channel);
                }
            }
        }