/// <summary> /// Executed hourly to check if server reset has been reached (occurs at 00:00 UTC) /// to run additional tasks /// </summary> private async Task OnServerReset() { ulong channelId = 0; if (ReleaseMode.Mode == "ProdSettings") { channelId = await ChannelHelper.GetChannelId(_mongoClient, "broadcast", "bot-channel"); } else { channelId = 720690834638372949; } var broadcastChannel = _discordClient.GetChannel(channelId) as SocketTextChannel; var utcNow = DateTime.UtcNow; if (utcNow.Hour == 0) { // Different collections to filter results from var tomorrowPveDailiesId = await HttpService.GetTomorrowsPveDailiesId(); var dailyPveAchievements = await DatabaseService.GetDailyPveAchievements(_mongoClient); var dailyPveWatchlist = await DatabaseService.GetDailyPveWatchlist(_mongoClient); List <string> dailyPveNames = new(); List <string> upcomingPveDailies = new(); dailyPveNames = AchievementHelper.AchievementNamesFromIds(tomorrowPveDailiesId, dailyPveAchievements); upcomingPveDailies = AchievementHelper.AchievementsSetToAppear(dailyPveNames, dailyPveWatchlist); // List is non-empty; proceed to build an embedded message if (upcomingPveDailies.Count > 0) { var embed = new EmbedBuilder { Title = "Daily Alert", Description = "Attention! A daily achievement that is being monitored will appear tomorrow!", Color = 0xffee05 }; foreach (string achieveName in upcomingPveDailies) { var achieveId = AchievementHelper.AchievementGetIdFromName(achieveName, dailyPveAchievements); // Valid ID check if (achieveId != 0) { var desc = await HttpService.ObtainAchievementDescription(achieveId); embed.AddField(achieveName, desc); } else { continue; } } // Broadcast the embedded message await broadcastChannel.SendMessageAsync(embed : embed.Build()); } else { await broadcastChannel.SendMessageAsync("Nothing to report..."); } } }