C#C
C#10mo ago
Ryze

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();

            }
        }


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;?
Was this page helpful?