judahnator/discord-http-wrapper
Composer 安装命令:
composer require judahnator/discord-http-wrapper
包简介
A basic wrapper for the Discord HTTP API
README 文档
README
This library serves as a clean and simple interface between your bot and Discords HTTP REST API.
Because this library is under active development things might break, don't be afraid to open issues though. I will get to them as time permits.
Installation Instructions
This package can be installed via composer.
composer require judahnator/discord-http-wrapper
This library relies on the vlucas/phpdotenv
library to hold its configuration values. The most important of which
being the token for your bot. If your project also utilizes this library
simply include BOT_TOKEN=your-bots-token in your .env file. Otherwise
set that value in the /vendor/judahnator/discord-http-wrapper/.env file.
This file does not exist by default, but a .env.example template
is located in that same directory.
If you do not have a token yet, you can get one from the Discord-developers site. Your token must also be authorized to make RESTful API requests.
Basic Usage
judahnator\DiscordHttpWrapper\Bot::class - A singleton class that
provides general info about the bot. For example:
$Bot = judahnator\DiscordHttpWrapper\Bot::Instance();
$Bot->id; // 123456
$Bot->username; // TestBot
$Bot->guilds; // An array of guilds the bot has access to
judahnator\DiscordHttpWrapper\Guild::class - A class to interface with guilds.
$Guild = judahnator\DiscordHttpWrapper\Guild::find(1234567890);
$Guild->id; // 1234567890
$Guild->name; // TestGuild
$Guild->channels; // An array of channels belonging to this guild
judahnator\DiscordHttpWrapper\Channel::class - A class to interface with channels.
$Channel = judahantor\DiscordHttpWrapper\Channel::find(1234567890);
$Channel->id; // 1234567890
$Channel->name; // TestChannel
$Channel->guild; // The guild the channel belongs to
$Channel->messages; // The 50 most recent messages in this channel
$Channel->sendMessage("Foo bar baz"); // Sends message, returns the message object
judahnator\DiscordHttpWrapper\Message::class - Class to interface with messages
$Message = judahnator\DiscordHttpWrapper\Message::find($ChannelID,$MessageID);
$Message->id; // Message ID
$Message->content; // The content of the message
$Message->author; // The author object
$Message->reply("Foo bar baz"); // Replies to the author of the current message
judahnator\DiscordHttpWrapper\Message::send($ChannelID,"Foo bar baz"); // Sends a message to a channel
judahnator\DiscordHttpWrapper\Author::class - Class to interface with authors
$Author = judahnator\DiscordHttpWrapper\Author::find(1234567890);
$Author->id; // 1234567890
$Author->username; // TestAuthor
General Notes
As the name implies, this library interfaces with Discords HTTP API. This means that even on a low-latency connection, this library will be much slower than other libraries that interface with Discord via websockets.
In the same line of thought, this library also respects the rate-limit headers supplied by Discord. At the time of writing the limit was about 1.5 requests per second. This means in more popular servers, iterating through messages will be slow. If you need speed, I recommend using TeamReflexs' DiscordPHP library.
Contributing
I welcome issues, forks, pull requests, whole nine yards. Just please for the love of all that is good in the world write clean code and leave lots of comments.
judahnator/discord-http-wrapper 适用场景与选型建议
judahnator/discord-http-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 86 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 judahnator/discord-http-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 judahnator/discord-http-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 86
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-26