diff --git a/src/Commands/BanCommandGroup.cs b/src/Commands/BanCommandGroup.cs index f0da978..bbcf459 100644 --- a/src/Commands/BanCommandGroup.cs +++ b/src/Commands/BanCommandGroup.cs @@ -33,12 +33,12 @@ public class BanCommandGroup : CommandGroup private readonly IDiscordRestGuildAPI _guildApi; private readonly GuildDataService _guildData; private readonly IDiscordRestUserAPI _userApi; - private readonly UtilityService _utility; + private readonly Utility _utility; public BanCommandGroup( ICommandContext context, IDiscordRestChannelAPI channelApi, GuildDataService guildData, IFeedbackService feedback, IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi, - UtilityService utility) + Utility utility) { _context = context; _channelApi = channelApi; diff --git a/src/Commands/ClearCommandGroup.cs b/src/Commands/ClearCommandGroup.cs index 7ebd4ea..1d0ad64 100644 --- a/src/Commands/ClearCommandGroup.cs +++ b/src/Commands/ClearCommandGroup.cs @@ -30,11 +30,11 @@ public class ClearCommandGroup : CommandGroup private readonly IFeedbackService _feedback; private readonly GuildDataService _guildData; private readonly IDiscordRestUserAPI _userApi; - private readonly UtilityService _utility; + private readonly Utility _utility; public ClearCommandGroup( IDiscordRestChannelAPI channelApi, ICommandContext context, GuildDataService guildData, - IFeedbackService feedback, IDiscordRestUserAPI userApi, UtilityService utility) + IFeedbackService feedback, IDiscordRestUserAPI userApi, Utility utility) { _channelApi = channelApi; _context = context; diff --git a/src/Commands/KickCommandGroup.cs b/src/Commands/KickCommandGroup.cs index cad8ea9..ee94b93 100644 --- a/src/Commands/KickCommandGroup.cs +++ b/src/Commands/KickCommandGroup.cs @@ -30,12 +30,12 @@ public class KickCommandGroup : CommandGroup private readonly IDiscordRestGuildAPI _guildApi; private readonly GuildDataService _guildData; private readonly IDiscordRestUserAPI _userApi; - private readonly UtilityService _utility; + private readonly Utility _utility; public KickCommandGroup( ICommandContext context, IDiscordRestChannelAPI channelApi, GuildDataService guildData, IFeedbackService feedback, IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi, - UtilityService utility) + Utility utility) { _context = context; _channelApi = channelApi; diff --git a/src/Commands/MuteCommandGroup.cs b/src/Commands/MuteCommandGroup.cs index 6a28f38..522c7f7 100644 --- a/src/Commands/MuteCommandGroup.cs +++ b/src/Commands/MuteCommandGroup.cs @@ -32,11 +32,11 @@ public class MuteCommandGroup : CommandGroup private readonly IDiscordRestGuildAPI _guildApi; private readonly GuildDataService _guildData; private readonly IDiscordRestUserAPI _userApi; - private readonly UtilityService _utility; + private readonly Utility _utility; public MuteCommandGroup( ICommandContext context, GuildDataService guildData, IFeedbackService feedback, - IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi, UtilityService utility) + IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi, Utility utility) { _context = context; _guildData = guildData; diff --git a/src/Commands/SettingsCommandGroup.cs b/src/Commands/SettingsCommandGroup.cs index 15fd514..ce7472f 100644 --- a/src/Commands/SettingsCommandGroup.cs +++ b/src/Commands/SettingsCommandGroup.cs @@ -57,11 +57,11 @@ public class SettingsCommandGroup : CommandGroup private readonly IFeedbackService _feedback; private readonly GuildDataService _guildData; private readonly IDiscordRestUserAPI _userApi; - private readonly UtilityService _utility; + private readonly Utility _utility; public SettingsCommandGroup( ICommandContext context, GuildDataService guildData, - IFeedbackService feedback, IDiscordRestUserAPI userApi, UtilityService utility) + IFeedbackService feedback, IDiscordRestUserAPI userApi, Utility utility) { _context = context; _guildData = guildData; diff --git a/src/Octobot.cs b/src/Octobot.cs index 1806330..5cffd70 100644 --- a/src/Octobot.cs +++ b/src/Octobot.cs @@ -87,7 +87,7 @@ public sealed class Octobot .AddPostExecutionEvent() // Services .AddSingleton() - .AddSingleton() + .AddSingleton() .AddHostedService() .AddHostedService() .AddHostedService() diff --git a/src/Responders/GuildLoadedResponder.cs b/src/Responders/GuildLoadedResponder.cs index 2d66a3b..a1e7d16 100644 --- a/src/Responders/GuildLoadedResponder.cs +++ b/src/Responders/GuildLoadedResponder.cs @@ -25,11 +25,11 @@ public class GuildLoadedResponder : IResponder private readonly GuildDataService _guildData; private readonly ILogger _logger; private readonly IDiscordRestUserAPI _userApi; - private readonly UtilityService _utility; + private readonly Utility _utility; public GuildLoadedResponder( IDiscordRestChannelAPI channelApi, GuildDataService guildData, ILogger logger, - IDiscordRestUserAPI userApi, UtilityService utility) + IDiscordRestUserAPI userApi, Utility utility) { _channelApi = channelApi; _guildData = guildData; diff --git a/src/Services/GuildDataService.cs b/src/Services/GuildDataService.cs index 3cc8cea..961c8f9 100644 --- a/src/Services/GuildDataService.cs +++ b/src/Services/GuildDataService.cs @@ -11,7 +11,7 @@ namespace Octobot.Services; /// /// Handles saving, loading, initializing and providing . /// -public sealed class GuildDataService : IHostedService +public sealed class GuildDataService { private readonly ConcurrentDictionary _datas = new(); private readonly ILogger _logger; @@ -24,16 +24,6 @@ public sealed class GuildDataService : IHostedService lifetime.ApplicationStopping.Register(ApplicationStopping); } - public Task StartAsync(CancellationToken ct) - { - return Task.CompletedTask; - } - - public Task StopAsync(CancellationToken ct) - { - return Task.CompletedTask; - } - private void ApplicationStopping() { SaveAsync(CancellationToken.None).GetAwaiter().GetResult(); diff --git a/src/Services/Update/MemberUpdateService.cs b/src/Services/Update/MemberUpdateService.cs index 8937833..06e531f 100644 --- a/src/Services/Update/MemberUpdateService.cs +++ b/src/Services/Update/MemberUpdateService.cs @@ -30,10 +30,10 @@ public sealed partial class MemberUpdateService : BackgroundService private readonly IDiscordRestGuildAPI _guildApi; private readonly GuildDataService _guildData; private readonly ILogger _logger; - private readonly UtilityService _utility; + private readonly Utility _utility; public MemberUpdateService(IDiscordRestChannelAPI channelApi, IDiscordRestGuildAPI guildApi, - GuildDataService guildData, ILogger logger, UtilityService utility) + GuildDataService guildData, ILogger logger, Utility utility) { _channelApi = channelApi; _guildApi = guildApi; diff --git a/src/Services/Update/ScheduledEventUpdateService.cs b/src/Services/Update/ScheduledEventUpdateService.cs index dd9be0d..ac5c109 100644 --- a/src/Services/Update/ScheduledEventUpdateService.cs +++ b/src/Services/Update/ScheduledEventUpdateService.cs @@ -19,10 +19,10 @@ public sealed class ScheduledEventUpdateService : BackgroundService private readonly IDiscordRestGuildScheduledEventAPI _eventApi; private readonly GuildDataService _guildData; private readonly ILogger _logger; - private readonly UtilityService _utility; + private readonly Utility _utility; public ScheduledEventUpdateService(IDiscordRestChannelAPI channelApi, IDiscordRestGuildScheduledEventAPI eventApi, - GuildDataService guildData, ILogger logger, UtilityService utility) + GuildDataService guildData, ILogger logger, Utility utility) { _channelApi = channelApi; _eventApi = eventApi; diff --git a/src/Services/UtilityService.cs b/src/Services/Utility.cs similarity index 97% rename from src/Services/UtilityService.cs rename to src/Services/Utility.cs index 9ac481b..401b067 100644 --- a/src/Services/UtilityService.cs +++ b/src/Services/Utility.cs @@ -1,7 +1,6 @@ using System.Drawing; using System.Text; using System.Text.Json.Nodes; -using Microsoft.Extensions.Hosting; using Octobot.Data; using Octobot.Extensions; using Remora.Discord.API.Abstractions.Objects; @@ -17,14 +16,14 @@ namespace Octobot.Services; /// Provides utility methods that cannot be transformed to extension methods because they require usage /// of some Discord APIs. /// -public sealed class UtilityService : IHostedService +public sealed class Utility { private readonly IDiscordRestChannelAPI _channelApi; private readonly IDiscordRestGuildScheduledEventAPI _eventApi; private readonly IDiscordRestGuildAPI _guildApi; private readonly IDiscordRestUserAPI _userApi; - public UtilityService( + public Utility( IDiscordRestChannelAPI channelApi, IDiscordRestGuildScheduledEventAPI eventApi, IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi) { @@ -34,16 +33,6 @@ public sealed class UtilityService : IHostedService _userApi = userApi; } - public Task StartAsync(CancellationToken ct) - { - return Task.CompletedTask; - } - - public Task StopAsync(CancellationToken ct) - { - return Task.CompletedTask; - } - /// /// Checks whether or not a member can interact with another member ///