-
Notifications
You must be signed in to change notification settings - Fork 1
WebHookManager Guides
Wenox edited this page Oct 19, 2025
·
1 revision
The WebHookManager class handles sending Discord webhooks asynchronously within the SkyblockCore plugin. It provides a static method to send rich embed messages to Discord channels via webhooks, supporting titles, descriptions, colors, thumbnails, footers, fields, and custom avatars.
- Send Discord webhook messages asynchronously using PocketMine's async pool.
- Support for rich embeds with customizable elements.
- Automatic validation of webhook URLs (must be HTTPS).
- Error handling for invalid payloads and network issues.
- Uses a dedicated async task (
DiscordWebhookSendTask) for non-blocking execution.
To use WebHookManager from another plugin:
-
Add dependency in your
plugin.yml:depend: [SkyblockCore] -
Import the class:
use Biswajit\Core\Managers\WebHookManager;
-
Call the static
sendWebhookmethod with required parameters.
public static function sendWebhook(
string $url,
string $title,
string $description,
string $username,
string $color = '00ff00',
?string $thumbnail = null,
?string $footer = null,
?array $fields = null,
?string $avatar = null
): void-
$url(string): The Discord webhook URL. Must start with "https://". -
$title(string): The title of the embed. -
$description(string): The description text of the embed. -
$username(string): The username to display for the webhook. -
$color(string, optional): Hex color code for the embed (default: '00ff00' for green). -
$thumbnail(string, optional): URL of the thumbnail image. -
$footer(string, optional): Footer text for the embed. -
$fields(array, optional): Array of fields to add to the embed. Each field should be an associative array with 'name' and 'value' keys. -
$avatar(string, optional): URL of the avatar image (default: a predefined image).
// Basic webhook
WebHookManager::sendWebhook(
"https://discord.com/api/webhooks/1234567890/abcdef",
"Server Started",
"The server has started successfully.",
"SkyblockCore Bot"
);
// Advanced webhook with fields and thumbnail
WebHookManager::sendWebhook(
"https://discord.com/api/webhooks/1234567890/abcdef",
"Player Achievement",
"Player has reached a new milestone!",
"SkyblockCore Bot",
"ff0000",
"https://example.com/thumbnail.png",
"Powered by SkyblockCore",
[
["name" => "Player", "value" => "Steve", "inline" => true],
["name" => "Achievement", "value" => "First Island", "inline" => true]
],
"https://example.com/avatar.png"
);- Webhooks are sent asynchronously to avoid blocking the main thread.
- Invalid URLs or malformed payloads will log warnings but not throw exceptions.
- The default avatar is "https://i.imgur.com/jjwlRAI.png" if none is provided.
- Color is converted from hex string to decimal using
hexdec(). - The embed includes a timestamp and default footer if not specified.
- Uses cURL for HTTP requests with SSL verification disabled for compatibility.
- Relies on
DiscordWebhookSendTaskfor async execution. - Requires PocketMine's async pool for task submission.
- Package:
Biswajit\Core\Managers - Author: Biswajit
- Version: 0.1.4
- API Version: 5.30.0
For support with the SkyblockCore, you can join our Discord.
Copyright © 2025 PixelForge-Studios