discord-webhook-client 4.0.0

dotnet add package discord-webhook-client --version 4.0.0
                    
NuGet\Install-Package discord-webhook-client -Version 4.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="discord-webhook-client" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="discord-webhook-client" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="discord-webhook-client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add discord-webhook-client --version 4.0.0
                    
#r "nuget: discord-webhook-client, 4.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=discord-webhook-client&version=4.0.0
                    
Install discord-webhook-client as a Cake Addin
#tool nuget:?package=discord-webhook-client&version=4.0.0
                    
Install discord-webhook-client as a Cake Tool

Discord Webhook Client

NuGet NuGet

Simple .NET client to send Discord (https://discordapp.com/) messages using a webhook.

Reference documentation for creating this client: Discord Webhooks Guide and Discord Developer Portal.

Target

.NET 8.0+

For more information about suported versions visit https://docs.microsoft.com/pt-br/dotnet/standard/net-standard

Installation

NuGet

Install-Package discord-webhook-client

.NET CLI

dotnet add package discord-webhook-client

How to send a message?

Sending a message is very simple!

  • Add reference to namespace JNogueira.Discord.WebhookClient
  • In the Program.cs file add service.AddDiscordWebhookClient("Your Discord webhook URL here!")
  • Get an instance of the class DiscordWebhookClient. For more information about how to create a Discord webhook, visit https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks
  • Create your DiscordMessage instance with all parameters of your message.
  • Call DiscordWebhookClient.SendToDiscordAsync method to send your message to Discord!
// Add reference to namespace JNogueira.Discord.Webhook.Client
using JNogueira.Discord.WebhookClient;

service.AddDiscordWebhookClient("Your Discord webhook URL where!");

// Get an instance of DiscordWebhookClient
var discordClient = serviceProvider.GetService<DiscordWebhookClient>();

// 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 discordClient.SendToDiscord(message);

Look at to your Discord channel...your message is there!

A messagem in your Discord channel

Sending a message with file attachments

var message = new DiscordMessage(
    ...
);

var file1 = new DiscordFile("test1.txt", Encoding.UTF8.GetBytes("This is the first file."));

var file2 = new DiscordFile("test2.txt", Encoding.UTF8.GetBytes("This is the secound file."));

await client.SendToDiscord(message, new[] { file1, file2 });

Send message as file attachment on exception

When an exception is throwing on sending the message, a new message can be sent to Discord with attachments containing message data and exception information.

var message = new DiscordMessage(
    content: new string('0', 7000), // <-- The content length limit is 2000 characters => Exception is throwing.
    ...
);

await _client.SendToDiscord(message, true);

A messagem in your Discord channel

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on discord-webhook-client:

Package Downloads
logger-discord-provider

A .NET Core Logger provider to send log messages to Discord.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 135 6/11/2025
3.1.0 112,097 7/25/2021
3.0.0 18,285 6/3/2021
2.0.0 6,126 5/10/2020
1.2.1 1,507 5/1/2020
1.1.1 1,191 1/28/2020
1.1.0 1,190 1/24/2020
1.0.5 1,024 1/21/2020
1.0.4 700 1/19/2020
1.0.3 687 1/18/2020
1.0.2 588 1/17/2020

Bug fix and Discord field limits validations.