承接 almighty-shogun/discord-webhook 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

almighty-shogun/discord-webhook

最新稳定版本:1.0.0

Composer 安装命令:

composer require almighty-shogun/discord-webhook

包简介

Personal implementation of Discord webhooks for PHP

README 文档

README

Shogun app-icon

DiscordWebhook

Personal implementation of Discord webhooks for PHP.

📃 Prerequisites

  • PHP: >= v8.3
  • Extension ext-curl enabled in the php.ini file.

💻 Installation

Step 1

Install the library via composer:

composer require almighty-shogun/discord-webhook

Step 2

Use the library in your project.

Using the classes

<?php

use DiscordWebhook\DiscordWebhook;
use DiscordWebhook\Error\DiscordWebhookException;
use DiscordWebhook\Messages\{TextMessage, DiscordEmbed};

$discordWebhook = new DiscordWebhook("https://discord.com/api/webhooks/xxx/xxxx");

// Text message
$message = new TextMessage();
$embed = new DiscordEmbed();

$embed->setTitle("Test Embed")
    ->setDescription("This is a test embed.")
    ->setColor("#228b22") // Hex color code without the # symbol.
    ->setURL("https://github.com/Almighty-Shogun")
    ->setFooter("Test Footer", "https://avatars.githubusercontent.com/u/96011415?v=4")
    ->setTimestamp()
    ->setThumbnail("https://avatars.githubusercontent.com/u/96011415?v=4")
    ->setImage("https://avatars.githubusercontent.com/u/96011415?v=4")
    ->setAuthor("Almighty Shogun", "https://avatars.githubusercontent.com/u/96011415?v=4")
    ->addField("Field 1", "This is a test field.")
    ->addField("Field 2", "This is another test field.")
    ->addField("Field 3", "This is a third test field.");

$textMessage->setUsername("Almighty Shogun")
    ->setAvatar("https://avatars.githubusercontent.com/u/96011415?v=4")
    ->setContent("This is a test message.");

try {
    $discordWebhook->send($textMessage);
} catch (DiscordWebhookException $e) {
    echo $e->getMessage();
}

Using the helper functions

<?php

$discordWebhook = discordWebhook("https://discord.com/api/webhooks/xxx/xxxx");

$embed = discordEmbed()->setTitle("Test Embed")
    ->setDescription("This is a test embed.")
    ->setColor("228b22") // Hex color code without the # symbol.
    ->setURL("https://github.com/Almighty-Shogun")
    ->setFooter("Test Footer", "https://avatars.githubusercontent.com/u/96011415?v=4")
    ->setTimestamp()
    ->setThumbnail("https://avatars.githubusercontent.com/u/96011415?v=4")
    ->setImage("https://avatars.githubusercontent.com/u/96011415?v=4")
    ->setAuthor("Almighty Shogun", "https://avatars.githubusercontent.com/u/96011415?v=4")
    ->addField("Field 1", "This is a test field.")
    ->addField("Field 2", "This is another test field.")
    ->addField("Field 3", "This is a third test field.");

$textMessage = discordMessage()
    ->setUsername("Almighty Shogun")
    ->setAvatar("https://avatars.githubusercontent.com/u/96011415?v=4")
    ->setContent("This is a test message.")
    ->addEmbed($embed);

try {
    $discordWebhook->send($textMessage);
} catch (DiscordWebhookException $e) {
    echo $e->getMessage();
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固