public async Task DeclineMarriageAsync(EventContext e) { Locale locale = new Locale(e.Channel.Id); using (MikiContext context = new MikiContext()) { if (e.arguments == "*") { await Marriage.DeclineAllProposalsAsync(context, e.Author.Id.ToDbLong()); e.Channel.QueueMessageAsync(locale.GetString("miki_Marriage_all_declined")); return; } if (e.message.MentionedUserIds.Count == 0) { e.Channel.QueueMessageAsync(locale.GetString("miki_Marriage_no_mention")); return; } IDiscordUser user = await e.Guild.GetUserAsync(e.message.MentionedUserIds.First()); Marriage marriage = await Marriage.GetEntryAsync(context, e.message.MentionedUserIds.First(), e.Author.Id); if (marriage == null) { e.Channel.QueueMessageAsync(locale.GetString("miki_Marriage_null")); return; } if (marriage.IsProposing) { await marriage.RemoveAsync(context); Utils.Embed.SetTitle($"🔫 You shot down {user.GetName()}!") .SetDescription($"Aww, don't worry {user.GetName()}. There is plenty of fish in the sea!") .SetColor(191, 105, 82) .QueueToChannel(e.Channel); } else { e.ErrorEmbed("You're already married to this person ya doofus!") .QueueToChannel(e.Channel); } } }
public async Task DeclineMarriageAsync(EventContext e) { Locale locale = Locale.GetEntity(e.Channel.Id); using (MikiContext context = new MikiContext()) { if (e.arguments == "*") { await Marriage.DeclineAllProposalsAsync(context, e.Author.Id.ToDbLong()); await e.Channel.QueueMessageAsync(locale.GetString("miki_marriage_all_declined")); return; } if (e.message.MentionedUserIds.Count == 0) { await e.Channel.QueueMessageAsync(locale.GetString("miki_marriage_no_mention")); return; } Marriage marriage = await Marriage.GetEntryAsync(context, e.message.MentionedUserIds.First(), e.Author.Id); if (marriage == null) { marriage = await Marriage.GetEntryAsync(context, e.Author.Id, e.message.MentionedUserIds.First()); if (marriage == null) { await e.Channel.QueueMessageAsync(locale.GetString("miki_marriage_null")); return; } } await marriage.RemoveAsync(context); } }
public async Task AcceptMarriageAsync(EventContext e) { IDiscordUser user = await e.Arguments.Join().GetUserAsync(e.Guild); if (user == null) { e.ErrorEmbed("I couldn't find this user!") .ToEmbed().QueueToChannel(e.Channel); } if (user.Id == e.Author.Id) { e.ErrorEmbed("Please mention someone else than yourself.") .ToEmbed().QueueToChannel(e.Channel); return; } using (var context = new MikiContext()) { User accepter = await User.GetAsync(context, e.Author); User asker = await User.GetAsync(context, user); UserMarriedTo marriage = await Marriage.GetEntryAsync(context, accepter.Id, asker.Id); if (marriage != null) { if (accepter.MarriageSlots < (await Marriage.GetMarriagesAsync(context, accepter.Id)).Count) { e.Channel.QueueMessageAsync($"{e.Author.Username} do not have enough Marriage slots, sorry :("); return; } if (asker.MarriageSlots < (await Marriage.GetMarriagesAsync(context, asker.Id)).Count) { e.Channel.QueueMessageAsync($"{asker.Name} does not have enough Marriage slots, sorry :("); return; } if (marriage.ReceiverId != e.Author.Id.ToDbLong()) { e.Channel.QueueMessageAsync($"You can not accept your own responses!"); return; } if (marriage.Marriage.IsProposing) { marriage.Marriage.AcceptProposal(context); await context.SaveChangesAsync(); new EmbedBuilder() { Title = ("❤️ Happily married"), Color = new Color(190, 25, 49), Description = ($"Much love to { e.Author.Username } and { user.Username } in their future adventures together!") }.ToEmbed().QueueToChannel(e.Channel); } else { e.ErrorEmbed("You're already married to this person ya doofus!") .ToEmbed().QueueToChannel(e.Channel); } } else { e.Channel.QueueMessageAsync("This user hasn't proposed to you!"); return; } } }