matmper / php-discord-webhook
Sample and cleand package to send messages to your discord channel
Installs: 2 284
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.1|^8.0
- ext-curl: *
Requires (Dev)
- fakerphp/faker: ^1.23
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10
- squizlabs/php_codesniffer: ^3.7
README
Sample and cleand package to send messages to your discord channel. Easily!
Dependences
- PHP ^7.1 | ^8.0
- Webhook Link (Discord Doc)
Install & Usage
Install this repository in with composer:
$ composer require matmper/php-discord-webhook
Configure application envs values:
Applications without env files support, we recommend using version 1.x
# REQUIRED (https://discord.com/api/webhooks/{ID}/{TOKEN}) DISCORD_WEBHOOK_ID= DISCORD_WEBHOOK_TOKEN= # OPTIONAL (DEFAULT VALUE) APP_NAME="no application" APP_ENV="undefined" DISCORD_WEBHOOK_BOT_NAME="Webhook BOT"
Send a message:
$sendWebhook = new \Matmper\DiscordWebhook(); $sendWebhook->message('message')->send();
Set custom Discord ID and Token and send a message:
$sendWebhook = new \Matmper\DiscordWebhook('DISCORD_ID', 'DISCORD_TOKEN'); $sendWebhook->message('message')->send();
Send a typed message:
use Matmper\Enums\MessageType; $sendWebhook->type(MessageType::SUCCESS)->message('message')->send(); $sendWebhook->type(MessageType::WARNING)->message('message')->send(); $sendWebhook->type(MessageType::DANGER)->message('message')->send();
Value | Enum | Color |
---|---|---|
success | MessageType::SUCCESS | #2ecc71 |
warning | MessageType::WARNING | #e74c3c |
danger | MessageType::DANGER | #f1c40f |
default | MessageType::DEFAULT | #3498db |
Contribution & Development
This is an open source code, free for distribution and contribution. All contributions will be accepted only with Pull Request and that pass the test and code standardization.
Run composer install in yout development and create env file
$ composer install --dev --prefer-dist $ cp ./tests/.env.example .env
Edit ./tests/.env
and configure envs values. Execute $ composer check
.