dragan/discord-webhooks

用于通过 Discord webhook 创建和发送消息的包

dev-master 2022-11-08 18:52 UTC

This package is auto-updated.

Last update: 2024-10-01 00:07:37 UTC


README

通过 Discord webhook 发送消息的包

使用 composer 安装

composer require dragan/discord-webhooks

然后在 config/app.php 的 "providers" 部分添加 \Dragan\DiscordWebhooks\DiscordWebhooksServiceProvider::class

基本用法

发送基本消息

<?php

use Dragan\DiscordWebhooks\Services\Webhook;

(new Webhook())
       ->channel('example_channel')
       ->message('This message was sent at ' . now() )
       ->username('Example webhook')
       ->avatar('https://i.imgur.com/sDbhcnb.jpg')
       ->send();

Sending basic messages

默认配置

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default webhook color
    |--------------------------------------------------------------------------
    |
    | This options will be used as default color for the embeds.
    | Must be valid color code.
    |
    */
    'default_webhook_color' => 0x006eff,
    /*
    |--------------------------------------------------------------------------
    | Default webhook channel
    |--------------------------------------------------------------------------
    |
    | This options will be used when no other channel is specified.
    |
    */
    "default_channel" => env('DISCORD_DEFAULT_WEBHOOK', ''),


    /*
    |--------------------------------------------------------------------------
    | Other webhook channels
    |--------------------------------------------------------------------------
    |
    | Other Discord webhook channels.
    |
    */
    "channels" => [
        'example_channel' => env('DISCORD_EXAMPLE_CHANNEL', ''),
        'second_example_channel' => "",
    ],

];