jlnpinheiro/discord-webhook-client

Discord API migration has broke it

Closed this issue · 8 comments

Discord API migration has broke it

Whats happening?

The server responded with error 400: BadRequest

Did you try this @Haapavuo ? 👇

using JNogueira.Discord.Webhook.Client;

// Create an instance of the class DiscordWebhookClient with your Discord webhook URL.
var client = new DiscordWebhookClient("Your Discord webhook URL herer!");

// Create your DiscordMessage with all parameters of your message.
var message = new DiscordMessage(
    "Discord Webhook Client sent this message! " + DiscordEmoji.Grinning,
    username: "Username",
    avatarUrl: "https://avatars3.githubusercontent.com/u/24236993?s=460&v=4",
    tts: false,
    embeds: new[]
    {
        new DiscordMessageEmbed(
            "Embed title " + DiscordEmoji.Thumbsup,
            color: 0,
            author: new DiscordMessageEmbedAuthor("Embed 1 author name"),
            url: "https://github.com/jlnpinheiro/discord-webhook-client/",
            description: "This is a embed description.",
            fields: new[]
            {
                new DiscordMessageEmbedField("Field 1 name", "Field 1 value"),
                new DiscordMessageEmbedField("Field 2 name", "Field 2 value")
            },
            thumbnail: new DiscordMessageEmbedThumbnail("https://avatars3.githubusercontent.com/u/24236993?s=460&v=4"),
            image: new DiscordMessageEmbedImage("https://avatars3.githubusercontent.com/u/24236993?s=460&v=4"),
            footer: new DiscordMessageEmbedFooter("This is a embed footer text", "https://avatars3.githubusercontent.com/u/24236993?s=460&v=4")
        )
    }
);

// Send the message!
await _client.SendToDiscord(message);```

I have a code that was working previously but now doesn't work. I haven't change anything so I believe the Discord API has changed?

The Discord API does not appear to have been modified. Look at this @Haapavuo: https://discord.com/developers/docs/resources/webhook

You are correct. The problem for me was that there was too many or too large embeds. The error message doesn't tell you that though. But everything works now if I reduce embed count or size.

image

how can I remove the message field and only have the webhook block?

@sneakerstadt the message field is required. I don't understand your question very well! Can you give me more details?