The GuildHelper.CreateRoleAsync() was sending 2 requests to create a role. One to create the role, and one to modify the role that was created. This can be done in one request. So i have moved it to a single request to lower the amount of requests send to the api. This will also solve issue #1451.
## Summary
If PartyId isn't present, Discord.Net will throw an InvalidOperationException and not raise `MessageReceived`.
Got this a few times with my bot, stacktrace:
```
System.InvalidOperationException: This property has no value set.
at Discord.Optional`1.get_Value() in ...\Discord.Net\src\Discord.Net.Core\Utils\Optional.cs:line 20
at Discord.WebSocket.SocketMessage.Update(ClientState state, Message model) in ...\Discord.Net\src\Discord.Net.WebSocket\Entities\Messages\SocketMessage.cs:line 157
at Discord.WebSocket.SocketUserMessage.Update(ClientState state, Message model) in ...\Discord.Net\src\Discord.Net.WebSocket\Entities\Messages\SocketUserMessage.cs:line 58
at Discord.WebSocket.SocketUserMessage.Create(DiscordSocketClient discord, ClientState state, SocketUser author, ISocketMessageChannel channel, Message model) in ...\Discord.Net\src\Discord.Net.WebSocket\Entities\Messages\SocketUserMessage.cs:line 53
at Discord.WebSocket.DiscordSocketClient.ProcessMessageAsync(GatewayOpCode opCode, Nullable`1 seq, String type, Object payload) in ...\Discord.Net\src\Discord.Net.WebSocket\DiscordSocketClient.cs:line 1210
```
After looking all properties, this is the only one that could be blamed and was already fixed for `RestMessage`s, see #1337
## Changes
- `Value` to `GetValueOrDefault()` for `PartyId`
If the current reset time is in the past, then somebody else in the
current bucket must have made a request before we were able to. To
prevent accidental ratelimits, we fall-back to the second sleep
branch, as if the reset time wasn't specified at all.
Additionally Extracts the minimum sleep time to a constant, and also
bumps it to 750ms.
* Fix for Issue #1471
This change will allow `GuildAvailable` to fire when the client joins a new guild, as well as properly update `IsConnected`.
* Removed unnecessary statement;
* Feature: Allowed mentions object on msg create (interface breaking)
This change implements the AllowedMentions object for the payload of message creation. By default, the mentions behavior remains unchanged, the message content is parsed for all mentionable entities and they are all notified. If this payload is not null, it will use the content of the allowed_mentions field to determine if a role is notified, or just displayed.
This change is interface breaking. This follows the conventions of keeping RequestOptions as the last argument, but could break some users who specify each of these arguments without using named arguments.
* lint: remove commented-out code
This change removes the commented-out code which was added during testing from the previous commit.
* fix interface break: reorder allowedMentions arg so that it's after options
This change modifies the order of the AllowedMentions argument of SendMessageAsync so that this addition shouldn't be interface breaking. The downside to this change is that it breaks the convention followed by other methods, where the RequestOptions argument is normally last.
* docs: fix typo in allowedMentions arg doc
* fix interface break arg from IRestMessageChannel
* docs: update xmldoc for allowedMentions args
* fix interface breaking arg order for ISocketMessageChannel
* fix mocked classes that weren't updated
* fix: RestDMChannel#SendMessageAsync bug, allowed mentions always null
This change fixes a bug that was introduced while testing changes to the interface of the SendMessageAsync method to try and retain interface compatibility
* docs: update xmldoc for AllowedMentions type
* docs: reword xmldoc of AllowedMentionTypes type
* docs: fix typo
* fix: validate that User/Role flags and UserIds/RoleIds lists are mutually exclusive
This change adds validation to SendMessageAsync which checks that the User flag is mutually exclusive with the list of UserIds, and that the Role flag is also mutually exclusive with the list of RoleIds
* docs: reword summaries for AllowedMentions type
* Add util properties for specifying all or no mentions
Adds read only properties which specify that all mentions or no mentions will notify users. These settings might be more common than others, so this would make them easier to use.
* docs: Resolve PR comments for documentation issues/typos
* Add doc page for Named Arguments
* Implement minor stylistic changes
* Update docfx.json to support NS2.0
Signed-off-by: Still Hsu <5843208+Still34@users.noreply.github.com>
* Fix broken xref in basic-operations
* Fix broken crefs
* Fix wordings in named argument
* Fix misleading warning about long-running code
* Fix misleading CommandService summary
Signed-off-by: Still Hsu <5843208+Still34@users.noreply.github.com>
* Update copyright year and version
Signed-off-by: Still Hsu <5843208+Still34@users.noreply.github.com>
* Escape example captions
* Add warning regarding FlattenAsync for GetReactionUsersAsync
* Fix a minor grammar mistake
Co-authored-by: Joe4evr <jii.geugten@gmail.com>
This change fixes a bug that was introduced in PR #1406. Games were falsely detected to be CustomStatusGames, based on the Id property being included in the model payload.
This fixes the false detection of Games as CustomStatusGame. An activity will only be considered a CustomStatusGame if the Id has a value of "custom".
This change has been tested by listening to the GuildMemberUpdated event, and opening/closing games with a custom status set.
* Fixed GetUsersAsync to use MaxUsersPerBatch const as limit instead of MaxMessagesPerBatch.
Requests are now returning up to 1000 guild user entities instead of the previous 100.
* Added StartedAt and EndsAt timespans for SpotifyGame.
They make it possible to expose track's Elapsed and Remaining properties.
* Moved Duration to be initialized within model construction.
* Updated StartedAt and EndsAt comments.
This change updates the NewsChannel classes so that the overwrite permission-related properties no longer throw an Exception when they are used.
These properties were not initially supported by News/Announcement channels when the feature was first released, but now they are.
* Fix#1335 Add isMentionable parameter to CreateRoleAsync in non-breaking manner
This PR adds the isMentionable parameter to the CreateRoleAsync method
in a way that prevents it from being interface-breaking. This has been done
by adding it as an optional parameter at the end of publicly-exposed
methods.
This parameter determines if the newly created role can be mentioned as it is
created.
* Overload CreateRoleAsync methods
This change ensures that SocketUser.ActiveClients will not return null, but instead an empty set by default. This can happen if the client has not recieved a presence update for a user, or if the user is not cached.
* Implement CustomStatusGame activity
Adds the CustomStatusGame class, which is the activity corresponding to the custom status feature.
* Remove unused import from Game.cs
* Added support for Message References
* Removed unused usings, added debugger display, updated ToString override
* Changed snowflakes to be wrapped in an optional instead of a nullable.
This fixes the docs for the command service, where it specifies that arguments that use the params keyword are comma separated, when they are actually space separated.