private async void MinuteTimer(ulong minute) { Statuses.SaveConfig(); bool countdownsModified = false; foreach (ulong guild in Countdowns.Countdowns.Keys) { ulong?channel = (Countdowns.CountdownChannels?.ContainsKey(guild) ?? false) ? Countdowns.CountdownChannels[guild] : (ulong?)null; if (channel == null) { continue; } foreach (var countdown in Countdowns.Countdowns[guild]) { if (countdown.Value < DateTimeOffset.Now) { await((ITextChannel)Client.GetChannel(channel.Value)).SendMessageAsync("", embed: CommandTools.GenerateCountdownCompleteEmbed(this, countdown.Key, countdown.Value).Build()); countdownsModified = true; } } } if (countdownsModified) { foreach (ulong guild in Countdowns.Countdowns.Keys) { foreach (string key in Countdowns.Countdowns[guild].Where(x => x.Value < DateTimeOffset.Now).Select(x => x.Key).ToArray()) { Countdowns.Countdowns[guild].Remove(key); } } Countdowns.SaveConfig(); } foreach (var reminder in Reminders.Reminders.Where(reminder => reminder.Timestamp < DateTimeOffset.Now)) { EmbedBuilder embed = new EmbedBuilder { Author = new EmbedAuthorBuilder { Name = $"{Client.GetUser(reminder.SenderId)?.Username ?? "Someone"} sent you a reminder", IconUrl = Client.GetUser(reminder.SenderId)?.AvatarUrlOrDefaultAvatar() }, Description = reminder.Message, ThumbnailUrl = "http://icons.iconarchive.com/icons/webalys/kameleon.pics/512/Bell-icon.png", Timestamp = reminder.Timestamp, Color = new Color(224, 79, 95) }; var message = await Client.GetUser(reminder.ReceiverId).SendMessageAsync("", embed: embed.Build()); await message.AddReactionAsync(new Emoji("💤")); } Reminders.Reminders.RemoveAll(x => x.Timestamp < DateTimeOffset.Now); Reminders.SaveConfig(); if (DynamicMessages.Messages != null) { foreach (var message in DynamicMessages.Messages) { try { if (minute % message.UpdateInterval != 0) { continue; } var channel = (IMessageChannel)Client.GetGuild(message.GuildId).GetChannel(message.ChannelId); var discordMessage = (IUserMessage)await channel.GetMessageAsync(message.MessageId); if (discordMessage == null) { DynamicMessages.Messages.Remove(message); continue; } var context = new DiscordDynamicMessageContext(discordMessage, this, message.CommandText); string prefix = CommandTools.GetCommandPrefix(context, channel); if (message.CommandText.StartsWith(prefix)) { await CommandRunner.Run(message.CommandText, context, prefix, false); } else { await context.ReplyError($"The string `{message.CommandText}`", "Invalid Command"); } } catch { // Fail silently } } DynamicMessages.SaveConfig(); } }