Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Simple C# written code to send messages embeds and files using discord webhooks

License

N4T4NM/CSharpDiscordWebhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSharpDiscordWebhook

Simple C# written code to send messages embeds and files using discord webhooks

You need to add NewtonSoft.Json to references.

Code usage

Importing webhook code

using Discord;
using Discord.Webhook;

Creating webhook

DiscordWebhook hook = new DiscordWebhook();
hook.Url = "https://discordapp.com/hook-url";

Creating message

DiscordMessage message = new DiscordMessage();
message.Content = "Example message, ping @everyone, <@userid>";
message.TTS = true; //read message to everyone on the channel
message.Username = "Webhook username";
message.AvatarUrl = "http://url-of-image";

//embeds
DiscordEmbed embed = new DiscordEmbed();
embed.Title = "Embed title";
embed.Description = "Embed description";
embed.Url = "Embed Url";
embed.Timestamp = DateTime.Now;
embed.Color = Color.Red; //alpha will be ignored, you can use any RGB color
embed.Footer = new EmbedFooter() {Text="Footer Text", IconUrl="http://url-of-image"};
embed.Image = new EmbedMedia() {Url="Media URL", Width=150, Height=150}; //valid for thumb and video
embed.Provider = new EmbedProvider() {Name="Provider Name", Url="Provider Url"};
embed.Author = new EmbedAuthor() {Name="Author Name", Url="Author Url", IconUrl="http://url-of-image"};

//fields
embed.Fields = new[]{ 
  new EmbedField() {Name="Field Name", Value="Field Value", InLine=true },
  new EmbedField() {Name="Field Name 2", Value="Field Value 2", InLine=true }};

//set embed
message.Embeds = new[]{embed};

Sending message

//message
hook.Send(message);

//file
hook.Send(message, new FileInfo("C:/File/Path.file"));

About

Simple C# written code to send messages embeds and files using discord webhooks

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •