Advertisement
Charliezkie

Discord Send WebHook

May 18th, 2020
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. public class dWebHook : IDisposable
  2.     {
  3.         private readonly WebClient dWebClient;
  4.         private static NameValueCollection discordValues = new NameValueCollection();
  5.         public string WebHook { get; set; }
  6.         public string UserName { get; set; }
  7.         public string ProfilePicture { get; set; }
  8.  
  9.         public dWebHook()
  10.         {
  11.             dWebClient = new WebClient();
  12.         }
  13.  
  14.  
  15.         public void SendMessage(string msgSend)
  16.         {
  17.             discordValues.Add("username", UserName);
  18.             discordValues.Add("avatar_url", ProfilePicture);
  19.             discordValues.Add("content", msgSend);
  20.  
  21.             dWebClient.UploadValues(WebHook, discordValues);
  22.         }
  23.  
  24.         public void Dispose()
  25.         {
  26.             dWebClient.Dispose();
  27.         }
  28.     }
  29.  
  30. ===================================================================================================
  31.  
  32. static void Main(string[] args)
  33.         {
  34.             using (dWebHook dcWeb = new dWebHook())
  35.             {
  36.                 dcWeb.ProfilePicture = "your webhook profile picture";
  37.                 dcWeb.UserName = "your webook name";
  38.                 dcWeb.WebHook = "your webhook url";
  39.                 dcWeb.SendMessage("your message");
  40.             }
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement