定制 team-reflex/discord-php 二次开发

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

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

team-reflex/discord-php

Composer 安装命令:

composer require team-reflex/discord-php

包简介

An unofficial API to interact with the voice and text service Discord.

README 文档

README

Latest Stable Version Latest Unstable Version Total Downloads PHP Version Require

PHP Discorders

A wrapper for the official Discord REST, gateway and voice APIs. Documentation is available here, albeit limited at the moment, as well as a class reference. Feel free to ask questions in the Discord server above.

For testing and stability it would be greatly appreciated if you were able to add our test bot to your server. We don't store any data - the bot simply idles and does not interact with anyone and is used to test stability with large numbers of guilds. You can invite the bot here.

Cache Interface (experimental)

Warning This branch contains an experimental feature, do not use it in production! See the wiki page for more information on how to set it up.

FAQ

  1. Can I run DiscordPHP on a webserver (e.g. Apache, nginx)?
    • No, DiscordPHP will only run in CLI. If you want to have an interface for your bot you can integrate react/http with your bot and run it through CLI.
  2. PHP is running out of memory?
    • Try unlimit your PHP memory using ini_set('memory_limit', '-1');.

Framework Integrations

While DiscordPHP is framework-agnostic and designed to run directly in CLI environments, there are community-maintained integrations available for popular frameworks:

  • laracord/laracord — A Laravel integration for DiscordPHP, providing service container bindings, configuration helpers, and a more Laravel-native development experience.

Laracord is maintained independently and is not part of the DiscordPHP core project.

Getting Started

Before you start using this Library, you need to know how PHP, Event Loops, and Promises work. This is a fundamental requirement before you start. Without this knowledge, you will only suffer.

Requirements

Recommended Extensions

  • One of ext-uv (recommended), ext-ev or ext-event for a faster, and more performant event loop.
  • ext-mbstring if handling non-latin characters.

Voice Requirements

Windows and SSL

Unfortunately PHP on Windows does not have access to the Windows Certificate Store. This is an issue because TLS gets used and as such certificate verification gets applied (turning this off is not an option).

You will notice this issue by your script exiting immediately after one loop turn without any errors.

As such users of this library need to download a Certificate Authority extract from the cURL website.
The path to the caextract must be set in the php.ini for openssl.cafile.

Installing DiscordPHP

DiscordPHP is installed using Composer.

  1. Run composer require team-reflex/discord-php. This will install the latest stable release.
    • If you would like, you can also install the development branch by running composer require team-reflex/discord-php dev-master.
  2. Include the Composer autoload file at the top of your main file:
    • include __DIR__.'/vendor/autoload.php';
  3. Make a bot!

Basic Example

<?php

include __DIR__.'/vendor/autoload.php';

use Discord\Discord;
use Discord\Parts\Channel\Message;
use Discord\WebSockets\Intents;
use Discord\WebSockets\Event;

$discord = new Discord([
    'token' => 'bot-token',
    'intents' => Intents::getDefaultIntents()
//      | Intents::MESSAGE_CONTENT, // Note: MESSAGE_CONTENT is privileged, see https://dis.gd/mcfaq
]);

$discord->on('ready', function (Discord $discord) {
    $discord->logger->info("Bot is ready!");

    // Listen for messages.
    $discord->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) {
        // Note: MESSAGE_CONTENT intent must be enabled to get the content if the bot is not mentioned/DMed.
        $discord->logger->info("{$message->author->username}: {$message->content}");
    });
});

$discord->run();

See examples folder for more.

Documentation

Documentation for the latest version can be found here. Community contributed tutorials can be found on the wiki.

Contributing

We are open to contributions. However, please make sure you follow our coding standards (PSR-4 autoloading and custom styling). Please run php-cs-fixer before opening a pull request by running composer run-script cs.

License

MIT License, © David Cole and other contributers 2016-present.

Stargazers over time

Stargazers over time

team-reflex/discord-php 适用场景与选型建议

team-reflex/discord-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 420.63k 次下载、GitHub Stars 达 1.08k, 最近一次更新时间为 2015 年 08 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 team-reflex/discord-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 team-reflex/discord-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 team-reflex/discord-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 420.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1084
  • 点击次数: 29
  • 依赖项目数: 31
  • 推荐数: 3

GitHub 信息

  • Stars: 1082
  • Watchers: 25
  • Forks: 250
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-12