Commit Graph

72 Commits

Author SHA1 Message Date
Chris Johnston
9e9a11d4b0 Fix swapped parameters in ArgumentException, ArgumentNullException cstrs (#1139)
* Fix swapped parameters in ArgumentException and ArgumentNullException cstrs

The constructors of ArgumentException and ArgumentNullException are inconsistent with each other, which results in their parameters being swapped here and there.

* Use named parameters for ArgumentException constructors

Cleans up some of the methods of EmbedBuilder to use simpler syntax as well
2018-09-06 22:08:45 -04:00
Still Hsu
82cfdffc65 Add various optimizations and cleanups (#1114)
* Change all Select(... as ...) to OfType

* Add changes according to 194a8aa427
2018-08-30 17:36:44 -04:00
Chris Johnston
2de6cef18c Add validation to bot tokens based on string length (#1128)
* Add input validation for bot tokens based on their length

* Add token validation to BaseDiscordClient#LoginAsync

Adds a TokenUtils class which is used to validate that tokens are correct

* Revert changes to DiscordRestApiClient

* Add Unit tests to the TokenUtils class, fix a logic error that was caught by those tests

* Allow for API to throw exceptions

Moves the validation of tokens to be inside of LoginInternalAsync, and writes a Warning to the console when the supplied tokens are invalid
2018-08-30 17:27:37 -04:00
Hawx
bbbac85c46 Update Dependencies and support NS2.0 builds (#1046)
* Update deps, fix test warnings.

* Support ns2.0

* Fix typo

* Remove ns1.1 support

* Net.Http and Net.Websockets.Client are not needed in ns2.0

* Move to net46 per volt

* Remove ns1.3 constants
2018-05-25 08:14:28 -04:00
Finite Reality
32ebdd51f7 Correct impl. of HasFlag and ResolveChannel (#966)
HasFlag was checking if any of the flags were set, not the ones
specified, and ResolveChannel was still treating the ChannelPermission
enum as before it was changed to a bitflag.
2018-02-28 17:46:01 -05:00
Christopher F
05cd1ff85b Don't attempt to resolve permissions for invalid roles
This resolves #824.

Discord seems to have inconsistencies where a role can be deleted, but
there will still be a few users who still have it in their `role_ids`. I
was able to find this bug appearing in 11 members of a 10,000 member
guild, so it would make sense that this is relatively rare, and it's why
we hadn't noticed it previously.

Since our permission resolution code is implementation agnostic, it
operates on the user's RoleIds collection, which is what Discord sends
us directly, and is not vaidated against the member's guild.

In our permission resolution code, we make the assumption that Discord
will always be telling us the truth with regard to a member's
`role_ids`. This PR changes the behavior of permissions resolution to
instead verify that the guild was able to return a role before
attempting to resolve its permissions.
2018-01-14 19:39:26 -05:00
Joe4evr
b5e7548651 Comparers (#929)
* Add entity equality comparers

* Fix namespace #whoops

* Add Message comparer.

* Add comment explaining the specialized implementation

* Remove specialized implementation, as per feedback
2018-01-10 21:31:43 -05:00
Chris Johnston
edfbd055bb Fix #854 Added ViewChannel enum and property to channel permissions (#874)
* Fix #854 Added ViewChannel enum and property to channel permissions

* replaced usages of ChannelPermission#ReadMessages with ViewChannel

* rename parameter of ChannelPermissions constructor

* made OverwritePermissions#ReadMessages obsolete, use ViewChannel instead

* Fix #854 Added ViewChannel enum and property to channel permissions

replaced usages of ChannelPermission#ReadMessages with ViewChannel

rename parameter of ChannelPermissions constructor

made OverwritePermissions#ReadMessages obsolete, use ViewChannel instead

* renamed readMessages parameter in ChannelPermissions constructor and Modify

* fixed channel permission tests to use ChannelPermission enum instead of GuildPermission enum

* replaced usages of readmessages in channel permission tests

* resolve build warnings for permission tests
2018-01-06 22:35:17 -05:00
Christopher F
623d60fe51 Merge remote-tracking branch 'origin/dev' into dev 2017-11-06 20:41:08 -05:00
Christopher F
676be4081b Ignore messages with an ID of 0 when calculating age 2017-11-06 20:40:59 -05:00
enzosk8
da335b95c4 Fix general typos (#852) 2017-11-05 22:05:19 -05:00
Chris Johnston
f9963380a7 Proposed Solution for #674 Permissions Changes (#743)
* Initial commit of changes. Changed permissions from bitwise index to use bitwise flags instead. Modified relevant methods involved

* Revised enum value naming

* Added FlagsAttribute to ChannelPermission, GuildPermission

* Added comments per Joe4evr suggestion

* Added underlines to hex value digits for readability per Joe4evr suggestion

* updated names to better reflect actual permission names as per SubZero0 suggestion

* fix for 236775c2d8aca9481d6c51c674f5727f97adec04

* Replaced Math.Pow with left shift operator

* Cleaned up the formatting of ChannelPermission and GuildPermission enums to make it easier to read
2017-10-25 20:39:26 -04:00
Christopher F
506a6c96c9 Throw when attempting to add or remove a member's EveryoneRole (#781)
* Throw when attempting to add or remove a member's EveryoneRole

This resolves #780

* Removed braces
2017-08-17 02:59:58 -03:00
Christopher F
576a52cdc6 Restructure and replace emojis with a new emote system (#619) 2017-05-04 12:52:48 -03:00
RogueException
a306d83283 Added net45 TFM 2017-04-26 10:25:08 -03:00
Christopher F
431b7fbd9f Visual Studio C#7 suggestions 2017-04-23 15:23:06 -04:00
Christopher F
6000b15c4d C#7 TODOs 2017-04-23 15:13:31 -04:00
RogueException
e762dddfbb Added SnowflakeUtils 2017-04-19 14:50:33 -03:00
RogueException
8dfa0220c3 Prevent overlapping tags 2017-03-31 15:19:13 -03:00
RogueException
13d488f43b Added slow/deadlocked event handler detection 2017-03-31 00:35:20 -03:00
RogueException
bf0be82d15 Added IWebhookUser and MessageSource 2017-03-30 23:29:30 -03:00
RogueException
13b9b15cf0 Fixed DateTimeUtils on .Net Standard 1.1 2017-03-22 05:35:19 -03:00
RogueException
32cf7ba5e1 A few datetime fixes 2017-03-22 05:22:11 -03:00
RogueException
bc469cbb46 Process everyone permission overwrites before role 2017-03-18 11:33:38 -03:00
RogueException
5a6d6ee076 Fixed notempty precondition error message 2017-03-18 10:37:57 -03:00
RogueException
21959fe43c Fixed several permission issues 2017-03-18 10:36:37 -03:00
RogueException
cab41851ba Prevent duplicate GuildUnavailables 2017-03-13 22:14:30 -03:00
RogueException
1b0e47be42 Fixed SocketRole.CompareTo 2017-03-02 06:55:09 -04:00
Christopher F
5e1d84d918 Merge pull request #395 from LassieME/issue/359
Conflicts:
	src/Discord.Net.WebSocket/DiscordSocketClient.cs
2017-03-01 17:34:39 -05:00
Christopher F
66b7e0e7f0 Rename precondition to 'YoungerThanTwoWeeks' 2017-03-01 17:16:06 -05:00
Christopher F
4a18b321ea Change the minimum allowed message to 13d23h59m
Connection/API lag could cause messages right on the edge of 14 weeks to fail on Discord's end when they pass our checks.
2017-02-25 16:31:46 -05:00
Christopher F
607f478b9a Check that messages older than two weeks are not passed to bulk delete
This resolves #477
2017-02-23 17:39:10 -05:00
Sindre G. Langhus
ab60f63511 Changes HasValue in Cachable to constructor argument 2017-02-21 22:11:48 +09:00
RogueException
70e8cea6e2 Fixed order for permission resolving 2017-02-11 23:15:48 -04:00
Sindre Langhus
d8682a82b2 Change all signatures in the SocketClients to interfaces. 2017-02-03 15:04:54 +01:00
Sindre G. Langhus
2d67cf36ae Changed Id from a ulong to generic TId, as per discussion. 2017-02-02 13:52:38 +01:00
Christopher F
daf0ac9347 Added docstrings for Cacheable 2017-02-02 13:51:53 +01:00
Sindre G. Langhus
705d71875c Simplified PR, renamed Cached to Cacheable. 2017-02-02 13:51:53 +01:00
Sindre G. Langhus
959d49a26f renamed Cache to Cached, and refactored many events to use Cached 2017-02-02 13:51:35 +01:00
Sindre G. Langhus
05fcd5f076 First commit 2017-02-02 13:37:39 +01:00
RogueException
fe35400498 Cleanup 2017-01-24 11:42:28 -04:00
RogueException
e2934abe29 Made API models internal. Removed Discord.Net.API. 2017-01-01 23:28:42 -04:00
RogueException
8326d01f62 Isolated API definitions to their own library 2016-12-23 16:57:29 -04:00
RogueException
c102f52bfa Merge branch 'issue/379' into dev 2016-12-16 11:12:50 -04:00
RogueException
8f87b2cc71 Added support for .NET Standard 1.1 and 1.2 2016-12-16 05:52:46 -04:00
Christopher F
3fc043132b docstrings for modify params, minor bugfixes 2016-12-04 19:07:07 -05:00
RogueException
f56a1b653d Cleaned up Reactions PR 2016-11-27 00:55:01 -04:00
RogueException
b9eeac9105 Merge branch 'dev' into feature/reactions 2016-11-27 00:30:46 -04:00
RogueException
2c990f08f8 Readded fluent-style to EmbedBuilder 2016-11-18 08:33:34 -04:00
RogueException
593ba46f1c Cleaned up command builders and async func names 2016-11-18 08:18:00 -04:00