mistynetwork/discordwebhookapi

Simple discord webhook virion for PocketMine-MP

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/mistynetwork/discordwebhookapi

dev-main 2025-04-30 12:59 UTC

This package is auto-updated.

Last update: 2025-09-28 21:05:27 UTC


README

DiscordWebhookAPI is an asynchronous PocketMine-MP library that allows sending messages and embeds to Discord using webhooks easily. It uses the libasynCurl library for handling asynchronous requests.

📌 API Registration

Before using the API, it's important to register the class to avoid conflicts with other plugins. If you do not check for registration, it will throw an exception.

use reacherurmom\discordwebhookapi\DiscordWebhookAPI;
use pocketmine\plugin\PluginBase;

class MyMain extends PluginBase {

    protected function onEnable() : void {
        if (!DiscordWebhookAPI::isRegistered()) {
            DiscordWebhookAPI::register($this);
        }
    }
}

📜 Using Messages and Embeds

📌 Creating a Message

use reacherurmom\discordwebhookapi\Message;

$message = Message::create()
    ->setUsername("ReacherUrMom Bot")
    ->setAvatar("https://example.com/avatar.png")
    ->setContent("Hi! This is my bot");

📌 Adding an Embed

use reacherurmom\discordwebhookapi\Embed;

$embed = Embed::create("Embed Title")
    ->setDescription("This is an embedded message.")
    ->setColor(hexdec('ffffff'));

$message->addEmbed($embed);

📌 Embed Methods

use reacherurmom\discordwebhookapi\component\Footer;
use reacherurmom\discordwebhookapi\component\Author;
use reacherurmom\discordwebhookapi\component\Field;

$embed->setFooter(Footer::create("Footer Text", "https://example.com/footer.png"))
      ->setAuthor(Author::create("Author Name", "https://example.com/author.png"))
      ->setTimestamp(new \DateTime('now')->setTimezone('UTC'))
      ->setThumbnail("https://example.com/thumbnail.png")
      ->addField(Field::create("Field 1", "Value of field 1", true))
      ->addField(Field::create("Field 2", "Value of field 2", false));

🚀 Sending the Message

use reacherurmom\discordwebhookapi\DiscordWebhookAPI;

$webhook = "your_webhook_url";
DiscordWebhookAPI::create($webhook, $message)->send();

🙌 Credits

📦 Adding the API to Your Project

You can install this API using Composer:

composer require mistynetwork/discordwebhookapi

📜 License

This project is free to use. For more details, check the LICENSE.