Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 5.0.0 #309

Merged
merged 113 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
951b422
Updating composer.json: PHP ^7.0, symfony/options-resolver <=5.1.3
davidcole1340 Aug 13, 2020
f369043
Updating carbon and fixing composer errors
davidcole1340 Aug 13, 2020
1bc2538
Remove channel only if guild is found, #237
davidcole1340 Aug 13, 2020
cb72ed8
Retrieve user object from cache
davidcole1340 Aug 13, 2020
766ea3b
Fixed typehinting in helpers
davidcole1340 Aug 13, 2020
446eba6
Updated Process helper to work with upgraded stream
davidcole1340 Aug 13, 2020
f3c3ada
Added polyfill libsodium for backwards compatibility
davidcole1340 Aug 13, 2020
4589d4b
Upgraded to version 4 of voice gateway
davidcole1340 Aug 13, 2020
01a1c02
Added fill and getindex functions to Collection
davidcole1340 Aug 13, 2020
6374dfc
Fixed HTTP client caching requests
davidcole1340 Aug 13, 2020
e591a49
Stop repositories caching when freshing
davidcole1340 Aug 13, 2020
d97635e
Added webhooks #227
davidcole1340 Aug 13, 2020
72e5565
Updating composer.json
davidcole1340 Aug 13, 2020
d2b569a
Removing PHPStorm function
davidcole1340 Aug 13, 2020
9741d90
Upgrading illuminate/support package, close #293
davidcole1340 Aug 15, 2020
451689a
Typo in Guild.php
davidcole1340 Aug 15, 2020
f5bbc4d
Remove debug code
davidcole1340 Aug 15, 2020
5ea4060
Major overhaul of events system. Important changes include renaming G…
davidcole1340 Aug 15, 2020
36868f4
Setting up php-cs-fixer
davidcole1340 Aug 15, 2020
1e3cd09
Updating email address
davidcole1340 Aug 15, 2020
209ffc7
Adding php-cs-fixer command to composer scripts
davidcole1340 Aug 15, 2020
27e19cc
Added disclaimer to update presence function
davidcole1340 Aug 15, 2020
4aba97f
Updated presence update function
davidcole1340 Aug 15, 2020
6f63a50
Allow roles to update mentionability, close #256
davidcole1340 Aug 16, 2020
407f85a
Updated readme
davidcole1340 Aug 16, 2020
481eef3
Implementing message reaction events
davidcole1340 Aug 20, 2020
c7cd89a
Added getter function for loop
davidcole1340 Aug 20, 2020
eda931c
Adding message collector, #296
davidcole1340 Aug 20, 2020
8b7ebc9
Fixing limit
davidcole1340 Aug 20, 2020
9290c83
Cancel timer when limit resolves
davidcole1340 Aug 20, 2020
7c42c5a
Fixing message get channel
davidcole1340 Aug 21, 2020
845a38b
Allow message reaction with emoji part
davidcole1340 Aug 21, 2020
1d98c1d
Allow message reaction delete with emoji part
davidcole1340 Aug 21, 2020
d3158a3
Adding new channel attributes
davidcole1340 Aug 21, 2020
bca5daa
Adding new channel attributes
davidcole1340 Aug 21, 2020
805c8ef
Adding type to embed docs
davidcole1340 Aug 21, 2020
897cbf7
Adding ban reason
davidcole1340 Aug 21, 2020
6874cbc
Adding all members endpoint to MemberRepository
davidcole1340 Aug 21, 2020
2d03b5c
Added ability to get voice regions
davidcole1340 Aug 21, 2020
95080c0
cs-fixer
davidcole1340 Aug 21, 2020
c9d1d5d
Merge branch 'develop' into collectors
davidcole1340 Aug 21, 2020
d9f9308
Added ability to delete a message directly
oliverschloebe Aug 21, 2020
638483e
Update Message.php
oliverschloebe Aug 21, 2020
9f93fcd
Merge pull request #297 from oliverschloebe/patch-1
davidcole1340 Aug 21, 2020
1dda9e0
Added *timer() methods
oliverschloebe Aug 21, 2020
0f14e1d
Added ability to reply to message with a delay
oliverschloebe Aug 21, 2020
d95c357
Using getLoop() instead
oliverschloebe Aug 21, 2020
cb446ad
Remove previously added *timer() methods
oliverschloebe Aug 21, 2020
539d883
Make delayedReply() return a Promise
oliverschloebe Aug 21, 2020
a33201b
Merge pull request #298 from oliverschloebe/patch-2
davidcole1340 Aug 21, 2020
e05435f
cs fixer
davidcole1340 Aug 22, 2020
28cf97c
Added reaction collector, #296
davidcole1340 Aug 22, 2020
82a9fca
Retrieve bans -> false
davidcole1340 Aug 22, 2020
213c327
Client will not load members into memory if not told to in config
davidcole1340 Aug 22, 2020
339008e
Author attribute fixes
davidcole1340 Aug 22, 2020
3492f37
Remove the ability to create messages through repository
davidcole1340 Aug 22, 2020
cceed60
Added the ability to add an embed to a message
davidcole1340 Aug 22, 2020
2b81561
Cooldown option for commands
oliverschloebe Aug 23, 2020
9260bf3
Cooldown option for commands
oliverschloebe Aug 23, 2020
ec866b7
Merge branch 'develop' into patch-1
oliverschloebe Aug 24, 2020
bccc09c
Use microtime() instead of time()
oliverschloebe Aug 24, 2020
3e71e3a
Fix missing variable in constructor
oliverschloebe Aug 24, 2020
2c8913c
Microtransaction
oliverschloebe Aug 24, 2020
546d394
Merge pull request #299 from oliverschloebe/patch-1
davidcole1340 Aug 24, 2020
d6a376b
Replace deprecated xkcd parameter with unique parameter
oliverschloebe Aug 25, 2020
2a797f2
Merge pull request #300 from oliverschloebe/patch-1
davidcole1340 Aug 25, 2020
0dbf013
Creating an invite now takes an array of options
davidcole1340 Aug 25, 2020
27044d1
Mitigate missing members and roles for guild
mvaessen Aug 26, 2020
74ba8d0
Merge pull request #302 from mvaessen/feature/fix_no_members_and_role…
davidcole1340 Aug 27, 2020
a443d79
Added new channel types
davidcole1340 Aug 27, 2020
1d4f463
Fixing author attribute
davidcole1340 Aug 27, 2020
075f4f5
php-cs-fixer
davidcole1340 Aug 27, 2020
b3e0e90
Help command overhaul
oliverschloebe Aug 27, 2020
595cf70
Help command overhaul
oliverschloebe Aug 27, 2020
865eb97
Update DiscordCommandClient.php
oliverschloebe Aug 27, 2020
33d999e
Merge pull request #305 from oliverschloebe/patch-1
davidcole1340 Aug 28, 2020
28a573c
php-cs-fixer
davidcole1340 Aug 28, 2020
f70f562
Display unavailable guilds in debug when receiving guilds
davidcole1340 Aug 28, 2020
be95d5f
Optimization of guild create
davidcole1340 Aug 28, 2020
181beab
Removing cache references
davidcole1340 Aug 28, 2020
75af839
Implemented new collection class
davidcole1340 Aug 28, 2020
52eae96
Removing cache wrapper
davidcole1340 Aug 28, 2020
c22493f
Fixing message update event
davidcole1340 Aug 28, 2020
f05d357
Removing unused variable
davidcole1340 Aug 28, 2020
74b0198
Optimizing guild create and guild member chunk functions
davidcole1340 Aug 31, 2020
aac95a1
Collection::pull()
davidcole1340 Aug 31, 2020
f19b234
Updated README
davidcole1340 Aug 31, 2020
69168fb
Removed cache dependencies and added lib-uv
davidcole1340 Aug 31, 2020
1b10105
php-cs-fixer
davidcole1340 Aug 31, 2020
8e96c42
php-cs-fixer
davidcole1340 Aug 31, 2020
48b45ac
Implemented intents
davidcole1340 Aug 31, 2020
a2aa635
Throw exception if given an invalid intent
davidcole1340 Aug 31, 2020
7875b19
Added new events:
davidcole1340 Aug 31, 2020
ff2a31d
Added new websocket close codes
davidcole1340 Aug 31, 2020
9d0689d
Fixed username and discriminator attributes
davidcole1340 Sep 1, 2020
810d94b
Permissions overhaul
davidcole1340 Sep 1, 2020
c095f45
Merge branch 'develop' into permissions
davidcole1340 Sep 1, 2020
4f50e3d
Presence update push -> offsetSet
davidcole1340 Sep 1, 2020
acef429
Typo in guild update event, #306
davidcole1340 Sep 1, 2020
54420ea
guild update push -> offsetSet
davidcole1340 Sep 1, 2020
41d5417
Added the getLogger function
davidcole1340 Sep 2, 2020
959e534
Improved message update event
davidcole1340 Sep 3, 2020
1b20360
Optimising member attribute
davidcole1340 Sep 3, 2020
d2ffb1d
Passing deferred promise by reference for events
davidcole1340 Sep 3, 2020
22b976f
Updated monolog dependency
davidcole1340 Sep 3, 2020
8e1c2c9
Redoing requirements
davidcole1340 Sep 3, 2020
d31382d
Allow intent to be passed as an integer
davidcole1340 Sep 4, 2020
f888ac2
Added part and repository functions to factory
davidcole1340 Sep 5, 2020
f27cc2f
Fixed memory leak #174
davidcole1340 Sep 5, 2020
3a9cbee
Removing redundant loop interface
davidcole1340 Sep 5, 2020
ca05832
Merge new permissions system
davidcole1340 Sep 5, 2020
0aa0008
Added CHANGELOG.md
davidcole1340 Sep 5, 2020
0ee9896
Bumped version
davidcole1340 Sep 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/vendor
composer.lock
test*.php
.idea
.idea
.php_cs.cache
.php_cs
95 changes: 0 additions & 95 deletions .php_cs

This file was deleted.

106 changes: 106 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

/*
* This file is apart of the DiscordPHP project.
*
* Copyright (c) 2016 David Cole <david.cole1340@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the LICENSE.md file.
*/

$header = <<<'EOF'
This file is apart of the DiscordPHP project.

Copyright (c) 2016-2020 David Cole <david.cole1340@gmail.com>

This source file is subject to the MIT license that is bundled
with this source code in the LICENSE.md file.
EOF;

$fixers = [
'blank_line_after_namespace',
'braces',
'class_definition',
'elseif',
'encoding',
'full_opening_tag',
'function_declaration',
'lowercase_constants',
'lowercase_keywords',
'method_argument_space',
'no_closing_tag',
'no_spaces_after_function_name',
'no_spaces_inside_parenthesis',
'no_trailing_whitespace',
'no_trailing_whitespace_in_comment',
'single_blank_line_at_eof',
'single_class_element_per_statement',
'single_import_per_statement',
'single_line_after_imports',
'switch_case_semicolon_to_colon',
'switch_case_space',
'visibility_required',
'blank_line_after_opening_tag',
'no_multiline_whitespace_around_double_arrow',
'no_empty_statement',
'no_extra_consecutive_blank_lines',
'include',
'no_trailing_comma_in_list_call',
'not_operator_with_successor_space',
'trailing_comma_in_multiline_array',
'no_multiline_whitespace_before_semicolons',
'no_leading_namespace_whitespace',
'no_blank_lines_after_class_opening',
'no_blank_lines_after_phpdoc',
'object_operator_without_whitespace',
'binary_operator_spaces',
'phpdoc_indent',
'phpdoc_inline_tag',
'phpdoc_no_access',
'phpdoc_no_package',
'phpdoc_scalar',
'phpdoc_summary',
'phpdoc_to_comment',
'phpdoc_trim',
'phpdoc_var_without_name',
'no_leading_import_slash',
'blank_line_before_return',
'no_short_echo_tag',
'no_trailing_comma_in_singleline_array',
'single_blank_line_before_namespace',
'single_quote',
'no_singleline_whitespace_before_semicolons',
'cast_spaces',
'standardize_not_equals',
'ternary_operator_spaces',
'trim_array_spaces',
'unary_operator_spaces',
'no_unused_imports',
'no_useless_else',
'no_useless_return',
'phpdoc_no_empty_return',
];

$rules = [
'concat_space' => ['spacing' => 'none'],
'phpdoc_no_alias_tag' => ['type' => 'var'],
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => true],
'header_comment' => ['header' => $header],
'indentation_type' => true,
'phpdoc_align' => [
'align' => 'vertical'
]
];

foreach ($fixers as $fix) {
$rules[$fix] = true;
}

return PhpCsFixer\Config::create()
->setRules($rules)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
);
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"php-cs-fixer.config": ".php_cs",
"php-cs-fixer.executablePath": "${workspaceFolder}/vendor/friendsofphp/php-cs-fixer/php-cs-fixer"
}
97 changes: 97 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Changelog

## Version 5.0.0

First release for many years. Contains many bug fixes and stability patches so this is the most important update since.

### Breaking Changes

- PHP 7.0 is now required. PHP 5.x is no longer supported.
- Package versions:
- illuminate/support: now supports Laravel 6.x and 7.x
- nesbot/carbon: was ^1.18, now ^2.38
- symfony/options-resolver: was ^3.0, now ^5.1.3
- monolog/monolog: was ^1.19, now ^2.1
- Cache adapters such as apc, memcache and redis are no longer supported. There is no longer a `cachePool` option.
- ext-libevent is no longer supported as it only applies for PHP 5.x.
- The `Collection` class no longer extends Laravel collections.
- As such, some functions are no longer present.
- Feel free to add an issue if you would like to see a function added.
- Channels:
- `Channel::setPermissions()` function now takes a role or member as well as two arrays: one array of allow permissions and one array of deny permissions.
- `Channel::createInvite()` now takes an array of options. See the [Discord developer docs](https://discord.com/developers/docs/resources/channel#create-channel-invite) for a list of valid options.
- Messages can no longer be created using the message repository as part of the channel. Use `Channel::sendMessage()` instead.
- Overwrites:
- The `allow` and `deny` parameters of an overwrite are an instance of `ChannelPermission` instead of `int`.
- Guilds:
- Removed [old region constants](https://github.com/teamreflex/DiscordPHP/blob/ca05832fa0d5700d96f5ecee2fe32a3aa6125f41/src/Discord/Parts/Guild/Guild.php). Added the `Guild::getVoiceRegions()` function to get an array of valid regions.
- `Guild::validateRegion()` now has to perform an async HTTP request to validate the region. Only use this if nessasary.
- Removed the `Game` class. Renamed to `Activity` and new attributes added.
- `Discord::updatePresence()` now takes an `Activity` object as well as options `idle`, `status` and `afk`.

### Features

- Added `getLoop()` and `getLogger()` functions to the `Discord` client.
- Collectors:
- Channels now have message collectors. See the phpdoc of `Channel::createMessageColletor()` for more information.
- Messages now have reaction collectors. See the phpdoc of `Message::createReactionCollector()` for more information.
- Added the [`Reaction`](https://github.com/teamreflex/DiscordPHP/blob/ca05832fa0d5700d96f5ecee2fe32a3aa6125f41/src/Discord/Parts/Channel/Reaction.php) class.
- Added the [`Webhook`](https://github.com/teamreflex/DiscordPHP/blob/ca05832fa0d5700d96f5ecee2fe32a3aa6125f41/src/Discord/Parts/Channel/Webhook.php) class.
- Implemented gateway intents:
- See the [`Intents` class](https://github.com/teamreflex/DiscordPHP/blob/ca05832fa0d5700d96f5ecee2fe32a3aa6125f41/src/Discord/WebSockets/Intents.php) for constants.
- User can specify an `intents` field in the options array, containing either an array of intents or an integer corresponding to the intents.

### Changes

- WebSocket:
- Added new events: `GUILD_INTEGRATIONS_UPDATE`, `INVITE_CREATE`, `INVITE_DELETE`, `MESSAGE_REACTION_REMOVE_EMOJI`.
- Client will not retrieve guild bans by default anymore. Set `retrieveBans` to `true` in options to retrieve on guild availability.
- Command client:
- Help command now prints a rich embed (#305 thanks @oliverschloebe)
- Commands have a short and long description.
- Commands have a cooldown option.
- Factory now has a `part()` and `repository()` function to bypass `strpos` functions.
- Channels:
- [Added new attributes](https://github.com/teamreflex/DiscordPHP/pull/309/files#diff-d1f173f4572644420fb9cd5d0b540c59R51-R58).
- [Added new channel types](https://github.com/teamreflex/DiscordPHP/pull/309/files#diff-d1f173f4572644420fb9cd5d0b540c59R66-R72).
- Added webhook classes and repositories.
- `Channel::setOverwrite()` has been added to perform the action of `setPermissions()` from the previous version.
- Messages:
- [Added new attributes](https://github.com/teamreflex/DiscordPHP/pull/309/files#diff-dcdab880a1ed5dbd0b65000834e4955cR44-R55).
- [Added new message types](https://github.com/teamreflex/DiscordPHP/pull/309/files#diff-dcdab880a1ed5dbd0b65000834e4955cR59-R78).
- Added `Message::delayedReply()` to perform a reply after a specified duration.
- `Message::react()` and `Message::deleteReaction()` now takes an `Emoji` object or a string emoji.
- Added `Message::delete()` to delete a message without using the repository.
- Added `Message::addEmbed()` to add an embed to the message.
- Added the [`MessageReaction` class](https://github.com/teamreflex/DiscordPHP/blob/ca05832fa0d5700d96f5ecee2fe32a3aa6125f41/src/Discord/Parts/WebSockets/MessageReaction.php) to represent a reaction to a message.
- Embeds:
- Added the `type` parameter.
- Emojis:
- Added the `animated` parameter.
- Added the `Emoji::toReactionString()` function to convert to a format to put in a `Reaction` object.
- Added the `Emoji::__toString()` object for sending emojis in messages.
- Guilds:
- Guild region is no longer checked before saving. Make sure to handle any exceptions from Discord servers and do not spam.
- Roles can now update their `mentionable` attribute.
- Permissions:
- [Added new permissions.](https://github.com/teamreflex/DiscordPHP/pull/309/files#diff-60e83a1d96a4957061230b770a056001R5-R35)
- Members:
- [Added new attributes.](https://github.com/teamreflex/DiscordPHP/pull/309/files#diff-8f236f99fe6eec45c56cff1be0ba0f90R40-R42)
- The `game` attribute now returns an `Activity` part.
- Presence updates:
- [Added new attributes.](https://github.com/teamreflex/DiscordPHP/pull/309/files#diff-d6e13d509fb506d128c564d3ea4217adR25-R32)
- Typing updates:
- [Added new attributes.](https://github.com/teamreflex/DiscordPHP/pull/309/files#diff-bc4d0e1ce4e436c29b922dd26266df68R26-R32)
- Voice state updates:
- [Added new attributes.](https://github.com/teamreflex/DiscordPHP/pull/309/files#diff-4aa18d683d39063927ff9ff28149698fR21-R35)

### Bug Fixes

- Improved memory usage by removing `resolve` and `reject` functions from `Part`s.
- Memory leak has been improved but is still preset.
- `AbstractRepository::freshen()` now actually freshens the part, rather than being cached.
- Voice client has been updated to use the correct UDP server given by the web socket.
- Events *should* update their corresponding repositories more consistently.
- Improved the processing speed of `GUILD_CREATE` and `GUILD_MEMBERS_CHUNK` events.
- Added new gateway operation and close codes.
- Client will not attempt to reconnect to Discord servers if it receives a "critical" opcode (one that cannot be resolved by the bot).
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ DiscordPHP
====
[![Build Status](https://travis-ci.org/teamreflex/DiscordPHP.svg?branch=master)](https://travis-ci.org/teamreflex/DiscordPHP) [![Discord Chat](https://img.shields.io/badge/chat-Discord%20API-blue.svg)](https://discord.gg/0SBTUU1wZTX4Mjwn) [![PHP Discorders](https://img.shields.io/badge/chat-PHP%20Discord-blue.svg)](https://discord.gg/0duG4FF1ElFGUFVq)

A wrapper for the official [Discord](https://discordapp.com) REST, gateway and voice APIs. Project is currently being revived so please check out any Github issues. The `develop` branch is the most stable at the moment.
A wrapper for the official [Discord](https://discordapp.com) REST, gateway and voice APIs.

Project is currently being revived so please check out any Github issues. The `develop` branch is the most stable at the moment.

## 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](https://github.com/ReactPHP/http) with your bot and run it through CLI.
2. PHP is running out of memory?
- Try increase your memory limit using `ini_set('memory_limit', '-1');`.

## Getting Started

### Installing DiscordPHP

DiscordPHP is installed using [Composer](https://getcomposer.org). Make sure you have installed Composer and are used to how it operates. We require a minimum PHP version of PHP 5.5.9, however it is reccomended that you use PHP 7. PHP 5.x support **will** be removed in the future.

This library has not been tested with HHVM.
DiscordPHP is installed using [Composer](https://getcomposer.org). Make sure you have installed Composer and are used to how it operates. We require a minimum PHP version of PHP 7.0. PHP 7.1 will be required in the near future.

1. Run `composer require team-reflex/discord-php`. This will install the lastest release.
- If you would like, you can also install the development branch by running `composer require team-reflex/discord-php dev-develop`.
Expand Down Expand Up @@ -48,18 +50,14 @@ $discord->on('ready', function ($discord) {
$discord->run();
```

## Notes

- This library can use a lot of RAM and PHP may hit the memory limit. To increase the memory limit, use `ini_set('memory_limit', '200M')` to increase it to 200 mb. If you would like it to be unlimited, use `ini_set('memory_limit', '-1')`.

## Documentation

Raw documentation can be found in-line in the code and on the [DiscordPHP Class Reference](http://teamreflex.github.io/DiscordPHP/). More user friendly and examples will soon be coming on the [DiscordPHP Wiki](https://discordphp.readme.io/).

## Contributing

We are open to contributions. However, please make sure you follow our coding standards (PSR-4 autoloading and custom styling). We use StyleCI to format our code. Our StyleCI settings can be found [here](https://github.com/teamreflex/DiscordPHP/wiki/StyleCI).
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`.

## Library Comparison
## License

See [this chart](https://abal.moe/Discord/Libraries.html) for a feature comparison and list of other Discord API libraries.
MIT License, &copy; David Cole and other contributers 2016--present.
Loading