emorell96
35e0d1068e
added a HttpClientFactoryRestClientProvider to avoid having to expose a HttpClientFactoryRestClient.
5 years ago
emorell96
c3fbbe118e
changed incorrect namespace.
5 years ago
emorell96
1108009fec
removed the extensions from here into a sample to avoid adding 2 new dependencies.
5 years ago
emorell96
0910d059d9
changed namespace from 04 to 05
5 years ago
emorell96
cd0afcbc44
modified the startup to use the new AddDiscordRestClient which takes a client id and a client secret
5 years ago
emorell96
d89f1acc96
moved the service extensions to the sample to avoid addind 2 dependencies.
5 years ago
emorell96
9eb7026fe2
change namespace to 05
5 years ago
emorell96
64514661a7
added ClientId, and ClientSecret. They default to null to avoid incompatibilities with previous code.
5 years ago
emorell96
44ac70a77a
added the clientId, and clientSecret parameters to the construction of the DiscordRestApiClient
5 years ago
emorell96
b4057669fa
added a GetTokenAsync method that calls the Api method, and transform the raw Api Token to a RestToken.
5 years ago
emorell96
2075146506
implemented the SendAsync that takes IEnumerable<KeyValuePair<string?, string?>> in order to create a FormUrlEncodedContent and send the request with UrlEncoded content.
5 years ago
emorell96
56f21bbe3a
Added ClientId and ClientSecret to the library. These can be left null without any effect to the rest of the library. Just don't expect the refresh methods to work.
Added SendFormAsync in order to send url encoded content. It uses the bucket system all the oder SendAsync methods use.
Added a GetTokenAsync method. This method is used to get either a token from a code, or a token from a refresh token. It raises an error if given any other kind of tokens.
5 years ago
emorell96
05717cf93e
new FormRestRequest used for sending form data in url encoded format.
5 years ago
emorell96
0dc8416dbe
created a public RestToken object that is used when providing tokens to the user.
5 years ago
emorell96
ef9e66cbe5
added a token object to be read from Discord's token endpoint.
5 years ago
emorell96
0b13e0efa1
added 2 token types: refresh and code. Refresh is a refresh token, code is the code given by discord authorization code flow.
5 years ago
emorell96
c242d81af9
added a SendAsync method to IRestClient that takes an IEnumerable<KeyValuePair<string?, string?>> in order to be able to form a FormUrlEncodedContent which you need for getting the tokens.
5 years ago
emorell96
37514e9102
removed some pages in the blazor project.
5 years ago
emorell96
2ec1ed72b0
added showcasing for the refresh token methods.
5 years ago
emorell96
1c664060ab
removed some part of the blazor sample.
5 years ago
emorell96
b6ed3dd314
removed the provider since it's useless now, fixed the build break. Forgot to rename in the sample AddScoped... to AddDiscordRestClient().
5 years ago
emorell96
07bc947548
modified the ServicesCollectionExtentions to only add Singleton DiscordRestClient so that the DiscordRestClient is a singleton and we do not lose the rate limiter but the HttpClient is still regenareted every time the provider is called through the IHttpClientFactory instead of using new HttpClient(new HttpClientHandler).
5 years ago
emorell96
552e70a937
modified the extension methods to not use the HttpClientFactoryRestClientProvider since it's unnecessary, I can just use a delegate in the the config pointing to the HttpClientFactoryRestClient.
5 years ago
emorell96
1d8df45450
added documentation using .net conventions.
5 years ago
emorell96
8137ca1eca
added documentation to this method.
5 years ago
emorell96
67ace364a4
changed AddTransient to AddScoped when adding HttpClientFactoryRestClientProvider as a service in the AddScopedDiscordRestClient to stay consistent. AddScopedDiscordRestClient adds scoped services, AddTransientDiscordRestClient adds transient services.
5 years ago
emorell96
1c31bc8abe
renamed names to follow convention HttpClientFactory + RestClient or RestClientProvider.
5 years ago
emorell96
67d833a8b5
removed modifications made to this project while thinking of how to implement my changes.
5 years ago
emorell96
75c1e41a63
added the blazor simple sample with the new IServiceCollection extension usage example. Hopefully it shows what I mean of how much it simplifies handling DI with the library. I think the greatest benefits are the user could use polly or it could be integrated dirrectly into the library, or also for thing like ASP.NET projects where usually you'd use ScopedServices for each page, you could inject a DiscordRestClient safely.
5 years ago
emorell96
b745a3cd6d
Added two Extension methods "AddScopedDiscordRestClient" and "AddTransientDiscordRestClient" to allow for easier addition of scoped, and transient DiscordRestClients, it's left up to the user which one is more convenient to use for his/her application, and at the end of the day it doesn't risk running out of sockets since it uses IHttpClientFactory under the hood.
This means that it moves the useProxy boolean parameter here, not sure how much that affects the rest of the library. def an addition to consider. And something that more accustomed users/contributors will be able to answer.
The main advantage of having such a method in the future could be adding resiliency. Major resiliency by for example using Polly in a simple way see: https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly for example.
Of course this means that the user would have to use DI (which is anyways a good practice), but I left the other default ones so that it wouldn't bring any breaking changes.
5 years ago
emorell96
7ce31408be
added a dependency in Microsoft.Extensions.DependencyInjection.Abstractions and Microsoft.Extensions.Http to add an extension method to make it easy to add DiscordRestClients without risking socket exhaustation.
5 years ago
emorell96
87f530c2f1
added a HttpClientFactoryClient and HttpClientFactoryClientProvider that use IHttpClientFactory to create HttpClients to avoid having to recreate an HtppClient every time a DiscordRestClient is created which could lead to socket exhaustation.
5 years ago
emorell96
dc589653df
added simple blazor project as a sample using only Discord.Net.Core and Discord.Net.Rest. No websockets.
5 years ago
Paulo
1b64d19c84
meta: 2.3.1 ( #1795 )
5 years ago
Paulo
d41aeee4fe
fix: Audit log UserId can be null ( #1794 )
5 years ago
Alex Gravely
d2518db9a8
fix: Update Webhook ChannelId from model change ( #1791 )
5 years ago
Paulo
51b7afe2a6
misc: Add remark regarding CustomStatus as the activity ( #1774 )
* Throw exception with CustomStatus
* Add remark instead of exception
* Change wording
5 years ago
NeKz
f794163ffa
fix: NullReferenceException in pin/unpin audit logs ( #1780 )
5 years ago
NeKz
6ac5ea1cbb
fix: Add ChannelType property to ChannelInfo audit log ( #1786 )
5 years ago
Antonio Zdravkov Nikolov
0fc713a897
fix: Private methods aren't added as commands ( #1773 )
Fix breaking change introduced by #1521
5 years ago
Yeba
73e5cc2fbc
fix: Deadlock in DiscordShardedClient when Ready is never received ( #1761 )
* fixed a deadlock in DiscordShardedClient during a failed Identify due to InvalidSession
* fixed log
* Don't wait ready before releasing semaphore
Co-authored-by: Paulo <pnmanjos@hotmail.com>
5 years ago
Paulo
83e88f4fb9
meta: Bump version to 2.3.1-dev
5 years ago
Paulo
6bb54577ab
meta: 2.3.0
5 years ago
Paulo
2095701665
fix: Missing MessageReference when sending files
5 years ago
quinchs
8b25c9bbfb
feature: Add GuildUser IsPending property ( #1731 )
* Implemented Pending property
* Implemented changes
5 years ago
Paulo
225550dc5a
feature: Add MessageFlags and AllowedMentions to message modify ( #1724 )
* feature: Add MessageFlags and AllowedMentions to Modify
* Change exception message
5 years ago
Paulo
c683b2901d
feature: Add user public flags ( #1722 )
5 years ago
Paulo
6a62c4770c
feature: Add role tags ( #1721 )
5 years ago
Paulo
5934c7949a
misc: VoiceRegions and related changes ( #1720 )
5 years ago
Paulo
4a7f8fec93
fix: Move and fix internal AllowedMentions object ( #1727 )
5 years ago