frf/discord-notification

向 webhook Discord 频道发送消息

1.0.14 2021-05-11 22:30 UTC

This package is auto-updated.

Last update: 2024-09-12 05:31:38 UTC


README

向 discord hook 发送消息

N|Solid

Build Status

创建此项目是为了解耦向不同频道发送消息的过程,从而保持项目没有固定的依赖。通过 Discord hook 发送消息可以方便错误通信、在资费结束时发出警告等众多好处。

特性

  • 通过 hook 向 Discord 频道发送消息

未来特性

  • 通过 hook 向多个 Discord 频道发送消息
  • Laravel 集成通知

安装

Laravel Discord Message 需要 PHP Laravel v8+ 运行。

安装包

composer require frf/discord-notification

安装后 - 创建 Discord Hook

打开您的频道配置并创建集成

App Screenshot

添加 hook 名称并选择您的频道

App Screenshot

将文件末尾 .env 配置链接 hook 放入您的 .env

DISCORD_HOOK=https://discord.com/api/webhooks/4334343/XaFx43434343lGHYvQHoQO0ykhGRibx3w

使用命令行示例

php artisan discord:send_message Teste
php artisan discord:send_message Teste warning

使用注入服务示例

记住,控制器中并没有更好的地方 😅,我仅将其作为一个实际示例

<?php

use Frf\DiscordNotification\Services\DiscordService;
use Illuminate\Support\Facades\Route;

Route::get('/', function (DiscordService $discordService) {

    $discordService
    ->title('Mensagem Teste')
    ->description('Descricao')
    ->footer('Footer')
    ->success()
    ->timestamp(Carbon::now())
    ->send();

    return view('welcome');
});

结果

App Screenshot

许可证

MIT

自由软件,太棒了!