mirror of
https://github.com/metallicgloss/WHMCS-Discord-Notifications.git
synced 2025-12-19 14:59:18 +00:00
Added Global Variables
• Changed 'companyName' into a global variable. • Changed 'whmcsAdminURL' into a global variable. • Changed 'discordWebHookURL' into a global variable. • Removed "Global Variables do not work" message since they do and has been successfully tested.
This commit is contained in:
committed by
GitHub
parent
65c480ce9a
commit
88b7d39c5f
@@ -1,318 +1,294 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
//////// Configuration Information ////////
|
//////// Configuration Information ////////
|
||||||
// Unfortunately due to WHMCS hooks not allowing external inputs, values are required to defined within each hook. If this changes it will be updated!
|
$GLOBALS['discordWebHookURL'] = "";
|
||||||
// I recommend using NotePad++ to mass replace all values at once.
|
// Your Discord WebHook URL. Please be aware that the channel which you select to create the web hook is the channel which will be used for sending messages.
|
||||||
|
|
||||||
// $discordWebHookURL = "";
|
$GLOBALS['whmcsAdminURL'] = "";
|
||||||
// Found on line(s): 300
|
// Your WHMCS Admin URL. Please include the end / on your URL. An example of an accepted link would be: https://account.whmcs.com/admin/
|
||||||
// Your Discord WebHook URL. Please be aware that the channel which you select to create the web hook is the channel which will be used for sending messages.
|
|
||||||
|
|
||||||
// $whmcsAdminURL = "";
|
$GLOBALS['companyName'] = "";
|
||||||
// Found on line(s): 24, 45, 66, 87, 125, 146, 199, 220, 259
|
// Your Company Name. This will be the name of the user which sends the messages.
|
||||||
// Your WHMCS Admin URL. Please include the end / on your URL. An example of an accepted link would be: https://account.whmcs.com/admin/
|
|
||||||
|
|
||||||
// $companyName = "";
|
// $discordGroupID = "";
|
||||||
// Found on line(s): 25, 46, 67, 88, 126, 147, 200, 221, 260
|
// Found on line(s): 21, 38, 57, 76, 112, 131, 182, 201, 238
|
||||||
// Your Company Name. This will be the name of the user which sends the messages.
|
// Discord Group ID Config Option. If you wished for each message which is sent to ping a specific group, please place the ID here. An example of a group ID is: @&343029528563548162
|
||||||
|
|
||||||
// $discordGroupID = "";
|
|
||||||
// Found on line(s): 26, 47, 68, 89, 127, 148, 201, 222, 261
|
|
||||||
// Discord Group ID Config Option. If you wished for each message which is sent to ping a specific group, please place the ID here. An example of a group ID is: @&343029528563548162
|
|
||||||
|
|
||||||
add_hook('InvoicePaid', 1, function($vars) {
|
add_hook('InvoicePaid', 1, function($vars) {
|
||||||
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
|
$discordGroupID = ""; // Discord Group ID Config Option.
|
||||||
$companyName = ""; // Your Company Name.
|
$dataPacket = array(
|
||||||
$discordGroupID = ""; // Discord Group ID Config Option.
|
'content' => $discordGroupID,
|
||||||
$dataPacket = array(
|
'username' => $GLOBALS['companyName'],
|
||||||
'content' => $discordGroupID,
|
'embeds' => array(
|
||||||
'username' => $companyName,
|
array(
|
||||||
'embeds' => array(
|
'url' => $GLOBALS['whmcsAdminURL'] . 'invoices.php?action=edit&id=' . $vars['invoiceid'],
|
||||||
array(
|
'timestamp' => date(DateTime::ISO8601),
|
||||||
'url' => $whmcsAdminURL . 'invoices.php?action=edit&id=' . $vars['invoiceid'],
|
'description' => '',
|
||||||
'timestamp' => date(DateTime::ISO8601),
|
'color' => '5653183',
|
||||||
'description' => '',
|
'author' => array(
|
||||||
'color' => '5653183',
|
'name' => 'Invoice Payment Received'
|
||||||
'author' => array(
|
)
|
||||||
'name' => 'Invoice Payment Received'
|
)
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
)
|
processNotification($dataPacket);
|
||||||
);
|
});
|
||||||
processNotification($dataPacket);
|
add_hook('InvoiceRefunded', 1, function($vars) {
|
||||||
});
|
$discordGroupID = ""; // Discord Group ID Config Option.
|
||||||
add_hook('InvoiceRefunded', 1, function($vars) {
|
$dataPacket = array(
|
||||||
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
|
'content' => $discordGroupID,
|
||||||
$companyName = ""; // Your Company Name.
|
'username' => $GLOBALS['companyName'],
|
||||||
$discordGroupID = ""; // Discord Group ID Config Option.
|
'embeds' => array(
|
||||||
$dataPacket = array(
|
array(
|
||||||
'content' => $discordGroupID,
|
'url' => $GLOBALS['whmcsAdminURL'] . 'invoices.php?action=edit&id=' . $vars['invoiceid'],
|
||||||
'username' => $companyName,
|
'timestamp' => date(DateTime::ISO8601),
|
||||||
'embeds' => array(
|
'description' => '',
|
||||||
array(
|
'color' => '5653183',
|
||||||
'url' => $whmcsAdminURL . 'invoices.php?action=edit&id=' . $vars['invoiceid'],
|
'author' => array(
|
||||||
'timestamp' => date(DateTime::ISO8601),
|
'name' => 'Invoice Refunded'
|
||||||
'description' => '',
|
)
|
||||||
'color' => '5653183',
|
)
|
||||||
'author' => array(
|
)
|
||||||
'name' => 'Invoice Refunded'
|
);
|
||||||
)
|
processNotification($dataPacket);
|
||||||
)
|
});
|
||||||
)
|
add_hook('AcceptOrder', 1, function($vars) {
|
||||||
);
|
$discordGroupID = ""; // Discord Group ID Config Option.
|
||||||
processNotification($dataPacket);
|
$dataPacket = array(
|
||||||
});
|
'content' => $discordGroupID,
|
||||||
add_hook('AcceptOrder', 1, function($vars) {
|
'username' => $GLOBALS['companyName'],
|
||||||
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
|
'embeds' => array(
|
||||||
$companyName = ""; // Your Company Name.
|
array(
|
||||||
$discordGroupID = ""; // Discord Group ID Config Option.
|
'url' => $GLOBALS['whmcsAdminURL'] . 'orders.php?action=view&id=' . $vars['orderid'],
|
||||||
$dataPacket = array(
|
'timestamp' => date(DateTime::ISO8601),
|
||||||
'content' => $discordGroupID,
|
'description' => '',
|
||||||
'username' => $companyName,
|
'color' => '5653183',
|
||||||
'embeds' => array(
|
'author' => array(
|
||||||
array(
|
'name' => 'New Accepted Order'
|
||||||
'url' => $whmcsAdminURL . 'orders.php?action=view&id=' . $vars['orderid'],
|
)
|
||||||
'timestamp' => date(DateTime::ISO8601),
|
)
|
||||||
'description' => '',
|
)
|
||||||
'color' => '5653183',
|
);
|
||||||
'author' => array(
|
processNotification($dataPacket);
|
||||||
'name' => 'New Accepted Order'
|
});
|
||||||
)
|
add_hook('CancellationRequest', 1, function($vars) {
|
||||||
)
|
$discordGroupID = ""; // Discord Group ID Config Option.
|
||||||
)
|
$dataPacket = array(
|
||||||
);
|
'content' => $discordGroupID,
|
||||||
processNotification($dataPacket);
|
'username' => $GLOBALS['companyName'],
|
||||||
});
|
'embeds' => array(
|
||||||
add_hook('CancellationRequest', 1, function($vars) {
|
array(
|
||||||
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
|
'url' => $GLOBALS['whmcsAdminURL'] . 'cancelrequests.php',
|
||||||
$companyName = ""; // Your Company Name.
|
'timestamp' => date(DateTime::ISO8601),
|
||||||
$discordGroupID = ""; // Discord Group ID Config Option.
|
'description' => $vars['reason'],
|
||||||
$dataPacket = array(
|
'color' => '5653183',
|
||||||
'content' => $discordGroupID,
|
'author' => array(
|
||||||
'username' => $companyName,
|
'name' => 'New Cancellation Request'
|
||||||
'embeds' => array(
|
),
|
||||||
array(
|
'fields' => array(
|
||||||
'url' => $whmcsAdminURL . 'cancelrequests.php',
|
array(
|
||||||
'timestamp' => date(DateTime::ISO8601),
|
'name' => 'Product ID',
|
||||||
'description' => $vars['reason'],
|
'value' => $vars['relid'],
|
||||||
'color' => '5653183',
|
'inline' => true
|
||||||
'author' => array(
|
),
|
||||||
'name' => 'New Cancellation Request'
|
array(
|
||||||
),
|
'name' => 'Cancellation Type',
|
||||||
'fields' => array(
|
'value' => $vars['type'],
|
||||||
array(
|
'inline' => true
|
||||||
'name' => 'Product ID',
|
),
|
||||||
'value' => $vars['relid'],
|
array(
|
||||||
'inline' => true
|
'name' => 'User ID',
|
||||||
),
|
'value' => $vars['userid'],
|
||||||
array(
|
'inline' => true
|
||||||
'name' => 'Cancellation Type',
|
)
|
||||||
'value' => $vars['type'],
|
)
|
||||||
'inline' => true
|
)
|
||||||
),
|
)
|
||||||
array(
|
);
|
||||||
'name' => 'User ID',
|
processNotification($dataPacket);
|
||||||
'value' => $vars['userid'],
|
});
|
||||||
'inline' => true
|
add_hook('FraudOrder', 1, function($vars) {
|
||||||
)
|
$discordGroupID = ""; // Discord Group ID Config Option.
|
||||||
)
|
$dataPacket = array(
|
||||||
)
|
'content' => $discordGroupID,
|
||||||
)
|
'username' => $GLOBALS['companyName'],
|
||||||
);
|
'embeds' => array(
|
||||||
processNotification($dataPacket);
|
array(
|
||||||
});
|
'url' => $GLOBALS['whmcsAdminURL'] . 'orders.php?action=view&id=' . $vars['orderid'],
|
||||||
add_hook('FraudOrder', 1, function($vars) {
|
'timestamp' => date(DateTime::ISO8601),
|
||||||
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
|
'description' => '',
|
||||||
$companyName = ""; // Your Company Name.
|
'color' => '5653183',
|
||||||
$discordGroupID = ""; // Discord Group ID Config Option.
|
'author' => array(
|
||||||
$dataPacket = array(
|
'name' => 'Order Marked As Fraud'
|
||||||
'content' => $discordGroupID,
|
)
|
||||||
'username' => $companyName,
|
)
|
||||||
'embeds' => array(
|
)
|
||||||
array(
|
);
|
||||||
'url' => $whmcsAdminURL . 'orders.php?action=view&id=' . $vars['orderid'],
|
processNotification($dataPacket);
|
||||||
'timestamp' => date(DateTime::ISO8601),
|
});
|
||||||
'description' => '',
|
add_hook('NetworkIssueAdd', 1, function($vars) {
|
||||||
'color' => '5653183',
|
$discordGroupID = ""; // Discord Group ID Config Option.
|
||||||
'author' => array(
|
$dataPacket = array(
|
||||||
'name' => 'Order Marked As Fraud'
|
'content' => $discordGroupID,
|
||||||
)
|
'username' => $GLOBALS['companyName'],
|
||||||
)
|
'embeds' => array(
|
||||||
)
|
array(
|
||||||
);
|
'url' => $GLOBALS['whmcsAdminURL'] . 'networkissues.php?action=manage&id=' . $vars['announcementid'],
|
||||||
processNotification($dataPacket);
|
'timestamp' => date(DateTime::ISO8601),
|
||||||
});
|
'description' => $vars['reason'],
|
||||||
add_hook('NetworkIssueAdd', 1, function($vars) {
|
'color' => '5653183',
|
||||||
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
|
'author' => array(
|
||||||
$companyName = ""; // Your Company Name.
|
'name' => 'New Network Issue'
|
||||||
$discordGroupID = ""; // Discord Group ID Config Option.
|
),
|
||||||
$dataPacket = array(
|
'fields' => array(
|
||||||
'content' => $discordGroupID,
|
array(
|
||||||
'username' => $companyName,
|
'name' => 'Start Date',
|
||||||
'embeds' => array(
|
'value' => $vars['startdate'],
|
||||||
array(
|
'inline' => true
|
||||||
'url' => $whmcsAdminURL . 'networkissues.php?action=manage&id=' . $vars['announcementid'],
|
),
|
||||||
'timestamp' => date(DateTime::ISO8601),
|
array(
|
||||||
'description' => $vars['reason'],
|
'name' => 'End Date',
|
||||||
'color' => '5653183',
|
'value' => $vars['enddate'],
|
||||||
'author' => array(
|
'inline' => true
|
||||||
'name' => 'New Network Issue'
|
),
|
||||||
),
|
array(
|
||||||
'fields' => array(
|
'name' => 'Title',
|
||||||
array(
|
'value' => $vars['title'],
|
||||||
'name' => 'Start Date',
|
'inline' => true
|
||||||
'value' => $vars['startdate'],
|
),
|
||||||
'inline' => true
|
array(
|
||||||
),
|
'name' => 'Description',
|
||||||
array(
|
'value' => $vars['description'],
|
||||||
'name' => 'End Date',
|
'inline' => true
|
||||||
'value' => $vars['enddate'],
|
),
|
||||||
'inline' => true
|
array(
|
||||||
),
|
'name' => 'Affecting',
|
||||||
array(
|
'value' => $vars['affecting'],
|
||||||
'name' => 'Title',
|
'inline' => true
|
||||||
'value' => $vars['title'],
|
),
|
||||||
'inline' => true
|
array(
|
||||||
),
|
'name' => 'Priority',
|
||||||
array(
|
'value' => $vars['priority'],
|
||||||
'name' => 'Description',
|
'inline' => true
|
||||||
'value' => $vars['description'],
|
)
|
||||||
'inline' => true
|
)
|
||||||
),
|
)
|
||||||
array(
|
)
|
||||||
'name' => 'Affecting',
|
);
|
||||||
'value' => $vars['affecting'],
|
processNotification($dataPacket);
|
||||||
'inline' => true
|
});
|
||||||
),
|
add_hook('PendingOrder', 1, function($vars) {
|
||||||
array(
|
$discordGroupID = ""; // Discord Group ID Config Option.
|
||||||
'name' => 'Priority',
|
$dataPacket = array(
|
||||||
'value' => $vars['priority'],
|
'content' => $discordGroupID,
|
||||||
'inline' => true
|
'username' => $GLOBALS['companyName'],
|
||||||
)
|
'embeds' => array(
|
||||||
)
|
array(
|
||||||
)
|
'url' => $GLOBALS['whmcsAdminURL'] . 'orders.php?action=view&id=' . $vars['orderid'],
|
||||||
)
|
'timestamp' => date(DateTime::ISO8601),
|
||||||
);
|
'description' => '',
|
||||||
processNotification($dataPacket);
|
'color' => '5653183',
|
||||||
});
|
'author' => array(
|
||||||
add_hook('PendingOrder', 1, function($vars) {
|
'name' => 'New Pending Order'
|
||||||
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
|
)
|
||||||
$companyName = ""; // Your Company Name.
|
)
|
||||||
$discordGroupID = ""; // Discord Group ID Config Option.
|
)
|
||||||
$dataPacket = array(
|
);
|
||||||
'content' => $discordGroupID,
|
processNotification($dataPacket);
|
||||||
'username' => $companyName,
|
});
|
||||||
'embeds' => array(
|
add_hook('TicketOpen', 1, function($vars) {
|
||||||
array(
|
$discordGroupID = ""; // Discord Group ID Config Option.
|
||||||
'url' => $whmcsAdminURL . 'orders.php?action=view&id=' . $vars['orderid'],
|
$dataPacket = array(
|
||||||
'timestamp' => date(DateTime::ISO8601),
|
'content' => $discordGroupID,
|
||||||
'description' => '',
|
'username' => $GLOBALS['companyName'],
|
||||||
'color' => '5653183',
|
'embeds' => array(
|
||||||
'author' => array(
|
array(
|
||||||
'name' => 'New Pending Order'
|
'title' => $vars['subject'],
|
||||||
)
|
'url' => $GLOBALS['whmcsAdminURL'] . 'supporttickets.php?action=view&id=' . $vars['ticketid'],
|
||||||
)
|
'timestamp' => date(DateTime::ISO8601),
|
||||||
)
|
'description' => '',
|
||||||
);
|
'color' => '5653183',
|
||||||
processNotification($dataPacket);
|
'author' => array(
|
||||||
});
|
'name' => 'New Support Ticket'
|
||||||
add_hook('TicketOpen', 1, function($vars) {
|
),
|
||||||
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
|
'fields' => array(
|
||||||
$companyName = ""; // Your Company Name.
|
array(
|
||||||
$discordGroupID = ""; // Discord Group ID Config Option.
|
'name' => 'Priority',
|
||||||
$dataPacket = array(
|
'value' => $vars['priority'],
|
||||||
'content' => $discordGroupID,
|
'inline' => true
|
||||||
'username' => $companyName,
|
),
|
||||||
'embeds' => array(
|
array(
|
||||||
array(
|
'name' => 'Department',
|
||||||
'title' => $vars['subject'],
|
'value' => $vars['deptname'],
|
||||||
'url' => $whmcsAdminURL . 'supporttickets.php?action=view&id=' . $vars['ticketid'],
|
'inline' => true
|
||||||
'timestamp' => date(DateTime::ISO8601),
|
),
|
||||||
'description' => '',
|
array(
|
||||||
'color' => '5653183',
|
'name' => 'Ticket ID',
|
||||||
'author' => array(
|
'value' => $vars['ticketid'],
|
||||||
'name' => 'New Support Ticket'
|
'inline' => true
|
||||||
),
|
)
|
||||||
'fields' => array(
|
)
|
||||||
array(
|
)
|
||||||
'name' => 'Priority',
|
)
|
||||||
'value' => $vars['priority'],
|
);
|
||||||
'inline' => true
|
processNotification($dataPacket);
|
||||||
),
|
});
|
||||||
array(
|
add_hook('TicketUserReply', 1, function($vars) {
|
||||||
'name' => 'Department',
|
$discordGroupID = ""; // Discord Group ID Config Option.
|
||||||
'value' => $vars['deptname'],
|
$dataPacket = array(
|
||||||
'inline' => true
|
'content' => $discordGroupID,
|
||||||
),
|
'username' => $GLOBALS['companyName'],
|
||||||
array(
|
'embeds' => array(
|
||||||
'name' => 'Ticket ID',
|
array(
|
||||||
'value' => $vars['ticketid'],
|
'title' => $vars['subject'],
|
||||||
'inline' => true
|
'url' => $GLOBALS['whmcsAdminURL'] . 'supporttickets.php?action=view&id=' . $vars['ticketid'],
|
||||||
)
|
'timestamp' => date(DateTime::ISO8601),
|
||||||
)
|
'description' => '',
|
||||||
)
|
'color' => '5653183',
|
||||||
)
|
'author' => array(
|
||||||
);
|
'name' => 'New Ticket Reply'
|
||||||
processNotification($dataPacket);
|
),
|
||||||
});
|
'fields' => array(
|
||||||
add_hook('TicketUserReply', 1, function($vars) {
|
array(
|
||||||
$whmcsAdminURL = ""; // Your WHMCS Admin URL.
|
'name' => 'Priority',
|
||||||
$companyName = ""; // Your Company Name.
|
'value' => $vars['priority'],
|
||||||
$discordGroupID = ""; // Discord Group ID Config Option.
|
'inline' => true
|
||||||
$dataPacket = array(
|
),
|
||||||
'content' => $discordGroupID,
|
array(
|
||||||
'username' => $companyName,
|
'name' => 'Department',
|
||||||
'embeds' => array(
|
'value' => $vars['deptname'],
|
||||||
array(
|
'inline' => true
|
||||||
'title' => $vars['subject'],
|
),
|
||||||
'url' => $whmcsAdminURL . 'supporttickets.php?action=view&id=' . $vars['ticketid'],
|
array(
|
||||||
'timestamp' => date(DateTime::ISO8601),
|
'name' => 'Ticket ID',
|
||||||
'description' => '',
|
'value' => $vars['ticketid'],
|
||||||
'color' => '5653183',
|
'inline' => true
|
||||||
'author' => array(
|
)
|
||||||
'name' => 'New Ticket Reply'
|
)
|
||||||
),
|
)
|
||||||
'fields' => array(
|
)
|
||||||
array(
|
);
|
||||||
'name' => 'Priority',
|
processNotification($dataPacket);
|
||||||
'value' => $vars['priority'],
|
});
|
||||||
'inline' => true
|
function processNotification($dataPacket, $discordWebHookURL) {
|
||||||
),
|
$dataString = json_encode($dataPacket);
|
||||||
array(
|
$curl = curl_init();
|
||||||
'name' => 'Department',
|
curl_setopt($curl, CURLOPT_URL, $GLOBALS['discordWebHookURL']);
|
||||||
'value' => $vars['deptname'],
|
curl_setopt($curl, CURLOPT_POST, 1);
|
||||||
'inline' => true
|
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
||||||
),
|
'Content-Type: application/json'
|
||||||
array(
|
));
|
||||||
'name' => 'Ticket ID',
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
'value' => $vars['ticketid'],
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||||
'inline' => true
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
)
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString);
|
||||||
)
|
$output = curl_exec($curl);
|
||||||
)
|
$output = json_decode($output, true);
|
||||||
)
|
if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 204) {
|
||||||
);
|
echo "Failed " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "<br><br>";
|
||||||
processNotification($dataPacket);
|
print_r($output);
|
||||||
});
|
}
|
||||||
function processNotification($dataPacket, $discordWebHookURL) {
|
curl_close($curl);
|
||||||
$dataString = json_encode($dataPacket);
|
}
|
||||||
$curl = curl_init();
|
|
||||||
$discordWebHookURL = ""; // Your Discord WebHook URL
|
|
||||||
curl_setopt($curl, CURLOPT_URL, $discordWebHookURL);
|
|
||||||
curl_setopt($curl, CURLOPT_POST, 1);
|
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
|
||||||
'Content-Type: application/json'
|
|
||||||
));
|
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString);
|
|
||||||
$output = curl_exec($curl);
|
|
||||||
$output = json_decode($output, true);
|
|
||||||
if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 204) {
|
|
||||||
echo "Failed " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "<br><br>";
|
|
||||||
print_r($output);
|
|
||||||
}
|
|
||||||
curl_close($curl);
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user