PHP code example of enlumop / discord-webhook-client
1. Go to this page and download the library: Download enlumop/discord-webhook-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
enlumop / discord-webhook-client example snippets
use Enlumop\DiscordWebhooks\Embed;
use Enlumop\DiscordWebhooks\Payload;
use Enlumop\DiscordWebhooks\WebhookClient;
// Create embed
$embed = new Embed();
$embed->setDescription('This is an embed'); // with description
$url = 'DISCORD_WEBHOOK_URL'; // Put your discord webhook url
// Create Payload
$payload = new Payload();
$payload->setUsername('Example Webhook Bot') // Change discord bot webhook username
->setMessage('This is a message') // Some text before embed
->addEmbed($embed) // Add embed
;
// New discord webhook client
$webhook = new WebhookClient();
// Send message
$webhook->send($url, $payload);
use Enlumop\DiscordWebhooks\Payload;
use Enlumop\DiscordWebhooks\WebhookClient;
$url = 'DISCORD_WEBHOOK_URL'; // Put your discord webhook url
// Create Payload
$payload = new Payload();
$payload->setMessage('This is a message'); // Some text. If You need use the Message Builder
// New discord webhook client
$webhook = new WebhookClient();
// Send message
$webhook->send($url, $payload);
use Enlumop\DiscordWebhooks\Builder\TextFormattingCombine;
use Enlumop\DiscordWebhooks\Builder\TextMessageBuilder;
use Enlumop\DiscordWebhooks\Payload;
use Enlumop\DiscordWebhooks\WebhookClient;
$url = 'DISCORD_WEBHOOK_URL'; // Put your discord webhook url
// Builder with on auto-newline mode (to disable auto-newline use new TextMessageBuilder(false))
$messageBuilder = new TextMessageBuilder();
$message = $messageBuilder->addText('<@ROLE_ID>') // ping some role
->addText('How are you?') // some text without format
->addBold("It's time for new webhook tool!") // **Text with bold**
/**
* Text with multiline codeblock:
*
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.