nozell/webhookapi
最新稳定版本:v1.0.0
Composer 安装命令:
composer require nozell/webhookapi
包简介
A PocketMine-MP Virion to easily send messages via Discord Webhooks
README 文档
README
#DiscordWebhookAPI
🎉 Join the BlockForDevs Discord Community! 🎉
DiscordWebhookAPI
A PocketMine-MP Virion to easily send messages via Discord Webhooks
Una Virion para PocketMine-MP para enviar mensajes fácilmente mediante Discord Webhooks
🎉 Installation / Instalación
Installation is easy. You may get a compiled .phar here or integrate the virion itself into your plugin.
La instalación es fácil. Puedes obtener un .phar compilado aquí o integrar directamente el virion en tu plugin.
This virion is purely object-oriented. To use it, you'll need to import the Webhook, Message, and optionally, the Embed object (if needed).
Esta API es completamente orientada a objetos. Para usarla, deberás importar los objetos Webhook, Message, y opcionalmente, Embed si es necesario.
🛠 Basic Usage / Uso básico
Import the classes / Importar las clases
To use this API in your code, you'll need to import the following classes:
Para usar esta API en tu código, necesitarás importar las siguientes clases:
<?php use CortexPE\DiscordWebhookAPI\Message; use CortexPE\DiscordWebhookAPI\Webhook; use CortexPE\DiscordWebhookAPI\Embed; // optional / opcional
Construct a Webhook object / Crear un objeto Webhook
You'll need the Webhook URL. For more information on how to create Discord webhooks, click here.
Necesitarás la URL del Webhook. Para más información sobre cómo crear webhooks en Discord, haz clic aquí.
$webHook = new Webhook("YOUR WEBHOOK URL");
Construct a Message object / Crear un objeto Message
You must create a new Message object for each message you want to send.
Deberás crear un nuevo objeto Message para cada mensaje que desees enviar.
$msg = new Message(); $msg->setUsername("USERNAME"); // optional / opcional $msg->setAvatarURL("https://cortexpe.xyz/utils/kitsu.png"); // optional / opcional $msg->setContent("INSERT TEXT HERE"); // optional. Max length 2000 characters / opcional. Máximo 2000 caracteres
Send the message / Enviar el mensaje
Now you can send the message using the send() method. This will schedule an AsyncTask to avoid blocking the main thread.
Ahora puedes enviar el mensaje usando el método send(). Esto programará una AsyncTask para evitar bloquear el hilo principal.
$webHook->send($msg);
📦 Embeds
Before sending a message, you may want to add an embed. You can construct an Embed object and use Message->addEmbed() to include it.
Antes de enviar un mensaje, quizá quieras agregar un embed. Puedes construir un objeto Embed y usar Message->addEmbed() para incluirlo.
$embed = new Embed(); $embed->setTitle("Embed Title Here"); $embed->setDescription("A very awesome description / Una descripción muy genial");
You can also add a footer:
También puedes añadir un pie de página:
$embed->setFooter("Footer text / Texto del pie de página");
Finally, add the embed to the message:
Finalmente, agrega el embed al mensaje:
$msg->addEmbed($embed);
Example Code / Código de ejemplo:
$webHook = new Webhook("YOUR WEBHOOK URL"); $msg = new Message(); $msg->setUsername("USERNAME"); $msg->setAvatarURL("https://cortexpe.xyz/utils/kitsu.png"); $msg->setContent("INSERT TEXT HERE"); $embed = new Embed(); $embed->setTitle("EMBED 1"); $embed->setColor(0xFF0000); $msg->addEmbed($embed); $embed = new Embed(); $embed->setTitle("EMBED 2"); $embed->setColor(0x00FF00); $embed->setAuthor("AUTHOR", "https://CortexPE.xyz", "https://cortexpe.xyz/utils/kitsu.png"); $embed->setDescription("Lorem ipsum dolor sit amet."); $msg->addEmbed($embed); $webHook->send($msg);
This API was made with ❤️ by CortexPE updated by Nozell. Enjoy!~ :3
Esta API fue hecha con ❤️ por CortexPE actualizado por Nozell. ¡Disfrútala!~ :3
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2024-10-11