mistynetwork/discordwebhookapi 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mistynetwork/discordwebhookapi

Composer 安装命令:

composer require mistynetwork/discordwebhookapi

包简介

Simple discord webhook virion for PocketMine-MP

README 文档

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.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-05-28