Advertisement
Guest User

Untitled

a guest
Feb 17th, 2022
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var request = new XMLHttpRequest();
  2. request.open("POST", "https://discord.com/api/webhooks/944003693852901449/f_oJlQtVE_khP9gD4pBSWDN-lVlBRQoDtaw54hZNmlx1e-aHwCdgDEi_KU31pKwqKYRo");
  3. // again, replace the url in the open method with yours
  4. request.setRequestHeader('Content-type', 'application/json');
  5.  
  6. var myEmbed = {
  7.   field: {
  8.       name: "test",
  9.       value: "message"
  10.   },
  11.   title: "Webhook",
  12.   description: "This is a cool-looking Discord embed, sent directly from JavaScript!",
  13.   color: hexToDecimal("#ff0000")
  14. }
  15.  
  16. var params = {
  17.   username: "test",
  18.   embeds: [ myEmbed ]
  19. }
  20.  
  21. request.send(JSON.stringify(params));
  22.  
  23. // function that converts a color HEX to a valid Discord color
  24. function hexToDecimal(hex) {
  25.   return parseInt(hex.replace("#",""), 16)
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement