protected override void BeforeExecute(CommandInfo command) { dataContext = new WaitingListDataContext(); waitingList = new CommandWaitingList(dataContext, Context.Client.Rest, Context.Guild.Id); guildData = dataContext.GetOrCreateGuildData(Context.Guild) !; base.BeforeExecute(command); }
//[Command("unpause")] //[Summary("Pauses the joining of the list.")] //[ModPermission] //public async Task Unpause() //{ // storage.IsPaused = false; // storage.Save(); // await UpdateReactionMessageAsync(waitingList, Context.Guild, storage); // await Context.Message.ReplyAsync("Waiting list has been unpaused"); //} public static async Task UpdatePublicMessageAsync(IWaitingList waitingList, IGuild guild, GuildData guildData) { var message = await GetMessageAsync(guild, guildData); if (message is not IUserMessage) { return; } var embedBuilder = new EmbedBuilder { Color = Color.Green, Title = $"Waiting list" }; var sortedList = await waitingList.GetPlayerListAsync(); var description = ""; int counter = 0; foreach (var player in sortedList) { description += $"**{++counter}.** {player.Name} ({GetMentionWithId(player.UserId)}) {(player.IsSub ? "(Sub) " : "")}"; if (player.PlayCount > 0) { description += $"(Played { player.PlayCount} time{ (player.PlayCount > 1 ? "s" : "")})"; } description += "\r\n"; } string url = "https://wl.pdelvo.com/WaitingList/" + guild.Id; embedBuilder.Description = description; embedBuilder.AddField("\u200B", "[View this list in real time](" + url + ")"); ComponentBuilder componentBuilder = new ComponentBuilder(); componentBuilder.WithButton("Join", customId: "join", disabled: guildData.IsPaused); componentBuilder.WithButton("Leave", customId: "leave"); // Waiting for an updated Discord.Net package for this to work componentBuilder.WithButton("Website", null, style: ButtonStyle.Link, url: url); Embed embed = embedBuilder.Build(); await message.ModifyAsync(p => { p.Content = $"Join the waiting list now!:"; p.Embed = embed; p.Components = componentBuilder.Build(); }); }