Fix lag while sending a message to discord

This commit is contained in:
kotyara 2022-05-09 13:41:35 +00:00 • committed by GitHub
parent 7b4d69d550
commit 42e5e09ae4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -716,16 +716,14 @@ class PocketMinecraftServer{
if($this->extraprops->get("discord-msg") == true and $this->extraprops->get("discord-webhook-url") !== "none"){ if($this->extraprops->get("discord-msg") == true and $this->extraprops->get("discord-webhook-url") !== "none"){
$url = $this->extraprops->get("discord-webhook-url"); $url = $this->extraprops->get("discord-webhook-url");
$name = $this->extraprops->get("discord-bot-name"); $name = $this->extraprops->get("discord-bot-name");
$headers = [ 'Content-Type: application/json; charset=utf-8' ]; $this->asyncOperation(ASYNC_CURL_POST, array(
$POST = [ 'username' => $name, 'content' => str_replace("@", "", $msg)]; "url" => $url,
$ch = curl_init(); "data" => array(
curl_setopt($ch, CURLOPT_URL, $url); "username" => $name,
curl_setopt($ch, CURLOPT_POST, true); "content" => str_replace("@", "", $msg)
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); ),
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); ), NULL);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($POST));
$response = curl_exec($ch);
} }
} }
} }