Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/ialdrich23xx/libasynwebhook
- Owner: iAldrich23xX
- License: apache-2.0
- Created: 2023-03-20T12:33:16.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-17T17:01:09.000Z (9 months ago)
- Last Synced: 2024-04-17T18:24:48.428Z (9 months ago)
- Language: PHP
- Size: 169 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
---
# 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