1
0
Fork 0
Manager/app/util/DiscordUtil.php

26 lines
701 B
PHP
Raw Normal View History

2021-01-20 23:29:57 +00:00
<?php
declare(strict_types=1);
namespace Mcp\Util;
class DiscordUtil
{
public static function sendMessageToWebhook($webhook, $title, $message): void
2021-01-20 23:29:57 +00:00
{
2023-08-27 03:31:32 +00:00
$rawMessage = file_get_contents("style/discordMessage.json");
$rawMessage = str_replace("%%message%%", $message, $rawMessage);
$rawMessage = str_replace("%%title%%", $title, $rawMessage);
2021-01-20 23:29:57 +00:00
$options = [
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'timeout' => 3,
2023-08-27 03:31:32 +00:00
'content' => $rawMessage
2021-01-20 23:29:57 +00:00
]
];
2023-08-27 03:31:32 +00:00
file_get_contents($webhook, false, stream_context_create($options));
2021-01-20 23:29:57 +00:00
}
}