private async Task UnpinMessageAsync(RestUserMessage message) { await message.RemoveAllReactionsAsync(); await message.UnpinAsync(); Logger.LogInformation("Unpinned message with ID {0} from {1} posted at {2}", message.Id, message.Author.GetFullName(), message.CreatedAt); }
public static async Task CreateRaidEmbedAsync(RestUserMessage msg, Raid raid) { var westernTimeZone = TZConvert.GetTimeZoneInfo("America/Los_Angeles"); var localDateTime = TimeZoneInfo.ConvertTime(raid.RaidTime, westernTimeZone); if (DateTimeOffset.UtcNow.CompareTo(raid.RaidTime) > 0) { if (msg.IsPinned) { await msg.UnpinAsync(); } await msg.ModifyAsync(m => m.Content = "This raid has already occurred."); await msg.ClearReactionsAsync(); return; } await AddRaidEmojisAsync(msg); if (!msg.IsPinned) { await msg.PinAsync(); } var roleCounts = Enum.GetNames(typeof(ClassRole)).Select(r => (Role: Enum.Parse <ClassRole>(r), Count: raid.Participants.Where(rp => !rp.IsAbsent).Count(rp => rp.Character.Role == Enum.Parse <ClassRole>(r)))); var classCounts = Enum.GetNames(typeof(WowClass)).Select(c => (Class: Enum.Parse <WowClass>(c), Count: raid.Participants.Where(rp => !rp.IsAbsent).Count(rp => rp.Character.Class == Enum.Parse <WowClass>(c)))); var embed = new LocalEmbedBuilder() .WithTitle($"{raid.RaidLocationId.Humanize().Transform(To.TitleCase)} - {localDateTime:MM/dd @ hh tt}") .WithTimestamp(raid.RaidTime); var raiderGroups = raid.Participants.Where(rp => !rp.IsAbsent).ToArray().OrderBy(rp => rp.SignedUpAt) .Select((rp, index) => (SignedUpNumber: index + 1, RaidParticipant: rp)) .GroupBy(signup => signup.RaidParticipant.Character.Class) .Select(g => (Class: Enum.Parse <WowClass>(g.Key.ToString()), Raiders: g.OrderBy(r => r.SignedUpNumber))) .ToDictionary(k => k.Class, v => v.Raiders); var embedLayoutDict = new Dictionary <WowClass, IOrderedEnumerable <(int, RaidParticipant)> > { { WowClass.Druid, null },