-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSupportAppController.php
More file actions
40 lines (34 loc) · 1.34 KB
/
SupportAppController.php
File metadata and controls
40 lines (34 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
class SupportAppController extends AppController
{
protected function sendDiscordMessage($msg = "", $embedData = [])
{
$this->loadModel("Support.SettingsSupport");
$discordWebhook = $this->SettingsSupport->find("first");
if (empty($discordWebhook) || empty($discordWebhook["SettingsSupport"]["discord_webhook"]))
return false;
$discordWebhook = explode("/", $discordWebhook["SettingsSupport"]["discord_webhook"]);
$webhookData = [
"id" => $discordWebhook[5],
"token" => $discordWebhook[6]
];
$handle = curl_init("https://discord.com/api/webhooks/" . $webhookData["id"] . "/" . $webhookData["token"]);
$data = json_encode([
"content" => $msg,
"embeds" => $embedData
]);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_HEADER, true);
curl_setopt($handle, CURLOPT_HTTPHEADER,
array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data)
)
);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$res = curl_exec($handle);
return true;
}
}