PMMP4 | PMMP5 | Nukkit | WaterdogPE
Add Add this line in the onLoad() function in main class, Plugin Example.
<?php
use src\ialdrich23xx\libasynwebhook\Loader;
class Main extends \pocketmine\plugin\PluginBase
{
public function onLoad(): void
{
Loader::make($this);
}
}
use ialdrich23xx\libasynwebhook\discord\WebHook;
use ialdrich23xx\libasynwebhook\discord\body\Base;
WebHook::make("your_url", Base::make()
//Optional methods
->setAvatar("url_avatar")
->setContent("text content")
->setUsername("username")
->setTextToSpeech(false) //enable tts
)->send(); //function for send message to channel
$body = Base::make()
->setAvatar("url_avatar")
->setContent("text content")
->setUsername("username")
->setTextToSpeech(false);
$webHook = WebHook::make("your_url");
$webHook->setBody($body);
$webHook->send(); //function for send message to channel
//Import the classes
use ialdrich23xx\libasynwebhook\discord\body\Base;
use ialdrich23xx\libasynwebhook\discord\body\embed\components\Author;
use ialdrich23xx\libasynwebhook\discord\body\embed\components\Field;
use ialdrich23xx\libasynwebhook\discord\body\embed\components\Footer;
use ialdrich23xx\libasynwebhook\discord\body\embed\components\Thumbnail;
use ialdrich23xx\libasynwebhook\discord\body\embed\components\Timestamp;
use ialdrich23xx\libasynwebhook\discord\body\embed\EmbedColors;
use ialdrich23xx\libasynwebhook\discord\body\embed\EmbedManager;
use ialdrich23xx\libasynwebhook\discord\WebHook;
WebHook::make("your_url", Base::make()
->addEmbed(EmbedManager::make("title", "description", EmbedColors::Green)
//Optional methods
->setFooter(Footer::make("text footer")
->setIcon("icon"))
->setAuthor(Author::make("name")
->setIcon("icon")
->setUrl("url"))
->setTimestamp(Timestamp::make(new DateTime("now"))
->setTimeZone("UTC"))
->addField(Field::make("name", "value")
->setInline(false))
->setThumbnail(Thumbnail::make("url"))
)
)->send();
Integrate the virion itself into your plugin, or you could also use it as a composer library by running the command below:
composer require ialdrich23xx/libasynwebhook dev-master
add in your "composer.json" and use composer install
"repositories": [
{
"type": "vcs",
"url": "[email protected]:iAldrich23xX/libasynWeebhook.git"
}
],
"require": {
"php": "^8.0",
"ialdrich23xx/libasynwebhook": "dev-master"
},
This library supports being included as a virion.
If you use Poggit to build your plugin, you can add it to your .poggit.yml like so:
--- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/YourGithubUserName/YourPluginName
build-by-default: true
branches:
- master
projects:
YourPluginName:
path: ""
libs:
- src: ialdrich23xx/libasynwebhook/Loader
version: 1.0.0
...
- use post in repository libasynCurl
- use color discord code_colors_discordjs.md