Skip to content
The Chat Archive
gemini-2.5-pro-preview-05-06· Google LMArena Human Preference 140K

i need add editer in app discordwebhook

  1. User

    i need add editer in app discordwebhook

  2. Assistant

    Okay, let's create a C# console application that will prompt you to fill in each of the "put ur txt" fields interactively before sending the Discord webhook.

    This version will:

    1. Ask for the Webhook URL.
    2. Ask for each piece of text for the embed and payload.
    3. Allow multi-line input for the description.
    4. Handle color input (you can enter decimal or hex like 0xRRGGBB).

    Here's the code:

    // Program.cs
    using System;
    using System.Collections.Generic;
    using System.Net.Http;
    using System.Text;
    using System.Text.Json;
    using System.Threading.Tasks;
    using System.Globalization; // For parsing hex color
    
    namespace DiscordWebhookEditor
    {
        internal class Program
        {
            static async Task Main(string[] args)
            {
                Console.WriteLine("--- Discord Webhook Embed Editor ---");
    
                // 1. Get Webhook URL
                string webhookUrl = GetStringInput("Enter your Discord Webhook URL:", "https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN");
    
                Console.WriteLine("\n--- Payload Details ---");
                string username = GetStringInput("Enter Bot Username (e.g., 'My Awesome Bot'):", "put ur txt");
                string avatarUrl = GetStringInput("Enter Avatar URL (e.g., 'https://your-logo-link.com/logo.png'):", "https://your-logo-link.com/logo.png");
    
                Console.WriteLine("\n--- Embed Details ---");
                string embedTitle = GetStringInput("Enter Embed Title:", "put ur txt");
    
                Console.WriteLine("\n--- Embed Description (Multi-line input) ---");
                Console.WriteLine("Enter your description. Type '--end--' on a new line when finished.");
                Console.WriteLine("Example format:\n" +
                                  "**Section 1:**\n" +
                                  "- Item 1\n" +
                                  "- Item 2\n\n" +
                                  "**Section 2:**\n" +
                                  "- Item A\n" +
                                  "`code` - details");
                string embedDescription = GetMultiLineInput(
                    "**put ur txt:**\n" +
                    "- put ur txt\n" +
                    "- put ur txt\n" +
                    "- put ur txt\n" +
                    "- put ur txt\n\n" +
                    "**put ur txt:**\n" +
                    "- put ur txt\n" +
                    "- put ur txt\n" +
                    "- put ur txt\n" +
                    "**put ur txt**\n" +
                    "`put ur txt` - put ur txt\n" +
                    "put ur txt\n" +
                    "put ur txt"
                );
    
                int embedColor = GetColorInput("Enter Embed Color (decimal e.g., 3092790 or hex e.g., 0x2F3136 or 2F3136):", 3092790);
    
                Console.WriteLine("\n--- Embed Footer ---");
                string footerText = GetStringInput("Enter Footer Text (e.g., 'Info • Timestamp'):", "put ur txt • put ur txt");
    
                Console.WriteLine("\n--- Embed Thumbnail ---");
                string thumbnailUrl = GetStringInput("Enter Thumbnail URL (e.g., 'https://your-logo-link.com/logo.png'):", "https://your-logo-link.com/logo.png");
    
                var embed = new
                {
                    title = embedTitle,
                    description = embedDescription,
                    color = embedColor,
                    footer = new { text = footerText },
                    thumbnail = new { url = thumbnailUrl }
                };
    
                var payload = new
                {
                    username = username,
                    avatar_url = avatarUrl,
                    embeds = new[] { embed }
                };
    
                // Serialize to JSON
                // Options to allow pretty printing for review, but not strictly necessary for sending
                var jsonOptions = new JsonSerializerOptions { WriteIndented = true };
                var jsonPayload = JsonSerializer.Serialize(payload, jsonOptions);
    
                Console.WriteLine("\n--- Review Payload ---");
                Console.WriteLine(jsonPayload);
    
                Console.Write("\nDo you want to send this embed? (yes/no): ");
                string confirmation = Console.ReadLine()?.Trim().ToLower();
    
                if (confirmation == "yes" || confirmation == "y")
                {
                    // Send request
                    using var httpClient = new HttpClient();
                    var response = await httpClient.PostAsync(
                        webhookUrl,
                        new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json") // Send non-indented for efficiency
                    );
    
                    // Result
                    if (response.IsSuccessStatusCode)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("✅ Embed sent successfully.");
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine($"❌ Failed to send embed: {(int)response.StatusCode}");
                        Console.ResetColor();
                        Console.WriteLine(await response.Content.ReadAsStringAsync());
                    }
                }
                else
                {
                    Console.WriteLine("Embed sending cancelled.");
                }
    
                Console.ResetColor();
                Console.WriteLine("\nPress any key to exit...");
                Console.ReadKey();
            }
    
            static string GetStringInput(string prompt, string defaultValue)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Write($"{prompt} ");
                Console.ResetColor();
                Console.Write($"[Default: '{defaultValue}']: ");
                string input = Console.ReadLine();
                return string.IsNullOrWhiteSpace(input) ? defaultValue : input;
            }
    
            static string GetMultiLineInput(string defaultStructure)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("(Enter '--end--' on a new line to finish input for this field)");
                Console.WriteLine("Default structure hint (you can replace all of this):");
                Console.WriteLine(defaultStructure);
                Console.ResetColor();
                Console.WriteLine("Start typing your description below:");
    
                var lines = new List<string>();
                string line;
                while ((line = Console.ReadLine()) != null && line.Trim().ToLower() != "--end--")
                {
                    lines.Add(line);
                }
    
                string result = string.Join("\n", lines);
                return string.IsNullOrWhiteSpace(result) ? defaultStructure.Replace("put ur txt", "Default text") : result;
            }
    
            static int GetColorInput(string prompt, int defaultValue)
            {
                while (true)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write($"{prompt} ");
                    Console.ResetColor();
                    Console.Write($"[Default: {defaultValue} (0x{defaultValue:X6})]: ");
                    string input = Console.ReadLine();
    
                    if (string.IsNullOrWhiteSpace(input))
                    {
                        return defaultValue;
                    }
    
                    try
                    {
                        if (input.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
                        {
                            return int.Parse(input.Substring(2), NumberStyles.HexNumber);
                        }
                        else if (int.TryParse(input, out int decimalColor))
                        {
                            return decimalColor;
                        }
                        else // Try parsing as hex without "0x"
                        {
                             return int.Parse(input, NumberStyles.HexNumber);
                        }
                    }
                    catch (FormatException)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Invalid format. Please enter a decimal number or hex (e.g., 3092790, 0x2F3136, or 2F3136).");
                        Console.ResetColor();
                    }
                    catch (OverflowException)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Input number is too large or too small.");
                        Console.ResetColor();
                    }
                }
            }
        }
    }
    

    How to use it:

    1. Create a new C# Console App project:

      • If using Visual Studio: Create a new project, select "Console App (.NET Core)" or "Console App".
      • If using .NET CLI: dotnet new console -n DiscordWebhookEditor Then cd DiscordWebhookEditor
    2. Replace Program.cs: Copy the code above and paste it into your Program.cs file, overwriting the default content.

    3. Run the application:

      • In Visual Studio: Click the "Start" button (or press F5).
      • Using .NET CLI: dotnet run
    4. Follow the prompts:

      • It will ask you for each piece of information.
      • For fields with defaults, you can just press Enter to use the default.
      • For the multi-line description, type your content. When you're done with the description, type --end-- on a new line and press Enter.
      • It will show you a JSON preview of what will be sent.
      • Confirm if you want to send it.

    This provides a much more interactive way to construct your Discord webhook message directly from the console!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.