1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-05-04 04:56:30 +03:00

Merge BackgroundGuildDataSaverService into GuildDataService (#239)

Title. idk why I didn't think of this before.
Also, GuildDataService is now properly registered as an IHostedService,
so it receives start & shutdown events. So this PR gets rid of the
workaround that was needed for save-on-shutdown to function

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-12-20 22:08:56 +05:00 committed by GitHub
parent bd4c5b26da
commit 21f200c988
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 36 deletions

View file

@ -24,12 +24,12 @@ namespace Octobot;
public sealed class Octobot
{
public static readonly AllowedMentions NoMentions = new(
Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>());
public const string RepositoryUrl = "https://github.com/LabsDevelopment/Octobot";
public const string IssuesUrl = $"{RepositoryUrl}/issues";
public static readonly AllowedMentions NoMentions = new(
Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>());
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).UseConsoleLifetime().Build();
@ -86,12 +86,12 @@ public sealed class Octobot
.AddPreparationErrorEvent<LoggingPreparationErrorEvent>()
.AddPostExecutionEvent<ErrorLoggingPostExecutionEvent>()
// Services
.AddSingleton<GuildDataService>()
.AddSingleton<Utility>()
.AddSingleton<GuildDataService>()
.AddHostedService<GuildDataService>(provider => provider.GetRequiredService<GuildDataService>())
.AddHostedService<MemberUpdateService>()
.AddHostedService<ScheduledEventUpdateService>()
.AddHostedService<SongUpdateService>()
.AddHostedService<BackgroundGuildDataSaverService>()
// Slash commands
.AddCommandTree()
.WithCommandGroup<AboutCommandGroup>()