diff --git a/src/Discord.Net.Rest/Extensions/ServiceCollectionExtensions.cs b/src/Discord.Net.Rest/Extensions/ServiceCollectionExtensions.cs index 57ce68b59..7b4123145 100644 --- a/src/Discord.Net.Rest/Extensions/ServiceCollectionExtensions.cs +++ b/src/Discord.Net.Rest/Extensions/ServiceCollectionExtensions.cs @@ -22,7 +22,7 @@ namespace Discord.Rest.Extensions /// This is the IServiceCollection where all the services are located. /// Set this to true to use proxies, default is false. /// - public static IServiceCollection AddScopedDiscordRestClient(this IServiceCollection services, bool useProxy = false) + public static IServiceCollection AddDiscordRestClient(this IServiceCollection services, bool useProxy = false) { services.AddHttpClient("HttpClientFactoryRestClientProvider") .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler @@ -35,37 +35,7 @@ namespace Discord.Rest.Extensions //services.AddScoped(provider => new HttpClientFactoryRestClientProvider(provider.GetRequiredService())); - services.AddScoped(provider => - { - var config = new DiscordRestConfig - { - RestClientProvider = url => new HttpClientFactoryRestClient(url, provider.GetRequiredService().CreateClient("HttpClientFactoryRestClientProvider"), useProxy) - }; - return new DiscordRestClient(config); - }); - - return services; - } - /// - /// Adds the DiscordRestClient as a Transient Service to be able to use through DI. - /// - /// This is the IServiceCollection where all the services are located. - /// Set this to true to use proxies, default is false. - /// - public static IServiceCollection AddTransientDiscordRestClient(this IServiceCollection services, bool useProxy = false) //where should we put this useProxy options, I haven't fully understood where the original code takes this from. - { - services.AddHttpClient("HttpClientFactoryRestClientProvider") - .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler - { - AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, - UseCookies = false, - UseProxy = useProxy, - }); - - - - //services.AddTransient(provider => new HttpClientFactoryRestClientProvider(provider.GetRequiredService())); - services.AddTransient(provider => + services.AddSingleton(provider => { var config = new DiscordRestConfig {