Advertisement
Guest User

Untitled

a guest
Jan 20th, 2021
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. <?PHP
  2.     function discordmsg($msg, $webhook) {
  3.         if($webhook != "") {
  4.             $ch = curl_init( $webhook );
  5.             curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
  6.             curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
  7.             curl_setopt( $ch, CURLOPT_POST, 1);
  8.             curl_setopt( $ch, CURLOPT_POSTFIELDS, $msg);
  9.             curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
  10.             curl_setopt( $ch, CURLOPT_HEADER, 0);
  11.             curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
  12.  
  13.             $response = curl_exec( $ch );
  14.             // If you need to debug, or find out why you can't send message uncomment line below, and execute script.
  15.             echo $response;
  16.             curl_close( $ch );
  17.         }
  18.     }
  19.  
  20.     // URL FROM DISCORD WEBHOOK SETUP
  21.     $webhook = "my webhook is in here";
  22.     $msg = json_decode('
  23.    {
  24.        "username":"BOTNAME",
  25.        "content":"The message the BOTNAME posts.",
  26.        "embeds": [{
  27.            "title":"The Link Title",
  28.            "description":"The Link Description",
  29.            "url":"https://www.thelinkurl.com/",
  30.            "color":DECIMALCOLORCODE,
  31.            "author":{
  32.                "name":"Site Name",
  33.                "url":"https://www.sitelink.com/",
  34.                "icon_url":"URLTOIMG"
  35.            },
  36.            "fields":[
  37.                {
  38.                    "name":"LISTITEM1",
  39.                    "value":"LISTVALUE1"
  40.                },
  41.                {
  42.                    "name":"LISTITEM2",
  43.                    "value":"LISTVALUE2"
  44.                },
  45.                {
  46.                    "name":"LISTITEM3",
  47.                    "value":"LISTVALUE3"
  48.                }]
  49.        }]
  50.    }
  51.    ', true);
  52.     discordmsg($msg, $webhook); // SENDS MESSAGE TO DISCORD
  53.     echo "sent?";
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement