matmper/php-discord-webhook

Sample and cleand package to send messages to your discord channel

2.0.2 2024-07-08 18:25 UTC

This package is auto-updated.

Last update: 2025-05-08 20:10:26 UTC


README

Sample and cleand package to send messages to your discord channel. Easily!

image

Dependences

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.