public static async Task SendCaptchaAsync(SocketUser u) { string captchaCode = ImageFactory.CreateCode(6); await Task.Yield(); Task save = verificationDatabase.Captcha.SetCaptchaAsync(captchaCode, u); MemoryStream imageStream = ImageFactory.BuildImage(captchaCode, 60, 160, 24, 14); imageStream.Position = 0; Image image = Image.FromStream(imageStream); image.Save($"{u.Id}.png", ImageFormat.Png); await Task.WhenAll ( save, u.SendFileAsync($"{u.Id}.png", $"Please type `\\verify` followed by a space and this captcha code to continue{((u as SocketGuildUser) != null ? $" to {(u as SocketGuildUser)!.Guild.Name}" : "")}.\n") ); image.Dispose(); File.Delete($"{u.Id}.png"); List <Task> commands = new(); foreach (SocketGuild g in u.MutualGuilds) { if (await verificationDatabase.Roles.GetVerificationRoleAsync(g) == null) { continue; } SocketGuildUser user = g.GetUser(u.Id); commands.Add(SendToCaptchaLog.SendToCaptchaLogAsync(SendToCaptchaLog.CaptchaType.Requested, user, captchaCode)); } await Task.WhenAll(commands); }