Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ialdrich23xx/libasynwebhook

Lib Async of Pocketmine for Discord Webhooks
https://github.com/ialdrich23xx/libasynwebhook

Last synced: 2 months ago
JSON representation

Lib Async of Pocketmine for Discord Webhooks

Awesome Lists containing this project

README

        

---
icon

# libasynWebHook
[![PHPStan](https://github.com/ialdrich23xx/libasynWeebhook/actions/workflows/phpstan.yml/badge.svg)](https://github.com/ialdrich23xx/libasynWeebhook/actions/workflows/phpstan.yml)
[![License](https://img.shields.io/github/license/iAldrich23xX/libasynWeebhook)](https://github.com/iAldrich23xX/libasynWebhook/blob/master/LICENSE)

PMMP4 | PMMP5 | Nukkit | WaterdogPE

---

## Usage

---

Add Add this line in the onLoad() function in main class, Plugin Example.

```php
setAvatar("url_avatar")
->setContent("text content")
->setUsername("username")
->setTextToSpeech(false) //enable tts
)->send(); //function for send message to channel
```

#### OR

```php
$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
```

### Build embed Message:

---

```php
//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();
```

---
## Installation

---

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

### COMPOSER

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"
},
```

### VIRION

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:

```yml
--- # 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
...
```

## Credits

* use post in repository libasynCurl
* use color discord code_colors_discordjs.md