diff --git a/Discord.Addons.Hosting/ServiceCollectionExtensions.cs b/Discord.Addons.Hosting/ServiceCollectionExtensions.cs index 01a7e48..e2155c5 100644 --- a/Discord.Addons.Hosting/ServiceCollectionExtensions.cs +++ b/Discord.Addons.Hosting/ServiceCollectionExtensions.cs @@ -34,12 +34,12 @@ public static class ServiceCollectionExtensions /// Adds and optionally configures a along with the required services. /// /// - /// A is supplied so you can pull data from additional services if required. + /// A is supplied, so you can pull data from additional services if required. /// /// The service collection to configure. /// The delegate for the that will be used to configure the host. /// Thrown if client is already added to the service collection - public static void AddDiscordShardedHost(this IServiceCollection collection, Action config) + public static IServiceCollection AddDiscordShardedHost(this IServiceCollection collection, Action config) { collection.AddDiscordHostInternal(config); @@ -47,18 +47,20 @@ public static void AddDiscordShardedHost(this IServiceCollection collection, Act throw new InvalidOperationException("Cannot add more than one Discord Client to host"); collection.AddSingleton(); + + return collection; } /// /// Adds and optionally configures a along with the required services. /// /// - /// A is supplied so you can pull data from additional services if required. + /// A is supplied, so you can pull data from additional services if required. /// /// The host builder to configure. /// The delegate for the that will be used to configure the host. /// Thrown if client is already added to the service collection - public static void AddDiscordHost(this IServiceCollection builder, Action config) + public static IServiceCollection AddDiscordHost(this IServiceCollection builder, Action config) { builder.AddDiscordHostInternal(config); @@ -66,6 +68,8 @@ public static void AddDiscordHost(this IServiceCollection builder, Action(); + + return builder; } private static void AddDiscordHostInternal(this IServiceCollection collection, Action config) where T: BaseSocketClient @@ -96,19 +100,19 @@ static bool ValidateToken(string token) /// /// The service collection to configure. /// Thrown if is already added to the collection - public static void AddCommandService(this IServiceCollection collection) => collection.AddCommandService((context, config) => { }); + public static IServiceCollection AddCommandService(this IServiceCollection collection) => collection.AddCommandService((context, config) => { }); /// /// Adds a instance to the host for use with a Discord.NET client. /> /// /// - /// A is supplied so you can pull data from additional services if required. + /// A is supplied, so you can pull data from additional services if required. /// /// The service collection to configure. /// The delegate for configuring the that will be used to initialise the service. /// Thrown if config is null /// Thrown if is already added to the collection - public static void AddCommandService(this IServiceCollection collection, Action config) + public static IServiceCollection AddCommandService(this IServiceCollection collection, Action config) { ArgumentNullException.ThrowIfNull(config); @@ -119,6 +123,8 @@ public static void AddCommandService(this IServiceCollection collection, Action< collection.AddSingleton(); collection.AddHostedService(); + + return collection; } /// @@ -126,20 +132,20 @@ public static void AddCommandService(this IServiceCollection collection, Action< /// /// The service collection to configure. /// Thrown if is already added to the collection - public static void AddInteractionService(this IServiceCollection collection) => collection.AddInteractionService((_, _) => { }); + public static IServiceCollection AddInteractionService(this IServiceCollection collection) => collection.AddInteractionService((_, _) => { }); /// /// Adds a instance to the host for use with a Discord.NET client. /> /// /// - /// A is supplied so you can pull data from additional services if required. + /// A is supplied, so you can pull data from additional services if required. /// /// The service collection to configure. /// The delegate for configuring the that will be used to initialise the service. /// Thrown if config is null /// Thrown if is already added to the collection - public static void AddInteractionService(this IServiceCollection collection, Action config) + public static IServiceCollection AddInteractionService(this IServiceCollection collection, Action config) { ArgumentNullException.ThrowIfNull(config); @@ -150,6 +156,7 @@ public static void AddInteractionService(this IServiceCollection collection, Act collection.AddSingleton(); collection.AddHostedService(); - + + return collection; } -} \ No newline at end of file +}