public async Task MarryAsync(EventContext e) { Locale locale = Locale.GetEntity(e.Channel.Id); if (e.message.MentionedUserIds.Count == 0) { await e.Channel.QueueMessageAsync(locale.GetString("miki_module_accounts_marry_error_no_mention")); return; } using (MikiContext context = new MikiContext()) { IDiscordUser user = await e.Guild.GetUserAsync(e.message.MentionedUserIds.First()); User mentionedPerson = await User.GetAsync(context, user); User currentUser = await User.GetAsync(context, e.Author); if (mentionedPerson.Banned) { return; } if (currentUser == null || mentionedPerson == null) { await Utils.ErrorEmbed(locale, "miki_module_accounts_marry_error_null").QueueToChannel(e.Channel); return; } if (mentionedPerson.Id == currentUser.Id) { await Utils.ErrorEmbed(locale, locale.GetString("miki_module_accounts_marry_error_null")).QueueToChannel(e.Channel); return; } if (await Marriage.ExistsAsync(context, mentionedPerson.Id, currentUser.Id)) { await Utils.ErrorEmbed(locale, locale.GetString("miki_module_accounts_marry_error_exists")).QueueToChannel(e.Channel); return; } if (await Marriage.ProposeAsync(context, currentUser.Id, mentionedPerson.Id)) { await Utils.Embed .SetTitle("💍" + e.GetResource("miki_module_accounts_marry_text", $"**{e.Author.Username}**", $"**{user.Username}**")) .SetDescription(locale.GetString("miki_module_accounts_marry_text2", user.Username, e.Author.Username)) .SetColor(0.4f, 0.4f, 0.8f) .SetThumbnailUrl("https://i.imgur.com/TKZSKIp.png") .AddInlineField("✅ To accept", $">acceptmarriage @user") .AddInlineField("❌ To decline", $">declinemarriage @user") .SetFooter("Take your time though! This proposal won't disappear", "") .QueueToChannel(e.Channel); } } }
public async Task MarryAsync(EventContext e) { Locale locale = Locale.GetEntity(e.Channel.Id); if (e.message.MentionedUserIds.Count == 0) { await e.Channel.SendMessage(locale.GetString("miki_module_accounts_marry_error_no_mention")); return; } using (MikiContext context = new MikiContext()) { User mentionedPerson = await context.Users.FindAsync(e.message.MentionedUserIds.First().ToDbLong()); User currentUser = await context.Users.FindAsync(e.Author.Id.ToDbLong()); IDiscordUser user = await e.Guild.GetUserAsync(e.message.MentionedUserIds.First()); if (currentUser == null || mentionedPerson == null) { await Utils.ErrorEmbed(locale, "miki_module_accounts_marry_error_null").SendToChannel(e.Channel); return; } if (mentionedPerson.Id == currentUser.Id) { await Utils.ErrorEmbed(locale, locale.GetString("miki_module_accounts_marry_error_null")).SendToChannel(e.Channel); return; } if (await Marriage.ExistsAsync(context, mentionedPerson.Id, currentUser.Id)) { await Utils.ErrorEmbed(locale, locale.GetString("miki_module_accounts_marry_error_exists")).SendToChannel(e.Channel); return; } if (await Marriage.ProposeAsync(context, currentUser.Id, mentionedPerson.Id)) { await e.Channel.SendMessage( $"💍 " + locale.GetString("miki_module_accounts_marry_text", $"**{e.Author.Username}**", $"**{user.Username}**") + " 💍\n\n⛪ " + user.Username + " " + locale.GetString("miki_module_accounts_marry_text2") + $" ⛪\n\n✅ **>acceptmarriage [@{locale.GetString("miki_terms_mention")}]**\n❌ **>declinemarriage [@{locale.GetString("miki_terms_mention")}]**"); } } }
public async Task MarryAsync(EventContext e) { long askerId = 0; long receiverId = 0; ArgObject args = e.Arguments.FirstOrDefault(); if (args == null) { return; } IDiscordGuildUser user = await args.GetUserAsync(e.Guild); if (user == null) { e.Channel.QueueMessageAsync("Couldn't find this person.."); return; } if (user.Id == (await e.Guild.GetSelfAsync()).Id) { e.Channel.QueueMessageAsync("(´・ω・`)"); return; } using (MikiContext context = new MikiContext()) { User mentionedPerson = await User.GetAsync(context, user); User currentUser = await User.GetAsync(context, e.Author); askerId = currentUser.Id; receiverId = mentionedPerson.Id; if (currentUser == null || mentionedPerson == null) { e.ErrorEmbed(e.GetResource("miki_module_accounts_marry_error_null")).ToEmbed().QueueToChannel(e.Channel); return; } if (mentionedPerson.Banned) { e.ErrorEmbed("This person has been banned from Miki.").ToEmbed().QueueToChannel(e.Channel); return; } if (mentionedPerson.Id == currentUser.Id) { e.ErrorEmbed(e.GetResource("miki_module_accounts_marry_error_null")).ToEmbed().QueueToChannel(e.Channel); return; } if (await Marriage.ExistsAsync(context, mentionedPerson.Id, currentUser.Id)) { e.ErrorEmbed(e.GetResource("miki_module_accounts_marry_error_exists")).ToEmbed().QueueToChannel(e.Channel); return; } } await Marriage.ProposeAsync(askerId, receiverId); Utils.Embed .SetTitle("💍" + e.GetResource("miki_module_accounts_marry_text", $"**{e.Author.Username}**", $"**{user.Username}**")) .SetDescription(e.GetResource("miki_module_accounts_marry_text2", user.Username, e.Author.Username)) .SetColor(0.4f, 0.4f, 0.8f) .SetThumbnail("https://i.imgur.com/TKZSKIp.png") .AddInlineField("✅ To accept", $">acceptmarriage @user") .AddInlineField("❌ To decline", $">declinemarriage @user") .SetFooter("Take your time though! This proposal won't disappear", "") .ToEmbed().QueueToChannel(e.Channel); }