© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•12mo ago•
58 replies
Ryze

Why wont it reach return?

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

            }
        }
        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;?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

I never reach the return, and i dont know why?
C#CC# / help
3y ago
❔ Why it wont let me type array ?
C#CC# / help
3y ago
✅ Why wont it output to 2 decimal points?
C#CC# / help
2y ago