public async Task Decline([Remainder] string str = "") { //common variables IUser user = Context.User; EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor(user); eb.WithColor(ProfileDb.GetHex(out string colour, user.Id) ? (Discord.Color)UserUtil.HexToColor(colour) : BasicUtil.RandomColor()); var proposals = MarriageDb.GetProposalsReceived(user.Id, Context.Guild.Id); proposals.AddRange(MarriageDb.GetProposalsSent(user.Id, Context.Guild.Id)); var proposal = await UserUtil.SelectMarriage(proposals, this); if (proposal == null) { eb.WithDescription("~ You have no proposals ~"); await Context.Channel.SendMessageAsync($"", false, eb.Build()); return; } ulong wife = UserUtil.GetWifeId(proposal, user.Id); // Swagness //creating decline action var decline = new DialogueBoxOption { Action = async(IUserMessage message) => { await MarriageDb.DeleteMarriageOrProposal(proposal); //embed eb.WithAuthor(user); eb.WithDescription($"You declined the proposal.\nBetter luck next time **{ BasicUtil.IdToMention(wife) }**."); await message.ModifyAsync(x => x.Embed = eb.Build()); //execution condition }, After = OnExecute.RemoveReactions }; //creating cancel var cancel = new DialogueBoxOption { After = OnExecute.Delete }; //making dialog embed var dia = new DialogueBox(); dia.Options.Add(Emote.Parse("<:TickYes:577838859107303424>"), decline); dia.Options.Add(Emote.Parse("<:TickNo:577838859077943306>"), cancel); dia.Timeout = new TimeSpan(0, 1, 0); dia.Embed = new EmbedBuilderPrepared(user) .WithDescription($"Are you sure you wish to Decline **{ BasicUtil.IdToMention(wife) }**?").Build(); // await DialogueReplyAsync(dia); }
public static EmbedBuilder ProposalsEmbed(IUser user, SocketGuild guild) { //embed basics EmbedBuilder embed = new EmbedBuilder(); embed.WithAuthor(user); embed.WithColor(ProfileDb.GetHex(out string colour, user.Id) ? (Discord.Color)UserUtil.HexToColor(colour) : BasicUtil.RandomColor()); //proposals List <Marriage> sent = MarriageDb.GetProposalsSent(user.Id, guild.Id); List <Marriage> received = MarriageDb.GetProposalsReceived(user.Id, guild.Id); //fields aggregation int users = 1; string field1 = "", field2 = ""; foreach (Marriage proposals in sent) { field1 += $"#{users++} {guild.GetUser(proposals.WifeId) }\n"; } // foreach (Marriage proposals in received) { field2 += $"#{users++} {guild.GetUser(proposals.UserId) }\n"; } //if this dude is #ForeverAlone if (String.IsNullOrEmpty(field1) && String.IsNullOrEmpty(field2)) { embed.WithDescription("You have not sent or received any Proposals."); } //do columns, sent on the left received on the right (or some shit) if (!String.IsNullOrEmpty(field1)) { embed.AddField("Proposals Sent :sparkling_heart:", field1, true); } if (!String.IsNullOrEmpty(field2)) { embed.AddField("Proposals Received :sparkling_heart:", field2, true); } return(embed); }