Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- function discordmsg($msg, $webhook) {
- if($webhook != "") {
- $ch = curl_init( $webhook );
- curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
- curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
- curl_setopt( $ch, CURLOPT_POST, 1);
- curl_setopt( $ch, CURLOPT_POSTFIELDS, $msg);
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt( $ch, CURLOPT_HEADER, 0);
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
- $response = curl_exec( $ch );
- // If you need to debug, or find out why you can't send message uncomment line below, and execute script.
- echo $response;
- curl_close( $ch );
- }
- }
- // URL FROM DISCORD WEBHOOK SETUP
- $webhook = "my webhook is in here";
- $msg = json_decode('
- {
- "username":"BOTNAME",
- "content":"The message the BOTNAME posts.",
- "embeds": [{
- "title":"The Link Title",
- "description":"The Link Description",
- "url":"https://www.thelinkurl.com/",
- "color":DECIMALCOLORCODE,
- "author":{
- "name":"Site Name",
- "url":"https://www.sitelink.com/",
- "icon_url":"URLTOIMG"
- },
- "fields":[
- {
- "name":"LISTITEM1",
- "value":"LISTVALUE1"
- },
- {
- "name":"LISTITEM2",
- "value":"LISTVALUE2"
- },
- {
- "name":"LISTITEM3",
- "value":"LISTVALUE3"
- }]
- }]
- }
- ', true);
- discordmsg($msg, $webhook); // SENDS MESSAGE TO DISCORD
- echo "sent?";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement