agorlov/discordmsg 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

agorlov/discordmsg

最新稳定版本:1.0.1

Composer 安装命令:

composer require agorlov/discordmsg

包简介

Little class to send Discord message

README 文档

README

Very simple code to send single messages to discord channel.

This code was originally writen to send service messages about deploying my project to production.

How to Use

Composer

Execute:

$ composer require agorlov/discordmsg

Create example.php:

<?php

use AG\DiscordMsg;

require_once './vendor/autoload.php';

(new DiscordMsg('Greetings!'))->send();

Run it:

$ php example.php

Check discord chanel (for tests), your message is there:

https://discord.gg/jB5FsPf

Good old require_once

  1. Put Msg.php and DiscordMsg.php to your project:

  2. Check out how it works:

example.php

require_once 'Msg.php';
require_once 'DiscordMsg.php';


echo "To see dumb messages..\n";
echo "..join the discordmsg chanel https://discord.gg/Bh4EZB and enjoy!\n";
echo "Feel free to test!\n";


// First message
$msg = new \AG\DiscordMsg('Hello, Friends');
$msg->send();


// Second message
(new \AG\DiscordMsg(
    'I started the example.php, something happened?',
    null,
    $_ENV["USER"] ?? 'Mr. Pitkin'
))->send();


// Third message
(new \AG\DiscordMsg(
    "Maybe the missile is launched? :grimacing:", // message
    'https://discordapp.com/api/webhooks/475239272610398218/' . // chanel webhook link
        'tfpeg5EFI_94oEHfltZwcB5UAurfcswkBw5mKouZCq-akhvxe5BNOtN16AqSHvmSwpum',
    get_current_user(), // bot name
    '' // avatar url
))->send();


```bash
$ php example.php

How to notify user

Thank to @bricecarbou (#3)

To notify anybody by webhook, we need to use the "real" id of user (recover in discord with @) and use $msg="<@id_recovered> ...

$msg = "<@4386638385456546554> is notified";
(new \AG\DiscordMsg(
  $msg, // message
  $webhookurl, // chanel webhook link
  "Trad Bot", // bot name
  '' // avatar url
))->send();

How to get Webhook link

Open chanel preferences (if you have enough permissions): image

Create Webhook: image

统计信息

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

GitHub 信息

  • Stars: 11
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-04