Ryze
Ryze
CC#
Created by Ryze on 3/10/2025 in #help
Problem with the first iteration in the loop, wont wait the set delay
I'm basically trying to iterate through users and then add a delay for each iteration, delay is user set. There is however a base delay that is also user set, I just calculate the final delay with base delay + delay. I use a variable to calculate which user its at, if its the first then its 0, second 1, third 2 etc. It resets after all the users have been done sending. Problem is, the first user sends instantly after 1 second, ignoring the delay.
33 replies
CC#
Created by Ryze on 3/9/2025 in #help
Why wont it reach return?
c#
static string WebMessage;
static async void ConsecutiveWebhookMessage()
{
doit = true;
Console.Clear();
Console.Write("Webhook URL: ");
webhookURL = Console.ReadLine();

if (string.IsNullOrEmpty(webhookURL))
{
doit = false;
Console.WriteLine("Discord webhook cannot be empty.");
Thread.Sleep(1000);
return;
}
else if (!webhookURL.Contains("discord.com/api/webhooks"))
{
doit = false;
Console.WriteLine("Please enter a valid discord webhook.");
Thread.Sleep(1000);
return;
}

if (doit == true)
{
Console.WriteLine("Send your message down below");
WebMessage = Console.ReadLine();
SendMessage();
}

}

static async void SendMessage()
{

string json = $"{{\"content\":\"{WebMessage}\"}}";

using (HttpClient client = new HttpClient())
{
HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");
client.PostAsync(webhookURL, content).Wait();

}
}
c#
static string WebMessage;
static async void ConsecutiveWebhookMessage()
{
doit = true;
Console.Clear();
Console.Write("Webhook URL: ");
webhookURL = Console.ReadLine();

if (string.IsNullOrEmpty(webhookURL))
{
doit = false;
Console.WriteLine("Discord webhook cannot be empty.");
Thread.Sleep(1000);
return;
}
else if (!webhookURL.Contains("discord.com/api/webhooks"))
{
doit = false;
Console.WriteLine("Please enter a valid discord webhook.");
Thread.Sleep(1000);
return;
}

if (doit == true)
{
Console.WriteLine("Send your message down below");
WebMessage = Console.ReadLine();
SendMessage();
}

}

static async void SendMessage()
{

string json = $"{{\"content\":\"{WebMessage}\"}}";

using (HttpClient client = new HttpClient())
{
HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");
client.PostAsync(webhookURL, content).Wait();

}
}
does anyone know why it wont return after it says "Please enter a valid discord webhook"? It looks as if everything it right to me. I deleted the thread.sleep but still nothing happens. Why wont it reach return;?
59 replies