mirror of
https://gitlab.com/ArkHost/WHMCS-Discord-Notifications.git
synced 2026-09-19 17:27:28 +02:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace WHMCS\Module\Notification\Discord;
|
||||
|
||||
class Message
|
||||
{
|
||||
public $content = "";
|
||||
public $username = "";
|
||||
public $avatarUrl = "";
|
||||
public $embeds = array();
|
||||
|
||||
public function content($content)
|
||||
{
|
||||
$this->content = trim($content);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function username($username)
|
||||
{
|
||||
$this->username = trim($username);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function avatarUrl($avatarUrl)
|
||||
{
|
||||
$this->avatarUrl = trim($avatarUrl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function embed($embed)
|
||||
{
|
||||
$this->embeds[] = $embed;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
$message = array();
|
||||
|
||||
if (!empty($this->content)) {
|
||||
$message["content"] = $this->content;
|
||||
}
|
||||
if (!empty($this->avatarUrl)) {
|
||||
$message["avatar_url"] = $this->avatarUrl;
|
||||
}
|
||||
if (!empty($this->username)) {
|
||||
$message["username"] = $this->username;
|
||||
}
|
||||
if (!empty($this->embeds)) {
|
||||
$message["embeds"] = array_map(function($embed) {
|
||||
return $embed instanceof Embed ? $embed->toArray() : $embed;
|
||||
}, $this->embeds);
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user