From 33663d7efc35eac5e59c9c05f8eb4e8447e4cd90 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 8 Sep 2024 14:16:35 +0000 Subject: [PATCH] dev: Some packages updated, and small cleanup --- src/NadekoBot/Bot.cs | 4 ++-- .../Db/Extensions/GuildConfigExtensions.cs | 13 +++++++++---- src/NadekoBot/NadekoBot.csproj | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/NadekoBot/Bot.cs b/src/NadekoBot/Bot.cs index 60bda9bd5..093234e99 100644 --- a/src/NadekoBot/Bot.cs +++ b/src/NadekoBot/Bot.cs @@ -88,7 +88,7 @@ public sealed class Bot : IBot public IReadOnlyList GetCurrentGuildIds() - => Client.Guilds.Select(x => x.Id).ToList().ToList(); + => Client.Guilds.Select(x => x.Id).ToList().AsReadOnly(); private void AddServices() { @@ -99,7 +99,7 @@ public sealed class Bot : IBot using (var uow = _db.GetDbContext()) { uow.EnsureUserCreated(bot.Id, bot.Username, bot.Discriminator, bot.AvatarId); - AllGuildConfigs = uow.Set().GetAllGuildConfigs(startingGuildIdList).ToImmutableArray(); + AllGuildConfigs = uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList); } // var svcs = new StandardKernel(new NinjectSettings() diff --git a/src/NadekoBot/Db/Extensions/GuildConfigExtensions.cs b/src/NadekoBot/Db/Extensions/GuildConfigExtensions.cs index 69f571384..f82425db2 100644 --- a/src/NadekoBot/Db/Extensions/GuildConfigExtensions.cs +++ b/src/NadekoBot/Db/Extensions/GuildConfigExtensions.cs @@ -47,14 +47,19 @@ public static class GuildConfigExtensions .Include(gc => gc.CommandCooldowns) .Include(gc => gc.FollowedStreams) .Include(gc => gc.StreamRole) + .Include(gc => gc.DelMsgOnCmdChannels) .Include(gc => gc.XpSettings) - .ThenInclude(x => x.ExclusionList) - .Include(gc => gc.DelMsgOnCmdChannels); + .ThenInclude(x => x.ExclusionList) + ; - public static IEnumerable GetAllGuildConfigs( + public static IReadOnlyCollection GetAllGuildConfigs( this DbSet configs, IReadOnlyList availableGuilds) - => configs.IncludeEverything().AsNoTracking().Where(x => availableGuilds.Contains(x.GuildId)).ToList(); + => configs.IncludeEverything() + .Where(x => availableGuilds.Contains(x.GuildId)) + .AsNoTracking() + .ToList() + .AsReadOnly(); /// /// Gets and creates if it doesn't exist a config for a guild. diff --git a/src/NadekoBot/NadekoBot.csproj b/src/NadekoBot/NadekoBot.csproj index 4fdb54698..46324386b 100644 --- a/src/NadekoBot/NadekoBot.csproj +++ b/src/NadekoBot/NadekoBot.csproj @@ -81,7 +81,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -89,7 +89,7 @@ - +