Commit Graph

2704 Commits

Author SHA1 Message Date
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
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
8d9e9714f7 meta: bump version to 2.3.0-dev 2020-04-16 21:44:53 -04:00
Christopher Felegy
6ed311bc73 meta: 2.2.0 2020-04-14 20:50:55 -04: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
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
Chris Johnston
007b011f12 Cache regex instances in MessageHelper (#1403) 2019-10-24 15:52:45 +01:00
JT
d199d93ae4 meta: Fix .NET Core 3.0 compatibility + Drop NS1.3 (#1382)
* Update all dependencies and deal with warning/errors

* Add updated AsyncEnumerable implementation

* Fix broken target

* Cleanup

* Remove obsolete message

* typo

* Update azure pipelines

* Update samples to .NET Core 3.0

* Pull out test change

* Install the .net core 3 SDK on the ubuntu image for the time being

* Target net core 3 for the unit tests because pipelines
2019-10-22 22:50:12 -04:00
Chris Johnston
a61adb07e0 feature: #1381 Guild PreferredLocale support (#1387)
* Fix #1381 Guild PreferredLocale support

Adds support for getting and modifying a guild's preferred_locale. This is a language tag in IETF BCP 47 format, which works with the built-in CultureInfo.

While Discord only supports a number of cultures, I think that this restriction should be handled at the API and not by the wrapper. (Also easier on our end)

* Add PreferredCulture to IGuild

This property was defined in RestGuild and SocketGuild, so it only makes sense to make it part of IGuild as well.
2019-10-22 22:46:41 -04:00
Joe4evr
0bda8a4217 fix: patch todo in NamedTypeReader (#1392) 2019-10-03 16:35:48 -04:00
Kieran Boyle
0d54207a27 feature: support guild subscription opt-out (#1386) 2019-10-01 15:51:02 -04:00
Still Hsu
fd3810e9fe docs: September 2019 Documentation Update (#1379)
* docs: adjust wording of ActivityType.Watching enum

Adjusts the xmldoc summary wording of the ActivityType.Watching enum to
fix a wording issue.

* Add D.NET Logo to Open Graph meta tags

* Update DescriptionGenerator
...And update color to suit the logo better

* Disable smooth scrolling due to user complaints

* Remove unnecessary spacing in sideaffix

* Update footer version

* Remove featherlight plugin

As it is unnecessary and can break image tags

* Adjust wordings regarding safe-handling of secrets

* Fix formatting for first bot token sample

* Add badges to homepage

* Minor wording fixes on terminal

* Update to higher quality PNG

* Add Discord.Net.Example in sln for build validation

* Clarify all instances of IAsnycEnumerable

* Clarify overridden props in SocketNewsChannel

* Add returns and params docs for SyncPermissionsAsync

* Remove/fix invalid XMLdoc strings

* Remove AppVeyor and add GitHub badge
2019-09-22 19:06:57 -04:00
Christopher F
7b9029dd91 feature: support X-RateLimit-Reset-After (#1372)
* feature: support X-RateLimit-Reset-After

Users may now optionally disable using the system clock to calculate
the ratelimit duration. This may be overrided globally, via
DiscordConfig, or per RequestOptions.

This change has been built and tested via the integrated test suite,
but has not been tested in the real world. Please verify this does not
break any of the edge-case ratelimits.

* patch: wire new config properties to ApiClient

* patch: update Reset-After parsing precision

This patch applies the changes made to parsing precision in 606dac3.
2019-09-21 09:24:37 -04:00
Chris Johnston
68eb71c175 (binbrk)feature: Support filtering audit log entries on user, action type, and before entry id (#1377)
* Support filtering audit log entries on user, type, and before id

Adds support for filtering audit log entires with GetAuditLogsAsync. Adds the ability to specify a userId and ActionType to filter. Exposes the beforeId filter which was already implemented, yet unused (even when requesting > 100 entries)?

Was thinking that this could expose overloads of GetAuditLogAsync that accepts a IUser and IAuditLogEntry, but dealing with all the combinations of these types may be excessive.

* use only stringbuilder for args instead of string interpolation
2019-09-20 18:36:02 -04:00
NeKz
c54867feba feature: update audit log models (#1373)
* Fix bugs

* Add missing properties

* Add missing properties to ChannelInfo

Remove UserLimit property

* Add missing properties to GuildInfo

Change ContentFilterLevel of type int? to ExplicitContentFilter of type ExplicitContentFilterLevel?

* Remove AvatarHash from MemberInfo

* Add missing doc comments

* Make ExplicitContentFilter public

* Add ChannelId property to overwrite audits

* Update doc comments based on feedback
2019-09-20 18:29:11 -04:00
Chris Johnston
606dac3e1a fix: Use double precision for X-Reset-After, set CultureInfo when parsing numeric types (#1375)
* Parse double for X-Reset-After instead of float, needs more precision

Float did not contain enough precision to store the millisecond unix
time value, which resulted in the second and millisecond values being
slightly off.

This can be easily tested using:

```cs
> DateTimeOffset.FromUnixTimeMilliseconds((long)(1470173022.123f *
1000)).Millisecond
160 // wrong

> DateTimeOffset.FromUnixTimeMilliseconds((long)(1470173022.123 *
1000)).Millisecond
123 // correct
```

* Parse RateLimit-Reset using an IFormatProvider

* State NumberStyle and use CultureInfo.InvariantCulture for any parsing

This updates most occurances in the code where a Parse or TryParse method was used to explicitly state the NumberStyle, and to use CultureInfo.InvariantCulture.
CultureInfo was used over NumberInfo, as it also works on DateTime parsing too.

* Use default format spec in Commands
2019-09-14 16:38:26 +00:00
Adam Gauthier
3755a027b3 feature: Provide ParameterInfo with error ParseResult (#1355)
Currently, when handling parsing errors, there is no way to know what
parameter caused the error. This change makes the CommandParser create
the parsing error with the current parameter info when ParseAsync()
fails. It is then available through the ErrorParameter of the
ParseResult.
2019-09-08 22:06:19 +00:00
Radka Janeková
b00da3d73c feature: add the "Stream" permission. (#1357) 2019-09-08 16:23:03 +00:00
Christopher Felegy
bcb3534195 change: use millisecond precision by default
this is More Precise and will allow us to handle ratelimits Much Easier
2019-09-08 11:28:27 -04:00
Chris Johnston
9482204bcf feature: Add support for setting X-RateLimit-Precision (#1354)
* support X-RateLimit-Reset sending integer or float values

This changes the way that the X-RateLimit-Request header is parsed, so that it will work with both integer seconds and float values with seconds and milliseconds

* Add RateLimitPrecision enum, set X-RateLimit-Precision

Adds the RateLimitPrecision enum, with Second and Millisecond values. (Do we want to use an extension method to convert it into a string, or is ToString().ToLower() fine?)
Adds RateLimitPrecision as a parameter to DiscordRestApiClient, and to DiscordConfig so that it can set the X-RateLimit-Precision header.
2019-09-08 15:21:10 +00:00
Chris Johnston
07f4d5f353 [abibrk] change: Update ISystemMessage interface to allow reactions (#1368)
* Move reaction methods of IUserMessage to IReactionMessage

Moves the reaction-related methods contained in IUserMessage to the IReactionMessage type. Updates the type of ISystemMessage so that it implements IReactionMessage.

* Move rest reaction implementation to RestReactionMessage

Copies the reaction implementation from RestUserMessage to RestReactionMessage. Updates RestUserMessage and RestSystemMessage to be derived from RestReactionMessage instead of RestMessage.

* Move WS reaction implementation to SocketReactionMessage

Copies the reaction implementation from SocketUserMessage into SocketReactionMessage. Updates SocketSystemMessage and SocketUserMessage to use SocketReactionMessage as the base class.

* docs: update summary for ReactionMessage classes

* Remove ReactionMessage types, move reaction impl to IMessage

Removes the IReactionMessage and derived types, which was unnecessary since all classes derived from IReactionMessage were IMessage.

Moves the reaction implementation to IMessage and derived types.
2019-09-08 15:18:52 +00:00
Christopher Felegy
dcd9cdd13e lint: rename IsStream to IsStreaming
While it might be more proper to refer to a voice state as composing
a stream (i.e., the IVoiceState is a Stream), this property is ported
up most often to actual user entities. It makes more sense to
communicate that the user is streaming, rather than stating that the
user itself is a stream.

This is also more gramatically consistent with the other voice state
properties (e.g., IsMuted). Movement from noun-form to participle-form
remains inline with the past-participle form used on the other
properties.
2019-09-07 22:19:26 +00:00
Chris Johnston
9bb08c9ba4 feature: Add SelfStream voice state property (#1369)
* Add self_stream voice state property

Adds the self_stream property which is set true when a user is streaming a video to a voice channel

* use flags for selfstream state instead of its own prop
2019-09-08 02:08:40 +00:00
NeKz
b0a595be77 fix: Fix keys of guild update audit (#1371) 2019-09-08 02:05:10 +00:00
Chris Johnston
c977f2ec9c fix: #1314 Don't parse tags within code blocks (#1318)
* implement a fix for tags being found in code blocks

still needs polish, consider this a rough draft

* refactor to reuse a local function

uses CheckWrappedInCode to check that there are no code blocks that surround the tag being parsed

* Add more test coverage of MessageHelper.ParseTags

* reset indexes for @ here mention

* add a test case to catch error fixed from prev commit

* wip commit of most test cases working

* fix the Enclosed in block util method

* code cleanup

* lint whitespace

* lint brackets for single line if blocks

* move messagehelpertests to the new unit test dir

* expose internals to the unit test project

this seems to have been breaking the build, since CI would build the merged branch, where rest wasn't exposed to the unit tests
2019-08-25 13:28:05 +00:00