定制 axl1232/php-discord-webhook 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

axl1232/php-discord-webhook

Composer 安装命令:

composer require axl1232/php-discord-webhook

包简介

A php library to use Discord webhooks.

README 文档

README

A PHP library that makes sending Discord webhooks easier.

Installation

composer require axl1232/php-discord-webhook

Usage

Sending a text message

$message = (new Axl1232\PhpDiscordWebhook\Message())
    ->setContent('Hello world')
    ->setUsername('Test hook')
    ->setAvatarUrl('https://example.com/avatar.png');

$hook = new Axl1232\PhpDiscordWebhook\Webhook('https://discordapp.com/api/webhooks/test/hook');
$hook->send($message);

Sending a text message with attachment

$message = (new Axl1232\PhpDiscordWebhook\Message())
    ->setContent('Hello world')
    ->setUsername('Test hook')
    ->setAvatarUrl('https://example.com/avatar.png')
    ->setFile('/path/to/file.png');

$hook = new Axl1232\PhpDiscordWebhook\Webhook('https://discordapp.com/api/webhooks/test/hook');
$hook->send($message);

Sending an embed message

$message = (new Axl1232\PhpDiscordWebhook\Message())
    ->setContent('Hello world')
    ->setUsername('Test hook')
    ->setAvatarUrl('https://example.com/avatar.png')
    ->addEmbed(
        (new Axl1232\PhpDiscordWebhook\Embed())
        ->setTitle('Test embed')
        ->setUrl('https://example.com/')
        ->setDescription('Some embed description')
        ->setImage(
            (new Axl1232\PhpDiscordWebhook\Embed\Image())
            ->setUrl('https://example.com/image.jpg')
        )
        ->setAuthor(
            (new Axl1232\PhpDiscordWebhook\Embed\Author())
            ->setName('Author')
            ->setUrl('https://example.com')
            ->setIconUrl('https://example.com/author_icon.png')
        )
        ->setColor(Axl1232\PhpDiscordWebhook\Tools\ColorHelper::FUSCHIA)
        ->setFooter(
            (new Axl1232\PhpDiscordWebhook\Embed\Footer())
            ->setText('Footer text')
            ->setIconUrl('https://example.com/footer_icon.png')
        )
        ->setTimestamp(new DateTime('-1 week'))
        ->setThumbnail(
            (new Axl1232\PhpDiscordWebhook\Embed\Thumbnail())
            ->setUrl('https://example.com/thumbnail.png')
        )
        ->addField(
            (new Axl1232\PhpDiscordWebhook\Embed\Field())
            ->setName('Field 1')
            ->setValue('Value 1')
        )
        ->addField(
            (new Axl1232\PhpDiscordWebhook\Embed\Field())
            ->setName('Field 2')
            ->setValue('Value 2')
        )
    );

$hook = new Axl1232\PhpDiscordWebhook\Webhook('https://discordapp.com/api/webhooks/test/hook');
$hook->send($message);

Predefined colors in Axl1232\PhpDiscordWebhook\Tools\ColorHelper

Name Value Hex Code
WHITE 16777215 #FFFFFF
BLURPLE 5793266 #5865F2
GREYPLE (Default) 10070709 #99AAB5
DARK_BUT_NOT_BLACK 2895667 #2C2F33
NOT_QUITE_BLACK 2303786 #23272A
GREEN 5763719 #57F287
YELLOW 16705372 #FEE75C
FUSCHIA 15418782 #EB459E
RED 15548997 #ED4245
WHITE 16777215 #FFFFFF
BLACK 2303786 #23272A

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2021-10-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固