Commit Graph

3142 Commits

Author SHA1 Message Date
Paulo
f2130f8513 feature: Add Direction.Around to GetMessagesAsync (#1526)
* Add Direction.Around to GetMessagesAsync

* Reuse the method

* Reuse GetMany

* Fix limit when getting from cache without message id

* Fix limit when getting from rest without message id

* Change cache return

It will return in a similar way to REST
2020-06-17 23:48:45 -04:00
moiph
d5d10d32cf feature: Support Gateway Intents (#1566)
* Support Gateway Intents

Allows supplying gateway intents through DiscordSocketConfig which will be passed through the IDENTIFY payload, in order to choose what gateway events you want to receive.

* Fixing enum casing

* Feedback

* Updating comment for GuildSubscriptions

* Comment update
2020-06-17 23:40:10 -04:00
Christopher Felegy
5227241ba5 ci: force dotnet restore to run without cache 2020-06-16 00:59:16 -04:00
Paulo
3325031f04 fix: AllowedMentions and AllowedMentionTypes (#1525)
* Give proper values to flag enum

* Add zero value

* Initialize lists

* Update xml docs
2020-06-16 00:45:19 -04:00
Christopher Felegy
3df05399ea nit: remove redundant CreateGuildRoleParams
CreateGuildRoleParams is identical to ModifyGuildRoleParams, so just use
the latter when creating new roles.
2020-06-15 00:29:16 -04:00
Bram
5430cc8df9 fix: Sending 2 requests instead of 1 to create a Guild role. (#1557)
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.
2020-06-15 00:11:05 -04:00
Paulo
a89f0761f4 feature: Add MESSAGE_REACTION_REMOVE_EMOJI and RemoveAllReactionsForEmoteAsync (#1544)
* Add event and method

* Simplify convert to IEmote
2020-06-15 00:04:34 -04:00
Joe4evr
42826df5e4 nit: minor refactor to switch expression (#1561) 2020-06-15 00:03:23 -04:00
Paulo
bd4672ae21 fix: InvalidOperationException at MESSAGE_CREATE (#1555)
## 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`
2020-06-15 00:02:51 -04:00
Paulo
57880de5b8 (ifcbrk) Add SearchUsersAsync (#1556) 2020-06-15 00:02:23 -04:00
Paulo
323a6775ee misc: MutualGuilds optimization (#1545)
* Check Dictionary

Check Dictionary instead of creating a new IReadOnlyCollection and looping in it

* Add Remark to MutualGuilds
2020-05-24 23:38:25 -04:00
Paulo
30b5a833d2 feature: Add GetUsersAsync to SocketGuild (#1549)
* Add GetUsersAsync to SocketGuild

* Fix IGuild return

* Do not download unless needed
2020-05-24 23:37:21 -04:00
moiph
758578955e misc: update webhook regex to support discord.com (#1551)
* Updating webhook regex for discord.com

Updates webhook URL regex matching for discordapp.com and discord.com

* Fixing comment

* Whitespace
2020-05-24 23:36:05 -04:00
Matt Smith
a6c1e4c23f (ifcbrk) feature: news channel publishing (#1530)
* Added PublishAsync to Messages.

* Added missing implementation.

* 1. Aligned with naming standards
2. Clarified xml docs
3. Properly threw exceptions instead of failing silently.

* Additional documentation included.

* Removed un-needed comments.

Co-authored-by: Matt Smith <v-matsm@microsoft.com>
2020-05-20 17:28:23 -04:00
Paulo
91b270a0ce fix: handle GUILD_DELETE behavior correctly (#1542) 2020-05-20 17:25:49 -04:00
FiniteReality
08d9834e2c fix: Ensure resetAt is in the future
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.
2020-05-18 18:06:30 +01:00
FiniteReality
d294678ed5 fix: use UtcNow when computing reset tick 2020-05-18 16:48:56 +01:00
Joe4evr
0c16d2f538 misc: Use '??=' (rebased) (#1391)
Co-authored-by: Christopher Felegy <cfelegy@riseup.net>
2020-05-07 09:21:30 -04:00
TheKingEagle
03af8e0bb4 fix: Call GuildAvailableAsync for dispatch(GUILD_CREATE) case (#1473)
* 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;
2020-05-07 09:19:15 -04:00
Joe4evr
c68cc85895 feature: Add cache purging methods (#1478) 2020-05-07 09:16:57 -04:00
Arnav Borborah
b6c981227d docs: Use Timeout.Infinite instead of -1 so that intent is clearer (#1443) 2020-05-07 09:14:37 -04:00
Chris Johnston
89b6b7e1a5 feature: Include allowed mentions payload on message creation (#1455)
* 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
2020-05-07 09:13:57 -04:00
Paulo
f8b2b5627e fix: Move content check for ModifyMessage (#1503)
good catch, thanks!
2020-05-07 09:12:08 -04:00
NeKz
41543a8084 fix: Fix Deserialization in Audit Log Data Types (#1509)
* Get overwrite id and type from options

* Create overwrites via API model
2020-05-07 09:09:46 -04:00
NeKz
479e28358e feature: Implement missing audit log types (#1458)
* Implement missing audit log types

* Use IUser properties
2020-05-07 09:04:33 -04:00
Monica S
ed869bd78b [apibrk] change: Specify WebSocket close code (#1500)
* API breaking change: Specify WebSocket close code

Should fix #1479 and help overall with resuming sessions.

* Also try to resume on missed heartbeats
2020-04-25 12:12:57 +01:00
Yamboy1
6d8e216545 docs: Small typo in documentation (#1460) 2020-04-22 02:10:38 -04:00
Still Hsu
106f346ddb docs: 2020 April Documentation Maintenance (#1484)
* 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>
2020-04-22 02:04:10 -04:00
Min
1f01a2d1fa fix: nullcheck _shards before iterating (#1493) 2020-04-22 02:02:22 -04:00
Christopher Felegy
c637bab91a meta: bump to 2.3.0-dev 2020-04-16 21:48:45 -04:00
Christopher Felegy
8d9e9714f7 meta: bump version to 2.3.0-dev 2020-04-16 21:44:53 -04:00
Christopher Felegy
4b602b4517 meta: 2.2.0
free chick fil a for whomever writes the changelog
2020-04-14 20:53:05 -04:00
Christopher Felegy
6ed311bc73 meta: 2.2.0 2020-04-14 20:50:55 -04:00
Christopher Felegy
91aec9ff93 add idn debugger
where is my foxboat
2020-04-14 20:47:36 -04:00
Braedon Smith
adf823ca9a Added System.Linq reference (#1470)
Use of IReadOnlyCollection#Any requires a reference to System.Linq. It's a small thing, but better copy-paste-ability is never a bad thing.
2020-03-31 15:03:11 +01:00
NovusTheory
d734ce0a11 feature: Add ability to modify the banner for guilds (#1432) 2019-12-26 18:44:01 -05:00
Chris Johnston
a4846516fb fix: false-positive detection of CustomStatusGame based on Id property (#1416)
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.
2019-11-29 22:13:08 -05:00
Saulius Šaltenis
2bba324143 feature: add StartedAt, EndsAt, Elapsed and Remaining to SpotifyGame. (#1414)
* 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.
2019-11-29 22:11:48 -05:00
Chris Johnston
e627f0780a change: fix #1415 Re-add support for overwrite permissions for news channels (#1417)
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.
2019-11-29 22:07:43 -05:00
Chris Johnston
1c63fd479d (ifcbrk)fix: #1335 Add isMentionable parameter to CreateRoleAsync in non-breaking manner (#1418)
* 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
2019-11-29 21:59:11 -05:00
Mark
9ede6b905f docs: Fix incorrect and missing colour values for Color fields (#1426) 2019-11-29 21:58:04 -05:00
Chris Johnston
3ff4e3d506 fix: #1421 (in a better way) Return empty set when ActiveClients is null (#1422)
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.
2019-11-23 12:58:13 -05:00
Joe4evr
911523d56f docs: Fix the Comparer descriptions not linking the type (#1424) 2019-11-23 12:57:16 -05:00
Joe4evr
99d7135d09 nit: Utilize ValueTuples (#1393)
* Utilize ValueTuples (with polyfill)

* Rebase and remove polyfill
2019-11-09 14:58:49 -05:00
Chris Johnston
79a0ea9de3 Feature: CustomStatusGame Activity (#1406)
* Implement CustomStatusGame activity

Adds the CustomStatusGame class, which is the activity corresponding to the custom status feature.

* Remove unused import from Game.cs
2019-11-09 13:41:10 -05:00
Saulius Šaltenis
5439cbad5a fix: GetUsersAsync to use MaxUsersPerBatch const as limit instead of MaxMessagesPerBatch. (#1412)
Requests are now returning up to 1000 guild user entities instead of the previous 100.
2019-11-09 13:38:25 -05:00
Neuheit
f86c39de6a feature: Implemented Message Reference Property (#1413)
* 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.
2019-11-09 13:12:29 -05:00
Patrick Klaeren
7f0c0c9155 fix: add .NET Standard 2.1 support for Color (#1405)
* Add NETSTANDARD2_1 support for Color

* Remove all conditionals following PR
2019-10-25 23:38:41 +01:00
Christopher Felegy
fd204eeb7b ci: do not exit on failed robocopy 2019-10-24 17:08:35 -04:00
Christopher Felegy
a8cdadc0ec meta: copy only _site to docs-static 2019-10-24 16:59:21 -04:00