async Task RespondNotification(Notification notification) { foreach (var channel in notification.Channels) { ISocketMessageChannel foundChannel = GetChannel <SocketGuildChannel>(channel, false) as ISocketMessageChannel; await foundChannel?.SendMessageAsync(notification.Message); } }
private async Task EnableLogger() { _channel = (ISocketMessageChannel)_discord?.GetChannel(_channelId); foreach (var message in _preloadMessages) { await _channel?.SendMessageAsync(message); } }
public static async Task SendToDms(IUser user, string content = null, EmbedBuilder em = null, ISocketMessageChannel backup = null) { try { await user.SendMessageAsync(content, false, em?.Build()); } catch (Exception e) { Log.LogS("Failed to DM " + user.Id); Log.LogS(e); backup?.SendMessageAsync(content, false, em?.Build()); } }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { if (logLevel < _logLevel) { return; } var message = $"`{_category} ({logLevel})`: {state.ToString()} {exception}"; if (_channel == null) { _preloadMessages.Add(message); } else { _channel?.SendMessageAsync(message); } }
public async Task UserConnectsToVoice(SocketUser user, SocketVoiceState beforeState, SocketVoiceState afterState) { var guild = (user as SocketGuildUser).Guild; var server = Servers.GetServer(guild); var voiceChannelBefore = beforeState.VoiceChannel; var voiceChannelAfter = afterState.VoiceChannel; if (voiceChannelBefore != null && voiceChannelAfter == null) //When user disconnects from VC { ulong loggingVoiceDisconnectID = server.LogWhenUserDisconnectsFromVoiceChannel; if (loggingVoiceDisconnectID == 0) { return; } ISocketMessageChannel logVoiceDisconnect = (ISocketMessageChannel)_client.GetGuild(server.ID).GetChannel(loggingVoiceDisconnectID); EmbedBuilder embed = new EmbedBuilder(); embed.WithTitle("User Disconnected From Voice Chat"); embed.WithDescription($"**User:** `{user.Username}#{user.Discriminator}`" + $"\n**Exited From Channel:** `{voiceChannelBefore}`"); embed.WithThumbnailUrl("https://i.imgur.com/B5BNtp3.png"); embed.WithColor(Yellow); embed.WithTimestamp(DateTime.Now); await logVoiceDisconnect.SendMessageAsync("", false, embed.Build()); } else if (voiceChannelBefore == null && voiceChannelAfter != null) //When user connects to VC { ulong loggingVoiceConnectID = server.LogWhenUserConnectsToVoiceChannel; if (loggingVoiceConnectID == 0) { return; } ISocketMessageChannel logVoiceConnect = (ISocketMessageChannel)_client.GetGuild(server.ID).GetChannel(loggingVoiceConnectID); EmbedBuilder embed = new EmbedBuilder(); embed.WithTitle("User Connected To Voice Chat"); embed.WithDescription($"**User:** `{user.Username}#{user.Discriminator}`" + $"\n**Entered Channel:** `{voiceChannelAfter}`"); embed.WithThumbnailUrl("https://i.imgur.com/iAIa8La.png"); embed.WithColor(Yellow); embed.WithTimestamp(DateTime.Now); await logVoiceConnect.SendMessageAsync("", false, embed.Build()); } }
//this is async/void because it is an event handler public async void PollTwitchAPI(object source, ElapsedEventArgs e) { TwitchTokenData tokenData = await GetTokenAsync(); TwitchAPIData data = await RequestTwitchDataAsync(tokenData); //checks if BotToilet is streaming and that the message explaining so has not been sent already if (data.Data.Length != 0 && !alreadySentMessage) { //standard embed building EmbedAuthorBuilder embedAuthorBuilder = new EmbedAuthorBuilder() { Name = "BotToilet is now streaming!", Url = "https://www.twitch.tv/bottoilet" }; EmbedBuilder embedBuilder = new EmbedBuilder() { Author = embedAuthorBuilder, Color = new Color?(Color.Purple), ImageUrl = "https://static-cdn.jtvnw.net/previews-ttv/live_user_bottoilet-1920x1080.jpg?r=" + new Random().Next().ToString(), //cache buster Description = "https://www.twitch.tv/bottoilet" }; embedBuilder.AddField("Title", data.Data[0].Title, true); embedBuilder.AddField("Started (Eastern Time):", data.Data[0].StartedAt.ToLocalTime(), true); //gets the streaming channel and send messages channel = client.GetChannel(streamingChannelId) as ISocketMessageChannel; await channel.SendMessageAsync("BotToilet has gone live on Twitch!", embed: embedBuilder.Build()); alreadySentMessage = true; } //checks if BotToilet went offline thus resetting the alreadySentMessgae flag else if (data.Data.Length == 0 && alreadySentMessage) { alreadySentMessage = false; } await RevokeTokenAsync(tokenData); }
//updates channel permissions when a user leaves a voice channel public Task HandleDisconnect(SocketUser socketUser, ISocketMessageChannel targetChannel) { // Don't hide the channel for users that can manage messages if (!((SocketGuildUser)socketUser).GuildPermissions.ManageMessages) { OverwritePermissions overwrite = new OverwritePermissions(readMessages: PermValue.Deny); IGuildChannel textChannel = (IGuildChannel)targetChannel; textChannel.AddPermissionOverwriteAsync(socketUser, overwrite); } EmbedBuilder builder = new EmbedBuilder() { Description = ":mute: " + socketUser.Mention + " has left the voice channel ", Color = Color.Orange, ThumbnailUrl = socketUser.GetAvatarUrl(ImageFormat.Auto, 128) }; targetChannel.SendMessageAsync("", false, builder.Build()); return(Task.CompletedTask); }
//Static Methods internal static async Task SpecializationChoice(Player player, ISocketMessageChannel chan) { EmbedBuilder embed = player.UserEmbedColor(); embed.WithTitle("Character Class/Specialization"); embed.WithDescription("**Class may not be changed.**"); string data = null; if (player.IsPremium(5)) { data += "0;"; embed.AddField($"{EUI.specs[0]} Joker", SpecDescription[0]); } for (int i = 1; i < SpecDescription.Length; i++) { embed.AddField($"{EUI.specs[i]} {(Specs)i}", SpecDescription[i]); data += $"{i};"; } await player.NewUI(await chan.SendMessageAsync(embed: embed.Build()), MsgType.SpecSelection, data); }
public async Task LoggingUserLeaves(SocketGuildUser user) { IGuild server = (user as IGuildUser).Guild; Server currentServer = Servers.GetServer((SocketGuild)server); ulong loggingChannelID = currentServer.LogWhenUserLeaves; if (loggingChannelID == 0) { return; } ISocketMessageChannel logChannel = (ISocketMessageChannel)_client.GetGuild(currentServer.ID).GetChannel(loggingChannelID); EmbedBuilder embed = new EmbedBuilder(); embed.WithTitle("User Left"); embed.WithDescription($"User: `{user.Username}#{user.Discriminator}`\n`User ID: {user.Id}`"); embed.WithThumbnailUrl("https://i.imgur.com/624oxi8.png"); embed.WithTimestamp(DateTime.Now); embed.WithColor(Red); await logChannel.SendMessageAsync("", false, embed.Build()); }
async Task MessageSender() { while (true) { await Task.Delay(500); if (MessageStore.Count != 0) { await messageChannel?.SendMessageAsync(MessageStore[0]); MessageStore.RemoveAt(0); } if (LogStore.Count != 0) { await logChannel?.SendMessageAsync(LogStore[0]); LogStore.RemoveAt(0); } } }
private async Task LoggingUserUnbanned(SocketUser user, SocketGuild server) { Server currentServer = Servers.GetServer(server); var currentLog = ServerMessageLogs.GetLog(server); ulong loggingChannelID = currentServer.LogWhenUserIsUnbanned; if (loggingChannelID == 0) { return; } ISocketMessageChannel logChannel = (ISocketMessageChannel)_client.GetGuild(currentServer.ID).GetChannel(loggingChannelID); EmbedBuilder embed = new EmbedBuilder(); embed.WithTitle("User Unbanned"); embed.WithDescription($"User: `{user.Username}#{user.Discriminator}`\nUser ID: `{user.Id}`"); embed.WithThumbnailUrl("https://i.imgur.com/RH0HHkJ.png"); embed.WithTimestamp(DateTime.Now); embed.WithColor(Violet); await logChannel.SendMessageAsync("", false, embed.Build()); }
/*function essentially sends a message to the chat listing all the available images in the config file. Function takes a * ISocketMessageChannel which should be the channel the user sent the message from (given by message.Channel) and an array * of strings which should be in the format of {":ultrafastparrot", ":parrot", ...} which should be parsed from the config file */ public async void help(ISocketMessageChannel channel, string[] words) { string help = "```Available emojis (example usage-> :angelparrot) :\n"; int counter = 0; foreach (string word in words) { counter++; string temp = word.Substring(1, word.IndexOf(" ") - 1) + ", "; help += temp; if (counter % 4 == 0) { help += "\n"; } }//end of for loop help = help.Remove(help.Length - 2, 1); help = help.Insert(help.Length - 1, ".```"); System.Threading.Thread.Sleep(150); await channel.SendMessageAsync(help); }
public static async Task <IMessage> SendSteamProfile(this ISocketMessageChannel channel, string title, string description, string url, RequestOptions options = null) { var embed = new EmbedBuilder() .WithColor(Utils.RandomColor(), Utils.RandomColor(), Utils.RandomColor()) .WithDescription(description) .WithThumbnailUrl(url ?? "No image found") .WithAuthor(author => { author.WithIconUrl( "https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Steam_icon_logo.svg/768px-Steam_icon_logo.svg.png") .WithName(title); }) .WithCurrentTimestamp() .WithFooter("Powered by Steam API") .Build(); var message = await channel.SendMessageAsync(embed : embed); return(message); }
public static async Task ReplyWithLegalizedSetAsync(this ISocketMessageChannel channel, ITrainerInfo sav, ShowdownSet set) { if (set.Species <= 0) { await channel.SendMessageAsync("Oops! I wasn't able to interpret your message! If you intended to convert something, please double check what you're pasting!").ConfigureAwait(false); return; } var template = AutoLegalityWrapper.GetTemplate(set); var pkm = sav.GetLegal(template, out var result); var la = new LegalityAnalysis(pkm); var spec = GameInfo.Strings.Species[template.Species]; var reason = result == "Timeout" ? "That set took too long to generate." : "I wasn't able to create something from that."; var msg = la.Valid ? $"Here's your ({result}) legalized PKM for {spec} ({la.EncounterOriginal.Name})!" : $"Oops! {reason} Here's my best attempt for that {spec}!"; await channel.SendPKMAsync(pkm, msg + $"\n{ReusableActions.GetFormattedShowdownText(pkm)}").ConfigureAwait(false); }
public static void SendPages(this ISocketMessageChannel msgChannel, Pages pages) { var sendMessage = msgChannel.SendMessageAsync("", false, pages.GetFirst).Result; if (pages.PageCount > 1) { sendMessage.CreateReactionCollector((userID, emote, wasAdded) => { if (emote.Name == ForwardsEmote) { pages.GoForwards(); } else if (emote.Name == BackwardsEmote) { pages.GoBackwards(); } }, new Emoji(BackwardsEmote), new Emoji(ForwardsEmote)); pages.MessageHandle = sendMessage; } }
//Clear public async Task Clear(ISocketMessageChannel requester, bool all = false) { if (!m_loadedPlaylists) { await requester.SendMessageAsync("Playlists still loading please wait..."); return; } if (m_activePlaylist != null) { if (all) { m_activePlaylist.Clear(); } else { m_activePlaylist.ClearPlaying(); } } }
private static async Task DisplayList(ISocketMessageChannel context) { if (_trackedList != null) { await _trackedList.DeleteMessage(); } var msg = "```diff\r\n"; for (int i = 10 * _indx; i < (i + 10 > _listContents.Count() ? _listContents.Count() : i + 10); i++) { msg += $"-{_listContents[i]}\r\n"; } msg += "```"; _trackedList = await context.SendMessageAsync(msg); await _trackedList.RemoveReactions(); await _trackedList.AddNavigations(_indx, (int)Math.Ceiling((decimal)_listContents.Count() / 10)); }
public async Task CratesListUI(ISocketMessageChannel chan) { if (ResourceCrates == null) { ResourceCrates = new int[5]; } while (ResourceCrates.Length < 5) { ResourceCrates = ArrayM.AddItem(ResourceCrates, 0); } EmbedBuilder em = AMYPrototype.Commands.DUtils.BuildEmbed("Resource Crates", "Select a Crate type to open." + Environment.NewLine + $"{EUI.GetNum(0)} {ResourceCrates[0]} x Wooden Crates" + Environment.NewLine + $"{EUI.GetNum(1)} {ResourceCrates[1]} x Bronze Crates" + Environment.NewLine + $"{EUI.GetNum(2)} {ResourceCrates[2]} x Silver Crates" + Environment.NewLine + $"{EUI.GetNum(3)} {ResourceCrates[3]} x Golden Crates" + Environment.NewLine + $"{EUI.GetNum(4)} {ResourceCrates[4]} x Platinum Crates"); NewUI(await chan.SendMessageAsync(embed: em.Build()), MsgType.ResourceCrateList); }
private async Task LoggingUserJoins(SocketGuildUser user) { IGuild server = (user as IGuildUser).Guild; Server currentServer = Servers.GetServer((SocketGuild)server); var currentLog = ServerMessageLogs.GetLog((SocketGuild)server); ulong loggingChannelID = currentServer.LogWhenUserJoins; if (loggingChannelID == 0) { return; } ISocketMessageChannel logChannel = (ISocketMessageChannel)_client.GetGuild(currentServer.ID).GetChannel(loggingChannelID); EmbedBuilder embed = new EmbedBuilder(); embed.WithTitle("User Joined"); embed.WithDescription($"User: `{user.Username}#{user.Discriminator}`\nUser ID: `{user.Id}`\nAccount Created: `{user.CreatedAt}`"); embed.WithThumbnailUrl("https://i.imgur.com/LXiUKgF.png"); embed.WithTimestamp(DateTime.Now); embed.WithColor(SkyBlue); await logChannel.SendMessageAsync("", false, embed.Build()); }
public void Dispose(DisconnectReason reason) { string message = ""; switch (reason) { case DisconnectReason.NoUsers: message = "Disconnected: No users."; break; case DisconnectReason.Idle: message = "Disconnected: Idle for too long."; break; } if (message != "") { _messageChannel?.SendMessageAsync(message); } Dispose(); }
public static async Task DeleteSupportChannel(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel ch, SocketReaction s) { var channel = s.Channel as SocketGuildChannel; //allow us to send a message var config = GuildConfig.GetGuildConfig(channel.Guild.Id); //get the config so we can see the support channel name. (and embed colour) var embed = new EmbedBuilder() //create the embedded message. .WithColor(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3) .WithDescription($"Ticket marked as solved by {s.User.Value.Mention}! Closing in 45 seconds.") .WithAuthor(s.User.Value); if (channel.Name.Contains($"{config.SupportChannelName}-{s.UserId}") && s.Emote.Equals(new Emoji("☑"))) //check if a user made the reaction in a support ticket, //check if the emote is `☑` and then delete the channel. { if (s.UserId != 320942091049893888 && s.UserId != 410547925597421571) //check if the id of the person who made the reaction is NOT SIVA-dev or SIVA public. { await ch.SendMessageAsync("", false, embed); //send the embedded message defined above. Thread.Sleep(45000); //wait 45 seconds (45000ms) await channel.DeleteAsync(); //delete the channel } } }
public static async Task StartDuel(ISocketMessageChannel channel, SocketGuildUser user, SocketUser req) { var config = GlobalUserAccounts.GetUserAccount(req); var player2 = user.Guild.GetUser(user.Id); var configg = GlobalUserAccounts.GetUserAccount(player2); configg.OpponentId = req.Id; config.OpponentId = user.Id; configg.OpponentName = req.Username; config.OpponentName = user.Username; config.Fighting = true; configg.Fighting = true; string[] whoStarts = new string[] { req.Mention, user.Mention }; Random rand = new Random(); int randomIndex = rand.Next(whoStarts.Length); string text = whoStarts[randomIndex]; config.whosTurn = text; configg.whosTurn = text; if (text == req.Mention) { config.whoWaits = user.Mention; configg.whoWaits = user.Mention; } else { config.whoWaits = req.Mention; configg.whoWaits = req.Mention; } GlobalUserAccounts.SaveAccounts(); await channel.SendMessageAsync($":crossed_swords: | {req.Mention} challenged {user.Mention} to a duel!\n\n**{configg.OpponentName}** has **{config.Health}** health!\n**{config.OpponentName}** has **{configg.Health}** health!\n\n{text}, you go first!"); }
private static async Task TryNotifyMember(IUser member, IGuildUser leader, ISocketMessageChannel commandChannel, ScheduledEvent @event, DiscordGuildConfiguration guildConfig, CancellationToken token) { var success = false; try { await member.SendMessageAsync( $"The run you reacted to (hosted by {leader.Nickname ?? leader.Username}) is beginning in 30 minutes!\n\n" + $"Message link: <{(await commandChannel.GetMessageAsync(@event.MessageId3)).GetJumpUrl()}>"); success = true; } catch (HttpException) { try { var message = await commandChannel.SendMessageAsync($"{member.Mention}, the run you reacted to (hosted by {leader.Nickname ?? leader.Username}) is beginning in 30 minutes!\n\n" + $"Message link: <{(await commandChannel.GetMessageAsync(@event.MessageId3)).GetJumpUrl()}>"); (new Task(async() => { await Task.Delay((int)Threshold, token); try { await message.DeleteAsync(); } catch (HttpException) { } // Message was already deleted. })).Start(); success = true; } catch (HttpException) { Log.Warning("Every attempt at message user {Username} failed.", member.ToString()); } } if (success) { Log.Information($"Info sent to {member} about {leader}'s run."); } }
//static bool WaitNextConnection = true; static async void timer_ElapsedAsync(object sender, ElapsedEventArgs e) { /*bool NetAvailable = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable(); * if (NetAvailable == true) * { * if (WaitNextConnection == true) * { * await Client.LogoutAsync(); * await Client.StopAsync(); * Client.Dispose(); * Client = new DiscordSocketClient(); * * await Client.LoginAsync(Discord.TokenType.Bot, fileManager.ConfigJson["apikey"].ToString(), true); * await Client.StartAsync(); * * Client.Ready += Client_Ready; * Client.MessageReceived += HandleCommand; * } * } * else * { * WaitNextConnection = true; * }*/ string msg = IPCManager.check_printDataFile(fileManager.ConfigJson["DataFileLocate"].ToString()); if (msg == null) { return; } ISocketMessageChannel channel = (Client.GetChannel(Convert.ToUInt64(fileManager.ConfigJson["DisplayRoom"].ToString())) as ISocketMessageChannel); Console.WriteLine(msg); try { await channel.SendMessageAsync(msg); } catch { } }
public static async Task Age(IMessage message, ISocketMessageChannel channel) { await message.DeleteAsync(); var r1 = new Emoji("\u0031\u20e3"); var r2 = new Emoji("\u0032\u20e3"); var r3 = new Emoji("\u0033\u20e3"); var r4 = new Emoji("\u0034\u20e3"); var r5 = new Emoji("\u0035\u20e3"); var r6 = new Emoji("\u0036\u20e3"); var r7 = new Emoji("➡"); EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor("WIEK"); eb.Author.WithIconUrl("https://upload.wikimedia.org/wikipedia/commons/thumb/0/0e/Logo_anniversaire_rouge.svg/1024px-Logo_anniversaire_rouge.svg.png"); eb.WithTitle("Wybierz swój wiek klikając w odpowiednią reakcje"); eb.AddField("", ":one: 13 lat\n\n:two: 14 lat\n\n:three: 15 lat", true); eb.AddField("", ":four: 16 lat\n\n:five: 17 lat\n\n:six: 18+ lat", true); eb.WithColor(new Color(185, 43, 43)); RestUserMessage msg = await channel.SendMessageAsync("", false, eb.Build()); ReactionChannels.channels.age = msg.Id; ReactionChannels.SaveChannels(); await msg.AddReactionAsync(r1); await msg.AddReactionAsync(r2); await msg.AddReactionAsync(r3); await msg.AddReactionAsync(r4); await msg.AddReactionAsync(r5); await msg.AddReactionAsync(r6); await msg.AddReactionAsync(r7); }
private void birthdayHandler(DateTime date, Scheduler scheduler) { m_ctSource = new CancellationTokenSource(); var dateNow = DateTime.Now; TimeSpan ts; if (date > dateNow) { ts = date - dateNow; } else { date = getNextDate(date, scheduler); ts = date - dateNow; } Task.Delay(ts).ContinueWith(async(x) => { List <User> todaysBirthdays = GetBirthdays(); if (todaysBirthdays != null || todaysBirthdays.Count > 0) { foreach (User birthday in todaysBirthdays) { ISocketMessageChannel channel = (ISocketMessageChannel)_client.GetChannel(_config.BirthdayChannel); SocketUser user = _client.GetUser(birthday.UserID); string useString = birthdayString[_random.Next(birthdayString.Length)]; var age = DateTime.Today.Year - birthday.DateOfBirth.Year; useString = useString.Replace("{userName}", user.Mention).Replace("{age}", age.ToString()); await channel.SendMessageAsync(useString); } } birthdayHandler(getNextDate(date, scheduler), scheduler); }, m_ctSource.Token); }
private static async Task SendAllianceInfoAsync(ISocketMessageChannel channel, string arg) { if (long.TryParse(arg, out long allianceId)) { var alliance = await EveClient.Alliances.Get(allianceId).ConfigureAwait(false); var icons = await EveClient.Alliances.GetIcons(allianceId).ConfigureAwait(false); var embed = new EmbedBuilder { Author = new EmbedAuthorBuilder().WithName(alliance.Name).WithUrl(ZKill.GetAllianceLink(alliance.Id)), ThumbnailUrl = icons.GetSmallest(), Fields = new List <EmbedFieldBuilder> { new EmbedFieldBuilder().WithName("Founded").WithValue(alliance.DateFounded).WithIsInline(true), new EmbedFieldBuilder().WithName("Ticker").WithValue(alliance.Ticker).WithIsInline(true) } }; await channel.SendMessageAsync("", embed : embed).ConfigureAwait(false); } }
private async Task <(IEnumerable <IUserMessage> messages, IUserMessage logMessage)> GetMessagesInChannelAsync(ISocketMessageChannel collectionChannel, ISocketMessageChannel logChannel) { if (!(collectionChannel is IGuildChannel guildChannel)) { throw new ArgumentException("Collection channel must be a guild channel"); } //We send a message at the start of the process and reuse it to update progress, and display the final results var logMessage = await logChannel.SendMessageAsync("", embed : GetProgressEmbed(0, null, guildChannel)); IMessage offset = null; var ret = new List <IMessage>(); IEnumerable <IMessage> lastBatch; do { if (offset != null) { lastBatch = await collectionChannel.GetMessagesAsync(offset, Direction.Before).FlattenAsync(); } else { lastBatch = await collectionChannel.GetMessagesAsync().FlattenAsync(); } ret.AddRange(lastBatch); offset = ret.Last(); if (ret.Count % 500 == 0) { await logMessage.ModifyAsync(prop => prop.Embed = GetProgressEmbed(ret.Count, offset, guildChannel)); } }while (lastBatch.Count() > 0); await logMessage.ModifyAsync(prop => prop.Embed = GetProgressEmbed(ret.Count, offset, guildChannel, true)); return(ret.OfType <IUserMessage>(), logMessage); }
public async Task CharListForCrate(ISocketMessageChannel chan, int crateNum) { string desc = null; var chars = GetCharFiles(_id); if (chars.Count < 1) { await chan.SendMessageAsync("No characters were found for this user, create a character using `new character`"); } else { for (int i = 0; i < chars.Count; i++) { desc += EUI.GetNum(i) + " " + chars[i].ToString() + Environment.NewLine; } EmbedBuilder em = AMYPrototype.Commands.DUtils.BuildEmbed($"Opening {(ReferenceData.ResourceCrate)crateNum} Crates", "Select a character to reward crate content to." + Environment.NewLine + desc); await EditUI(null, em.Build(), MsgType.ResourceCrateOpening, crateNum + ";" + chars.Count, chan); } }
public override async Task startAsync() { while (!shutting_down) { List <Reminder> toRemove = new List <Reminder>(); foreach (Reminder reminder in reminders.Where(t => (t.expired()))) { ISocketMessageChannel channel = reminder.Channel.get_channel(Program.client); channel.SendMessageAsync($"_Buzz_ {Utils.mention(reminder.UserID)} {reminder.Message}"); toRemove.Add(reminder); } foreach (Reminder re in toRemove) { reminders.Remove(re); } await Task.Delay(5000); //the loop will fire 5 seconds } }