This resolves#987
Previous behavior was that even if `null` was passed for an embed in
UploadFileAsync, the Embed property on UploadFileArgs was still
specified - this meant we were always sending a payload_json.
If a payload_json is specified, it seems like Discord will only read
from the payload_json, and will ignore properties set outside of it.
To prevent unnecessary code duplication, this commit always specifies
parameters in the payload_json, and also will only include the embed if
one was actually specified with real data (not null).
* UnixTimestampConverter should now obey a maximum value
This change prevents an issue where the converter would be unable to
handle obscenely large timestamp values - which are actually quite
common on Discord.
OptionalConverter had to be rewritten to support checking whether or not
an InnerConverter returned an Optional. The perf impacts from this
_shouldn't_ be too bad, as types without a custom parser (which should
be the majority of Optionals in the lib) will bypass the type-check.
* optimizations on OptionalConverter
- Add a helper under CDN for cover art URLs
It would be bad practice of us to leave CDN urls hardcoded in the
deserializer, would be harder to change down the line should Spotify
ever change their CDN.
I'm not entirely supportive of leaving Spotify's CDN hardcoded in our lib
either, but there's no better alternative.
- Change SpotifyGame#Artists to an IEnumerable<string>
Seems pretty common to prefer IEnumerables in place of Arrays.
* Initial Spotify support
* Remove GameAsset#ToEntity
- appId doesn't seem to be necessary, and Spotify Game doesn't return appId either.
* Implement SpotifyGame details
* Implement song Duration prop
* Add album art CDN
* Fix ActivityType
* Remove payload debug
* Add changes according to review
+ Make `ApplicationId` nullable
+ Move ctor after props
Previously it was implemented under Discord.Net.Rest, which seems
inconsistent and unnecessary.
This also allows Commands docstrings to reference EmbedBuilder, since
Commands only has a dependency on Core.
To reply with just a rich embed, users have to invoke ReplyAsync with
`ReplyAsync("", embed: embed)`, which seems wasteful, when they only
need to specify the embed.
In f19730e4, AddModule(s)Async was changed so that the IServiceProvider
was optional, both at compile time and runtime. This had the side effect
of meaning that there was no longer a compile-time hint that users would
need to pass an IServiceProvider to AddModulesAsync. I assumed this
would not be an issue - users would recognize the runtime exception here
and self correct - but activity in our Discord support channel would
indicate otherwise.
We now require the user to explicitly opt-out of dependency injection -
they are still free to pass null in place of an IServiceProvider if they
do not intend to use one, and the library will handle this at runtime.
* Move REST requests to appropiate class
* Add call to ClientHelper and expose to public API
* Expose shard count request in public api
* Expose method from interface
* Update sharded client to utilize the new method
* Method is already implemented in a base class
* Refactor name to fit pattern for methods returning a `Task`
* Adds missing ConfigureAwait
* Corrects unnecessary whitespace
* Removes unneeded whitespace
commit a8bafb90cd
Merge: f38dd4c47e04285e
Author: WamWooWam <wamwoowam@gmail.com>
Date: Mon Mar 12 08:05:52 2018 +0000
Merge branch 'dev' of https://github.com/WamWooWam/Discord.Net into dev
commit f38dd4c421
Author: WamWooWam <wamwoowam@gmail.com>
Date: Mon Mar 12 08:05:49 2018 +0000
Cleaned up & fixed code style.
commit 7e04285e5d
Author: Thomas May <wamwoowam@gmail.com>
Date: Sun Mar 11 14:11:28 2018 +0000
Revert changes to DefaultRestClient
Didn't actually need to change this, whoops.
commit 3f5b2c8ef1
Author: WamWooWam <wamwoowam@gmail.com>
Date: Sat Mar 10 19:30:44 2018 +0000
Enabled embeds alongside uploaded files.
God damn Discord is a mess.
Co-authored-by: WamWooWam <wamwoowam@gmail.com>
IServiceProvider does not support scopes by itself - this is a behavior
introduced by Microsoft's DI container. As such, not all DI containers
may support an IScopeFactory the way that Microsoft's DI is expecting
them to.
This also means that our builtin EmptyServiceProvider does not support
scopes - meaning that users who do not use a DI container can not invoke
commands.
This prevents an issue where no clients could be constructed.
In 2fd4f56, the case for user tokens was removed from GetPrefixedToken,
which means that the default value for TokenType would now fallthrough
to the default case, which throws an error.
* Set usage of TokenType.User as an error rather than a warning.
* Remove commented sections and #pragma's
Additionally, changes use of ReadMessages to ViewChannel since that Obsolete was also suppressed by the pragma
If one is not passed, they will default to an EmptyServiceProvider
This resolves issues where since the merging of OnModuleBuilding, users
were effectively forced to use the DI pattern, where before they were
not.
While this isn't necessarily a bad idea, we shouldn't just change this
behavior for no reason (though I assume making the IServiceProvider
argument required was a mistake)
* Add tests for more Permissions code coverage
* Add guild tests
* Add more in-depth covering of permissions methods
* Add tests for OverwritePermissions
* Remove unknown ItemGroup tag from csproj
* Add missing Fact attributes, separate class so that it is not dependant on main test fixture
* Separate out GuildPermissions and ChannelPermissions tests from main partial Tests class because they do not need to have access to the main test fixture
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.
This fixes an issue where custom ModuleBases that contained a generic
parameter would be loaded as a module - only to fail when trying to be
built.
Realistically, ModuleBases _should_ be abstract - but it was still a bug
that we allowed them to be included as a module.