private async Task Message_Created(MessageCreateEventArgs arg) { if (arg.Message.Author.IsBot) { return; } // Gets the number of webpages that we found in the message var matches = linkParser.Matches(arg.Message.Content); foreach (Match match in matches) { Console.WriteLine($"Found webpage: {match.Value}"); // If the site is valid and selling a monitor if (await CheckSiteMonitorValid(match.Value)) { //Send a quote Console.WriteLine("Monitor match is valid"); await arg.Channel.SendMessageAsync(Lists.ChooseFromLines(TextFileCategory.quotes)); Console.WriteLine("now sending to task.run..."); var waitForMessageThread = Task.Run(() => WaitForMessage(arg)); if (Task.CompletedTask.IsCompletedSuccessfully) { Console.WriteLine("Task.Run is completed!"); return; } } } }
private async Task WaitForMessage(MessageCreateEventArgs arg) { await Task.CompletedTask; var interactivity = dClient.GetInteractivity(); var result = await interactivity.WaitForMessageAsync(xm => xm.Content.ToLower().Contains("roblot"), TimeSpan.FromSeconds(30)); if (result.Result != null) { await dClient.SendMessageAsync(arg.Channel, Lists.ChooseFromLines(TextFileCategory.retorts)); } return; }