From 15dac7e3ed6a3d62c58d09744577b18c6bb2ebc3 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 19 Jun 2021 03:32:48 +0200 Subject: [PATCH] Massive cleanup - Removed GuildConfigs repository, moved to extensions - Moved StreamSettings extension to GuildConfig extensions - namespace NadekoBot.Core has been simplified to NadekoBot in many places (more to come) - Replaced some raw delete queries with simple linqtodb queries --- .../Extensions/ServiceCollectionExtensions.cs | 2 +- .../TypeReaders/ShmartNumberTypeReader.cs | 2 +- .../Administration/DangerousCommands.cs | 2 +- .../SelfAssignedRolesCommands.cs | 2 +- .../Services/AdministrationService.cs | 7 +- .../Services/AutoAssignRoleService.cs | 5 +- .../Services/DangerousCommandsService.cs | 2 +- .../Services/GameVoiceChannelService.cs | 3 +- .../Services/GuildTimezoneService.cs | 2 +- .../Services/LogCommandService.cs | 8 +- .../Administration/Services/MuteService.cs | 16 +- .../Services/ProtectionService.cs | 16 +- .../Services/RoleCommandsService.cs | 4 +- .../Services/SelfAssignedRolesService.cs | 16 +- .../Services/UserPunishService.cs | 14 +- .../Administration/Services/VcRoleService.cs | 6 +- .../Modules/Gambling/AnimalRacingCommands.cs | 8 +- .../Modules/Gambling/BlackJackCommands.cs | 12 +- .../Common/AnimalRacing/AnimalRace.cs | 2 +- .../Common/AnimalRacing/RaceOptions.cs | 2 +- .../Modules/Gambling/Common/BetRoll.cs | 2 +- .../Gambling/Common/Blackjack/Blackjack.cs | 2 +- .../Gambling/Common/Blackjack/Player.cs | 2 +- .../Gambling/Common/CurrencyRaffleGame.cs | 2 +- .../Gambling/Common/Events/EventOptions.cs | 2 +- .../Gambling/Common/Events/GameStatusEvent.cs | 2 +- .../Gambling/Common/Events/ReactionEvent.cs | 4 +- .../Modules/Gambling/Common/GamblingConfig.cs | 2 +- .../Gambling/Common/GamblingTopLevelModule.cs | 4 +- .../Modules/Gambling/Common/Payout.cs | 2 +- .../Modules/Gambling/Common/RollDuelGame.cs | 2 +- .../Gambling/Common/Waifu/AffinityTitle.cs | 2 +- .../Gambling/Common/Waifu/ClaimTitle.cs | 2 +- .../Gambling/Common/Waifu/DivorceResult.cs | 2 +- .../Gambling/Common/Waifu/WaifuClaimResult.cs | 2 +- .../Common/Waifu/WaifuProfileTitle.cs | 2 +- .../Common/WheelOfFortune/WheelOfFortune.cs | 2 +- .../Modules/Gambling/Connect4Commands.cs | 7 +- .../Gambling/CurrencyEventsCommands.cs | 7 +- .../Gambling/CurrencyRaffleCommands.cs | 4 +- .../Modules/Gambling/DiceRollCommands.cs | 3 +- .../Modules/Gambling/DrawCommands.cs | 3 +- .../Modules/Gambling/FlipCoinCommands.cs | 7 +- src/NadekoBot/Modules/Gambling/Gambling.cs | 10 +- .../Gambling/Services/BlackJackService.cs | 4 +- .../Services/CurrencyEventsService.cs | 4 +- .../Services/CurrencyRaffleService.cs | 4 +- .../Services/GamblingConfigService.cs | 4 +- .../Gambling/Services/GamblingService.cs | 4 +- .../Modules/Gambling/Services/IShopService.cs | 2 +- .../Gambling/Services/Impl/ShopService.cs | 5 +- .../Gambling/Services/PlantPickService.cs | 9 +- .../Modules/Gambling/Services/WaifuService.cs | 7 +- .../Modules/Gambling/ShopCommands.cs | 23 +-- .../Modules/Gambling/SlotCommands.cs | 5 +- .../Modules/Gambling/WaifuClaimCommands.cs | 7 +- .../Gambling/WheelOfFortuneCommands.cs | 7 +- .../Modules/Games/CleverBotCommands.cs | 8 +- .../Modules/Games/Common/PollRunner.cs | 6 +- .../Modules/Games/Common/TicTacToe.cs | 2 + .../Modules/Games/Common/Trivia/TriviaGame.cs | 2 +- .../Games/Common/Trivia/TriviaOptions.cs | 2 +- .../Modules/Games/PlantAndPickCommands.cs | 3 +- .../Modules/Games/Services/PollService.cs | 4 +- src/NadekoBot/Modules/Games/TriviaCommands.cs | 1 - .../Modules/Help/Common/CommandsOptions.cs | 2 +- src/NadekoBot/Modules/Help/Help.cs | 2 +- .../Music/Common/ICachableTrackData.cs | 2 +- .../Music/Common/ILocalTrackResolver.cs | 2 +- .../Modules/Music/Common/IMusicPlayer.cs | 2 +- .../Modules/Music/Common/IMusicQueue.cs | 2 +- .../Music/Common/IPlatformQueryResolver.cs | 2 +- .../Modules/Music/Common/IQueuedTrackInfo.cs | 2 +- .../Modules/Music/Common/IRadioResolver.cs | 2 +- .../Music/Common/ISoundcloudResolver.cs | 2 +- .../Modules/Music/Common/ITrackCacher.cs | 2 +- .../Modules/Music/Common/ITrackInfo.cs | 2 +- .../Music/Common/ITrackResolveProvider.cs | 2 +- .../Modules/Music/Common/IYoutubeResolver.cs | 2 +- .../Music/Common/Impl/CachableTrackData.cs | 2 +- .../Music/Common/Impl/MultimediaTimer.cs | 2 +- .../Music/Common/Impl/MusicExtensions.cs | 2 +- .../Music/Common/Impl/MusicPlatform.cs | 2 +- .../Modules/Music/Common/Impl/MusicPlayer.cs | 4 +- .../Modules/Music/Common/Impl/MusicQueue.cs | 2 +- .../Music/Common/Impl/RedisTrackCacher.cs | 2 +- .../Music/Common/Impl/RemoteTrackInfo.cs | 2 +- .../Music/Common/Impl/SimpleTrackInfo.cs | 2 +- .../Common/Resolvers/LocalTrackResolver.cs | 2 +- .../Common/Resolvers/RadioResolveStrategy.cs | 2 +- .../Common/Resolvers/SoundcloudResolver.cs | 3 +- .../Common/Resolvers/TrackResolveProvider.cs | 2 +- .../Common/Resolvers/YtdlYoutubeResolver.cs | 2 +- src/NadekoBot/Modules/Music/Music.cs | 2 +- .../Modules/Music/PlaylistCommands.cs | 4 +- .../Modules/Music/Services/IMusicService.cs | 2 +- .../Modules/Music/Services/MusicService.cs | 5 +- .../Music/Services/_OldMusicService.cs | 8 +- src/NadekoBot/Modules/Music/_OldMusic.cs | 2 +- src/NadekoBot/Modules/Nsfw/Nsfw.cs | 1 - .../Modules/Permissions/CmdCdsCommands.cs | 3 +- .../Modules/Permissions/FilterCommands.cs | 15 +- .../Modules/Permissions/Permissions.cs | 11 +- .../Permissions/Services/FilterService.cs | 3 +- .../Services/PermissionsService.cs | 9 +- .../Modules/Searches/Common/BibleVerses.cs | 2 +- .../Modules/Searches/Common/CryptoData.cs | 2 +- .../Modules/Searches/Common/Gallery.cs | 2 +- .../Searches/Common/GatariUserResponse.cs | 2 +- .../Common/GatariUserStatsResponse.cs | 2 +- .../Searches/Common/HearthstoneCardData.cs | 2 +- .../Modules/Searches/Common/MtgData.cs | 2 +- .../Searches/Common/NhentaiApiModel.cs | 2 +- .../Modules/Searches/Common/OmdbMovie.cs | 2 +- .../Modules/Searches/Common/OsuUserData.cs | 2 +- .../Searches/Common/PathOfExileModels.cs | 2 +- .../Models/PicartoChannelResponse.cs | 2 +- .../StreamNotifications/Models/StreamData.cs | 3 +- .../Models/StreamDataKey.cs | 3 +- .../Models/TwitchResponseHelix.cs | 2 +- .../Models/TwitchResponseV5.cs | 2 +- .../Models/TwitchUsersResponseV5.cs | 2 +- .../StreamNotifications/NotifChecker.cs | 5 +- .../Providers/PicartoProvider.cs | 3 +- .../StreamNotifications/Providers/Provider.cs | 3 +- .../Providers/TwitchHelixProvider.cs | 2 +- .../Providers/TwitchProvider.cs | 3 +- .../Modules/Searches/Common/TimeData.cs | 2 +- .../Modules/Searches/Common/UrbanDef.cs | 2 +- .../Modules/Searches/CryptoCommands.cs | 2 +- src/NadekoBot/Modules/Searches/OsuCommands.cs | 2 +- .../Modules/Searches/PathOfExileCommands.cs | 2 +- src/NadekoBot/Modules/Searches/Searches.cs | 3 +- .../Searches/Services/CryptoService.cs | 4 +- .../Modules/Searches/Services/FeedsService.cs | 7 +- .../Searches/Services/SearchesService.cs | 9 +- .../Services/StreamNotificationService.cs | 14 +- .../Searches/Services/YtTrackService.cs | 4 +- .../Searches/StreamNotificationCommands.cs | 6 +- .../Modules/Searches/YtUploadCommands.cs | 4 +- .../Modules/Utility/CommandMapCommands.cs | 13 +- .../Extensions/StreamRoleExtensions.cs | 27 ---- .../Modules/Utility/InviteCommands.cs | 2 +- .../Modules/Utility/QuoteCommands.cs | 7 +- .../Modules/Utility/RemindCommands.cs | 2 + .../Modules/Utility/RepeatCommands.cs | 2 +- .../Utility/Services/CommandMapService.cs | 9 +- .../Modules/Utility/Services/InviteService.cs | 2 +- .../Utility/Services/PatreonRewardsService.cs | 2 +- .../Utility/Services/RepeaterService.cs | 6 +- .../Utility/Services/StreamRoleService.cs | 12 +- .../Utility/Services/VerboseErrorsService.cs | 3 +- src/NadekoBot/Modules/Xp/Club.cs | 1 + .../Modules/Xp/Common/FullUserStats.cs | 1 + src/NadekoBot/Modules/Xp/Common/XpTemplate.cs | 2 +- .../Modules/Xp/Services/ClubService.cs | 5 +- .../Modules/Xp/Services/XpService.cs | 54 ++++--- src/NadekoBot/Modules/Xp/Xp.cs | 2 +- src/NadekoBot/Services/CommandHandler.cs | 3 +- .../Services/Database/IUnitOfWork.cs | 2 - .../Services/Database/Models/ClubInfo.cs | 3 +- .../Services/Database/Models/DiscordUser.cs | 3 +- .../Database/Models/FollowedStream.cs | 5 +- .../Services/Database/Models/GuildConfig.cs | 1 + .../Services/Database/Models/Waifu.cs | 3 +- .../Services/Database/Models/WaifuUpdate.cs | 4 +- .../Services/Database/NadekoContext.cs | 1 + .../Repositories/IDiscordUserRepository.cs | 2 + .../Repositories/IGuildConfigRepository.cs | 28 ---- .../Database/Repositories/IRepository.cs | 14 +- .../Database/Repositories/IWaifuRepository.cs | 1 + .../Database/Repositories/IXpRepository.cs | 15 -- .../Repositories/Impl/ClubExtensions.cs | 1 + .../Impl/CustomReactionsExtensions.cs | 3 +- .../Impl/DiscordUserRepository.cs | 5 +- ...Repository.cs => GuildConfigExtensions.cs} | 143 +++++++++--------- .../Impl/MusicPlayerSettingsExtensions.cs | 30 ++++ .../Impl/MusicPlaylistExtensions.cs | 3 +- .../Repositories/Impl/PollExtensions.cs | 4 +- ...derRepository.cs => ReminderExtensions.cs} | 0 .../Database/Repositories/Impl/Repository.cs | 29 +--- .../{XpRepository.cs => UserXpExtensions.cs} | 42 ++--- .../Repositories/Impl/WaifuRepository.cs | 6 +- src/NadekoBot/Services/Database/UnitOfWork.cs | 14 +- src/NadekoBot/Services/DbService.cs | 1 + .../Services/GreetSettingsService.cs | 33 ++-- .../Services/Impl/CurrencyService.cs | 2 +- src/NadekoBot/Services/Impl/Localization.cs | 5 +- src/NadekoBot/Services/NadekoBot.cs | 11 +- .../Settings/GamblingConfigMigrator.cs | 4 +- src/NadekoBot/_Extensions/IUserExtensions.cs | 1 + 191 files changed, 563 insertions(+), 571 deletions(-) delete mode 100644 src/NadekoBot/Modules/Utility/Extensions/StreamRoleExtensions.cs delete mode 100644 src/NadekoBot/Services/Database/Repositories/IGuildConfigRepository.cs delete mode 100644 src/NadekoBot/Services/Database/Repositories/IXpRepository.cs rename src/NadekoBot/Services/Database/Repositories/Impl/{GuildConfigRepository.cs => GuildConfigExtensions.cs} (57%) create mode 100644 src/NadekoBot/Services/Database/Repositories/Impl/MusicPlayerSettingsExtensions.cs rename src/NadekoBot/Services/Database/Repositories/Impl/{ReminderRepository.cs => ReminderExtensions.cs} (100%) rename src/NadekoBot/Services/Database/Repositories/Impl/{XpRepository.cs => UserXpExtensions.cs} (56%) diff --git a/src/NadekoBot/Common/Extensions/ServiceCollectionExtensions.cs b/src/NadekoBot/Common/Extensions/ServiceCollectionExtensions.cs index 255fe8fff..94f8cf12e 100644 --- a/src/NadekoBot/Common/Extensions/ServiceCollectionExtensions.cs +++ b/src/NadekoBot/Common/Extensions/ServiceCollectionExtensions.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Reflection; using Microsoft.Extensions.DependencyInjection; using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Music; +using NadekoBot.Modules.Music; using NadekoBot.Core.Services; using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.Music.Resolvers; diff --git a/src/NadekoBot/Common/TypeReaders/ShmartNumberTypeReader.cs b/src/NadekoBot/Common/TypeReaders/ShmartNumberTypeReader.cs index 76a7ac919..2fcd30f9d 100644 --- a/src/NadekoBot/Common/TypeReaders/ShmartNumberTypeReader.cs +++ b/src/NadekoBot/Common/TypeReaders/ShmartNumberTypeReader.cs @@ -5,7 +5,7 @@ using NadekoBot.Core.Services; using System; using System.Text.RegularExpressions; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Services; namespace NadekoBot.Core.Common.TypeReaders { diff --git a/src/NadekoBot/Modules/Administration/DangerousCommands.cs b/src/NadekoBot/Modules/Administration/DangerousCommands.cs index 10df7b38e..ac1c1a4dc 100644 --- a/src/NadekoBot/Modules/Administration/DangerousCommands.cs +++ b/src/NadekoBot/Modules/Administration/DangerousCommands.cs @@ -4,7 +4,7 @@ using NadekoBot.Extensions; using System; using System.Threading.Tasks; using Discord; -using NadekoBot.Core.Modules.Administration.Services; +using NadekoBot.Modules.Administration.Services; using System.Linq; #if !GLOBAL_NADEKO diff --git a/src/NadekoBot/Modules/Administration/SelfAssignedRolesCommands.cs b/src/NadekoBot/Modules/Administration/SelfAssignedRolesCommands.cs index 2c2697bd4..7a38281cb 100644 --- a/src/NadekoBot/Modules/Administration/SelfAssignedRolesCommands.cs +++ b/src/NadekoBot/Modules/Administration/SelfAssignedRolesCommands.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Modules.Administration.Services; +using NadekoBot.Modules.Administration.Services; using NadekoBot.Extensions; namespace NadekoBot.Modules.Administration diff --git a/src/NadekoBot/Modules/Administration/Services/AdministrationService.cs b/src/NadekoBot/Modules/Administration/Services/AdministrationService.cs index 9c38617dd..5edc8702f 100644 --- a/src/NadekoBot/Modules/Administration/Services/AdministrationService.cs +++ b/src/NadekoBot/Modules/Administration/Services/AdministrationService.cs @@ -12,6 +12,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using NadekoBot.Core.Services.Database.Repositories.Impl; namespace NadekoBot.Modules.Administration.Services { @@ -45,7 +46,7 @@ namespace NadekoBot.Modules.Administration.Services { using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, + var conf = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.DelMsgOnCmdChannels)); return (conf.DeleteMessageOnCommand, conf.DelMsgOnCmdChannels); @@ -83,7 +84,7 @@ namespace NadekoBot.Modules.Administration.Services bool enabled; using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); enabled = conf.DeleteMessageOnCommand = !conf.DeleteMessageOnCommand; uow.SaveChanges(); @@ -95,7 +96,7 @@ namespace NadekoBot.Modules.Administration.Services { using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, + var conf = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.DelMsgOnCmdChannels)); var old = conf.DelMsgOnCmdChannels.FirstOrDefault(x => x.ChannelId == chId); diff --git a/src/NadekoBot/Modules/Administration/Services/AutoAssignRoleService.cs b/src/NadekoBot/Modules/Administration/Services/AutoAssignRoleService.cs index bc74298aa..313de2b1e 100644 --- a/src/NadekoBot/Modules/Administration/Services/AutoAssignRoleService.cs +++ b/src/NadekoBot/Modules/Administration/Services/AutoAssignRoleService.cs @@ -9,6 +9,7 @@ using System.Threading.Channels; using LinqToDB; using Microsoft.EntityFrameworkCore; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Core.Services.Database.Repositories.Impl; using NadekoBot.Extensions; using Serilog; @@ -107,7 +108,7 @@ namespace NadekoBot.Modules.Administration.Services public async Task> ToggleAarAsync(ulong guildId, ulong roleId) { using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); var roles = gc.GetAutoAssignableRoles(); if(!roles.Remove(roleId) && roles.Count < 3) roles.Add(roleId); @@ -142,7 +143,7 @@ namespace NadekoBot.Modules.Administration.Services { using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); gc.SetAutoAssignableRoles(newRoles); await uow.SaveChangesAsync(); diff --git a/src/NadekoBot/Modules/Administration/Services/DangerousCommandsService.cs b/src/NadekoBot/Modules/Administration/Services/DangerousCommandsService.cs index c66036b94..d88391d22 100644 --- a/src/NadekoBot/Modules/Administration/Services/DangerousCommandsService.cs +++ b/src/NadekoBot/Modules/Administration/Services/DangerousCommandsService.cs @@ -7,7 +7,7 @@ using LinqToDB; using LinqToDB.EntityFrameworkCore; using NadekoBot.Core.Services.Database.Models; -namespace NadekoBot.Core.Modules.Administration.Services +namespace NadekoBot.Modules.Administration.Services { public class DangerousCommandsService : INService { diff --git a/src/NadekoBot/Modules/Administration/Services/GameVoiceChannelService.cs b/src/NadekoBot/Modules/Administration/Services/GameVoiceChannelService.cs index 12e19e2d3..448445446 100644 --- a/src/NadekoBot/Modules/Administration/Services/GameVoiceChannelService.cs +++ b/src/NadekoBot/Modules/Administration/Services/GameVoiceChannelService.cs @@ -5,6 +5,7 @@ using Discord.WebSocket; using NadekoBot.Common.Collections; using NadekoBot.Extensions; using NadekoBot.Core.Services; +using NadekoBot.Core.Services.Database.Repositories.Impl; using Serilog; namespace NadekoBot.Modules.Administration.Services @@ -63,7 +64,7 @@ namespace NadekoBot.Modules.Administration.Services ulong? id; using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); if (gc.GameVoiceChannel == vchId) { diff --git a/src/NadekoBot/Modules/Administration/Services/GuildTimezoneService.cs b/src/NadekoBot/Modules/Administration/Services/GuildTimezoneService.cs index a741c946e..0a00c40ee 100644 --- a/src/NadekoBot/Modules/Administration/Services/GuildTimezoneService.cs +++ b/src/NadekoBot/Modules/Administration/Services/GuildTimezoneService.cs @@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Administration.Services { using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); gc.TimeZoneId = tz?.Id; uow.SaveChanges(); diff --git a/src/NadekoBot/Modules/Administration/Services/LogCommandService.cs b/src/NadekoBot/Modules/Administration/Services/LogCommandService.cs index 6e13b95e8..a0f28bcd1 100644 --- a/src/NadekoBot/Modules/Administration/Services/LogCommandService.cs +++ b/src/NadekoBot/Modules/Administration/Services/LogCommandService.cs @@ -124,7 +124,7 @@ namespace NadekoBot.Modules.Administration.Services int removed = 0; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.LogSettingsFor(gid); + var config = uow._context.LogSettingsFor(gid); LogSetting logSetting = GuildLogSettings.GetOrAdd(gid, (id) => config.LogSetting); removed = logSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == cid); config.LogSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == cid); @@ -167,7 +167,7 @@ namespace NadekoBot.Modules.Administration.Services LogSetting logSetting; using (var uow = _db.GetDbContext()) { - logSetting = uow.GuildConfigs.LogSettingsFor(guildId).LogSetting; + logSetting = uow._context.LogSettingsFor(guildId).LogSetting; GuildLogSettings.AddOrUpdate(guildId, (id) => logSetting, (id, old) => logSetting); logSetting.LogOtherId = logSetting.MessageUpdatedId = @@ -256,7 +256,7 @@ namespace NadekoBot.Modules.Administration.Services ulong? channelId = null; using (var uow = _db.GetDbContext()) { - var logSetting = uow.GuildConfigs.LogSettingsFor(gid).LogSetting; + var logSetting = uow._context.LogSettingsFor(gid).LogSetting; GuildLogSettings.AddOrUpdate(gid, (id) => logSetting, (id, old) => logSetting); switch (type) { @@ -1220,7 +1220,7 @@ namespace NadekoBot.Modules.Administration.Services { using (var uow = _db.GetDbContext()) { - var newLogSetting = uow.GuildConfigs.LogSettingsFor(guildId).LogSetting; + var newLogSetting = uow._context.LogSettingsFor(guildId).LogSetting; switch (logChannelType) { case LogType.Other: diff --git a/src/NadekoBot/Modules/Administration/Services/MuteService.cs b/src/NadekoBot/Modules/Administration/Services/MuteService.cs index 7276361ea..e51405f02 100644 --- a/src/NadekoBot/Modules/Administration/Services/MuteService.cs +++ b/src/NadekoBot/Modules/Administration/Services/MuteService.cs @@ -173,7 +173,7 @@ namespace NadekoBot.Modules.Administration.Services { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(guildId, set => set); + var config = uow._context.GuildConfigsForId(guildId, set => set); config.MuteRoleName = name; GuildMuteRoles.AddOrUpdate(guildId, name, (id, old) => name); await uow.SaveChangesAsync(); @@ -191,7 +191,7 @@ namespace NadekoBot.Modules.Administration.Services StopTimer(usr.GuildId, usr.Id, TimerType.Mute); using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(usr.Guild.Id, + var config = uow._context.GuildConfigsForId(usr.Guild.Id, set => set.Include(gc => gc.MutedUsers) .Include(gc => gc.UnmuteTimers)); config.MutedUsers.Add(new MutedUserId() @@ -231,7 +231,7 @@ namespace NadekoBot.Modules.Administration.Services StopTimer(guildId, usrId, TimerType.Mute); using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(guildId, set => set.Include(gc => gc.MutedUsers) + var config = uow._context.GuildConfigsForId(guildId, set => set.Include(gc => gc.MutedUsers) .Include(gc => gc.UnmuteTimers)); var match = new MutedUserId() { @@ -326,7 +326,7 @@ namespace NadekoBot.Modules.Administration.Services await MuteUser(user, mod, muteType, reason).ConfigureAwait(false); // mute the user. This will also remove any previous unmute timers using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(user.GuildId, set => set.Include(x => x.UnmuteTimers)); + var config = uow._context.GuildConfigsForId(user.GuildId, set => set.Include(x => x.UnmuteTimers)); config.UnmuteTimers.Add(new UnmuteTimer() { UserId = user.Id, @@ -343,7 +343,7 @@ namespace NadekoBot.Modules.Administration.Services await guild.AddBanAsync(user.Id, 0, reason).ConfigureAwait(false); using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(guild.Id, set => set.Include(x => x.UnbanTimer)); + var config = uow._context.GuildConfigsForId(guild.Id, set => set.Include(x => x.UnbanTimer)); config.UnbanTimer.Add(new UnbanTimer() { UserId = user.Id, @@ -360,7 +360,7 @@ namespace NadekoBot.Modules.Administration.Services await user.AddRoleAsync(role).ConfigureAwait(false); using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(user.GuildId, set => set.Include(x => x.UnroleTimer)); + var config = uow._context.GuildConfigsForId(user.GuildId, set => set.Include(x => x.UnroleTimer)); config.UnroleTimer.Add(new UnroleTimer() { UserId = user.Id, @@ -458,12 +458,12 @@ namespace NadekoBot.Modules.Administration.Services object toDelete; if (type == TimerType.Mute) { - var config = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.UnmuteTimers)); + var config = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.UnmuteTimers)); toDelete = config.UnmuteTimers.FirstOrDefault(x => x.UserId == userId); } else { - var config = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.UnbanTimer)); + var config = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.UnbanTimer)); toDelete = config.UnbanTimer.FirstOrDefault(x => x.UserId == userId); } if (toDelete != null) diff --git a/src/NadekoBot/Modules/Administration/Services/ProtectionService.cs b/src/NadekoBot/Modules/Administration/Services/ProtectionService.cs index 706824a17..a0f153c08 100644 --- a/src/NadekoBot/Modules/Administration/Services/ProtectionService.cs +++ b/src/NadekoBot/Modules/Administration/Services/ProtectionService.cs @@ -114,7 +114,7 @@ namespace NadekoBot.Modules.Administration.Services private Task _bot_JoinedGuild(GuildConfig gc) { using var uow = _db.GetDbContext(); - var gcWithData = uow.GuildConfigs.ForId(gc.GuildId, + var gcWithData = uow._context.GuildConfigsForId(gc.GuildId, set => set .Include(x => x.AntiRaidSetting) .Include(x => x.AntiAltSetting) @@ -304,7 +304,7 @@ namespace NadekoBot.Modules.Administration.Services using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.AntiRaidSetting)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.AntiRaidSetting)); gc.AntiRaidSetting = stats.AntiRaidSettings; await uow.SaveChangesAsync(); @@ -319,7 +319,7 @@ namespace NadekoBot.Modules.Administration.Services { using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.AntiRaidSetting)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.AntiRaidSetting)); gc.AntiRaidSetting = null; uow.SaveChanges(); @@ -336,7 +336,7 @@ namespace NadekoBot.Modules.Administration.Services removed.UserStats.ForEach(x => x.Value.Dispose()); using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.AntiSpamSetting) + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.AntiSpamSetting) .ThenInclude(x => x.IgnoredChannels)); gc.AntiSpamSetting = null; @@ -375,7 +375,7 @@ namespace NadekoBot.Modules.Administration.Services using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.AntiSpamSetting)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.AntiSpamSetting)); if (gc.AntiSpamSetting != null) { @@ -402,7 +402,7 @@ namespace NadekoBot.Modules.Administration.Services bool added; using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.AntiSpamSetting).ThenInclude(x => x.IgnoredChannels)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.AntiSpamSetting).ThenInclude(x => x.IgnoredChannels)); var spam = gc.AntiSpamSetting; if (spam is null) { @@ -459,7 +459,7 @@ namespace NadekoBot.Modules.Administration.Services int actionDurationMinutes = 0, ulong? roleId = null) { using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.AntiAltSetting)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.AntiAltSetting)); gc.AntiAltSetting = new AntiAltSetting() { Action = action, @@ -478,7 +478,7 @@ namespace NadekoBot.Modules.Administration.Services return false; using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.AntiAltSetting)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.AntiAltSetting)); gc.AntiAltSetting = null; await uow.SaveChangesAsync(); return true; diff --git a/src/NadekoBot/Modules/Administration/Services/RoleCommandsService.cs b/src/NadekoBot/Modules/Administration/Services/RoleCommandsService.cs index b85bbc3e3..e37db913a 100644 --- a/src/NadekoBot/Modules/Administration/Services/RoleCommandsService.cs +++ b/src/NadekoBot/Modules/Administration/Services/RoleCommandsService.cs @@ -156,7 +156,7 @@ namespace NadekoBot.Modules.Administration.Services { using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(id, set => set + var gc = uow._context.GuildConfigsForId(id, set => set .Include(x => x.ReactionRoleMessages) .ThenInclude(x => x.ReactionRoles)); if (gc.ReactionRoleMessages.Count >= 10) @@ -174,7 +174,7 @@ namespace NadekoBot.Modules.Administration.Services { using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(id, + var gc = uow._context.GuildConfigsForId(id, set => set.Include(x => x.ReactionRoleMessages) .ThenInclude(x => x.ReactionRoles)); uow._context.Set() diff --git a/src/NadekoBot/Modules/Administration/Services/SelfAssignedRolesService.cs b/src/NadekoBot/Modules/Administration/Services/SelfAssignedRolesService.cs index bdf78b6c8..458d53434 100644 --- a/src/NadekoBot/Modules/Administration/Services/SelfAssignedRolesService.cs +++ b/src/NadekoBot/Modules/Administration/Services/SelfAssignedRolesService.cs @@ -6,10 +6,12 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using NadekoBot.Modules.Administration; using NadekoBot.Modules.Xp; using NadekoBot.Modules.Administration.Common; +using NadekoBot.Modules.Xp.Common; -namespace NadekoBot.Core.Modules.Administration.Services +namespace NadekoBot.Modules.Administration.Services { public class SelfAssignedRolesService : INService { @@ -63,7 +65,7 @@ namespace NadekoBot.Core.Modules.Administration.Services bool newval; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(guildId, set => set); + var config = uow._context.GuildConfigsForId(guildId, set => set); newval = config.AutoDeleteSelfAssignedRoleMessages = !config.AutoDeleteSelfAssignedRoleMessages; uow.SaveChanges(); } @@ -75,7 +77,7 @@ namespace NadekoBot.Core.Modules.Administration.Services LevelStats userLevelData; using (var uow = _db.GetDbContext()) { - var stats = uow.Xp.GetOrCreateUser(guildUser.Guild.Id, guildUser.Id); + var stats = uow._context.GetOrCreateUserXpStats(guildUser.Guild.Id, guildUser.Id); userLevelData = new LevelStats(stats.Xp + stats.AwardedXp); } @@ -137,7 +139,7 @@ namespace NadekoBot.Core.Modules.Administration.Services bool set = false; using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, y => y.Include(x => x.SelfAssignableRoleGroupNames)); + var gc = uow._context.GuildConfigsForId(guildId, y => y.Include(x => x.SelfAssignableRoleGroupNames)); var toUpdate = gc.SelfAssignableRoleGroupNames.FirstOrDefault(x => x.Number == group); if (string.IsNullOrWhiteSpace(name)) @@ -205,7 +207,7 @@ namespace NadekoBot.Core.Modules.Administration.Services { using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); var autoDelete = gc.AutoDeleteSelfAssignedRoleMessages; var exclusive = gc.ExclusiveSelfAssignedRoles; var roles = uow._context.SelfAssignableRoles.GetFromGuild(guildId); @@ -239,7 +241,7 @@ namespace NadekoBot.Core.Modules.Administration.Services bool areExclusive; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(guildId, set => set); + var config = uow._context.GuildConfigsForId(guildId, set => set); areExclusive = config.ExclusiveSelfAssignedRoles = !config.ExclusiveSelfAssignedRoles; uow.SaveChanges(); @@ -255,7 +257,7 @@ namespace NadekoBot.Core.Modules.Administration.Services IDictionary groupNames; using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guild.Id, set => set.Include(x => x.SelfAssignableRoleGroupNames)); + var gc = uow._context.GuildConfigsForId(guild.Id, set => set.Include(x => x.SelfAssignableRoleGroupNames)); exclusive = gc.ExclusiveSelfAssignedRoles; groupNames = gc.SelfAssignableRoleGroupNames.ToDictionary(x => x.Number, x => x.Name); var roleModels = uow._context.SelfAssignableRoles.GetFromGuild(guild.Id); diff --git a/src/NadekoBot/Modules/Administration/Services/UserPunishService.cs b/src/NadekoBot/Modules/Administration/Services/UserPunishService.cs index fb7bfe5df..2d36eacf3 100644 --- a/src/NadekoBot/Modules/Administration/Services/UserPunishService.cs +++ b/src/NadekoBot/Modules/Administration/Services/UserPunishService.cs @@ -61,7 +61,7 @@ namespace NadekoBot.Modules.Administration.Services List ps; using (var uow = _db.GetDbContext()) { - ps = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.WarnPunishments)) + ps = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.WarnPunishments)) .WarnPunishments; warnings += uow._context @@ -191,7 +191,7 @@ WHERE GuildId in (SELECT GuildId FROM GuildConfigs WHERE WarnExpireHours > 0 AND { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(guildId, inc => inc); + var config = uow._context.GuildConfigsForId(guildId, inc => inc); if (config.WarnExpireHours == 0) return; @@ -220,7 +220,7 @@ WHERE GuildId={guildId} public Task GetWarnExpire(ulong guildId) { using var uow = _db.GetDbContext(); - var config = uow.GuildConfigs.ForId(guildId); + var config = uow._context.GuildConfigsForId(guildId, set => set); return Task.FromResult(config.WarnExpireHours / 24); } @@ -228,7 +228,7 @@ WHERE GuildId={guildId} { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(guildId, inc => inc); + var config = uow._context.GuildConfigsForId(guildId, inc => inc); config.WarnExpireHours = days * 24; config.WarnExpireAction = delete ? WarnExpireAction.Delete : WarnExpireAction.Clear; @@ -286,7 +286,7 @@ WHERE GuildId={guildId} using (var uow = _db.GetDbContext()) { - var ps = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.WarnPunishments)).WarnPunishments; + var ps = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.WarnPunishments)).WarnPunishments; var toDelete = ps.Where(x => x.Count == number); uow._context.RemoveRange(toDelete); @@ -310,7 +310,7 @@ WHERE GuildId={guildId} using (var uow = _db.GetDbContext()) { - var ps = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.WarnPunishments)).WarnPunishments; + var ps = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.WarnPunishments)).WarnPunishments; var p = ps.FirstOrDefault(x => x.Count == number); if (p != null) @@ -326,7 +326,7 @@ WHERE GuildId={guildId} { using (var uow = _db.GetDbContext()) { - return uow.GuildConfigs.ForId(guildId, gc => gc.Include(x => x.WarnPunishments)) + return uow._context.GuildConfigsForId(guildId, gc => gc.Include(x => x.WarnPunishments)) .WarnPunishments .OrderBy(x => x.Count) .ToArray(); diff --git a/src/NadekoBot/Modules/Administration/Services/VcRoleService.cs b/src/NadekoBot/Modules/Administration/Services/VcRoleService.cs index d7732f1b8..9a551a3ac 100644 --- a/src/NadekoBot/Modules/Administration/Services/VcRoleService.cs +++ b/src/NadekoBot/Modules/Administration/Services/VcRoleService.cs @@ -84,7 +84,7 @@ namespace NadekoBot.Modules.Administration.Services // need to load new guildconfig with vc role included using (var uow = _db.GetDbContext()) { - var configWithVcRole = uow.GuildConfigs.ForId( + var configWithVcRole = uow._context.GuildConfigsForId( arg.GuildId, set => set.Include(x => x.VcRoleInfos) ); @@ -144,7 +144,7 @@ namespace NadekoBot.Modules.Administration.Services guildVcRoles.AddOrUpdate(vcId, role, (key, old) => role); using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.VcRoleInfos)); + var conf = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.VcRoleInfos)); var toDelete = conf.VcRoleInfos.FirstOrDefault(x => x.VoiceChannelId == vcId); // remove old one if(toDelete != null) { @@ -169,7 +169,7 @@ namespace NadekoBot.Modules.Administration.Services using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.VcRoleInfos)); + var conf = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.VcRoleInfos)); var toRemove = conf.VcRoleInfos.Where(x => x.VoiceChannelId == vcId).ToList(); uow._context.RemoveRange(toRemove); uow.SaveChanges(); diff --git a/src/NadekoBot/Modules/Gambling/AnimalRacingCommands.cs b/src/NadekoBot/Modules/Gambling/AnimalRacingCommands.cs index 357e0f9d7..794241d38 100644 --- a/src/NadekoBot/Modules/Gambling/AnimalRacingCommands.cs +++ b/src/NadekoBot/Modules/Gambling/AnimalRacingCommands.cs @@ -6,14 +6,12 @@ using Discord.Commands; using Discord.WebSocket; using NadekoBot.Common.Attributes; using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Modules.Gambling.Common.AnimalRacing; -using NadekoBot.Core.Modules.Gambling.Services; using NadekoBot.Core.Services; -using NadekoBot.Extensions; +using NadekoBot.Modules.Gambling.Common; using NadekoBot.Modules.Gambling.Common.AnimalRacing; -using NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions; using NadekoBot.Modules.Gambling.Services; +using NadekoBot.Extensions; +using NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions; using NadekoBot.Modules.Games.Services; namespace NadekoBot.Modules.Gambling diff --git a/src/NadekoBot/Modules/Gambling/BlackJackCommands.cs b/src/NadekoBot/Modules/Gambling/BlackJackCommands.cs index 18b01b00f..f31a4acd7 100644 --- a/src/NadekoBot/Modules/Gambling/BlackJackCommands.cs +++ b/src/NadekoBot/Modules/Gambling/BlackJackCommands.cs @@ -1,14 +1,16 @@ using Discord; using Discord.Commands; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Modules.Gambling.Common.Blackjack; -using NadekoBot.Core.Modules.Gambling.Services; -using NadekoBot.Core.Services; +using NadekoBot.Common; +using NadekoBot.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Common.Blackjack; +using NadekoBot.Modules.Gambling.Services; +using NadekoBot.Services; using NadekoBot.Extensions; using System.Linq; using System.Threading.Tasks; +using NadekoBot.Core.Common; +using NadekoBot.Core.Services; using Serilog; namespace NadekoBot.Modules.Gambling diff --git a/src/NadekoBot/Modules/Gambling/Common/AnimalRacing/AnimalRace.cs b/src/NadekoBot/Modules/Gambling/Common/AnimalRacing/AnimalRace.cs index f81e36dea..65ffdc571 100644 --- a/src/NadekoBot/Modules/Gambling/Common/AnimalRacing/AnimalRace.cs +++ b/src/NadekoBot/Modules/Gambling/Common/AnimalRacing/AnimalRace.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using NadekoBot.Common; -using NadekoBot.Core.Modules.Gambling.Common.AnimalRacing; +using NadekoBot.Modules.Gambling.Common.AnimalRacing; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; using NadekoBot.Extensions; diff --git a/src/NadekoBot/Modules/Gambling/Common/AnimalRacing/RaceOptions.cs b/src/NadekoBot/Modules/Gambling/Common/AnimalRacing/RaceOptions.cs index 86295bbd9..05466d222 100644 --- a/src/NadekoBot/Modules/Gambling/Common/AnimalRacing/RaceOptions.cs +++ b/src/NadekoBot/Modules/Gambling/Common/AnimalRacing/RaceOptions.cs @@ -1,7 +1,7 @@ using CommandLine; using NadekoBot.Core.Common; -namespace NadekoBot.Core.Modules.Gambling.Common.AnimalRacing +namespace NadekoBot.Modules.Gambling.Common.AnimalRacing { public class RaceOptions : INadekoCommandOptions { diff --git a/src/NadekoBot/Modules/Gambling/Common/BetRoll.cs b/src/NadekoBot/Modules/Gambling/Common/BetRoll.cs index f25b0580b..5caa8f1ce 100644 --- a/src/NadekoBot/Modules/Gambling/Common/BetRoll.cs +++ b/src/NadekoBot/Modules/Gambling/Common/BetRoll.cs @@ -1,7 +1,7 @@ using System; using System.Linq; -namespace NadekoBot.Core.Modules.Gambling.Common +namespace NadekoBot.Modules.Gambling.Common { public class Betroll { diff --git a/src/NadekoBot/Modules/Gambling/Common/Blackjack/Blackjack.cs b/src/NadekoBot/Modules/Gambling/Common/Blackjack/Blackjack.cs index 8fd0f61ef..ddb151204 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Blackjack/Blackjack.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Blackjack/Blackjack.cs @@ -8,7 +8,7 @@ using NadekoBot.Core.Services; using NadekoBot.Modules.Gambling.Common; using Serilog; -namespace NadekoBot.Core.Modules.Gambling.Common.Blackjack +namespace NadekoBot.Modules.Gambling.Common.Blackjack { public class Blackjack { diff --git a/src/NadekoBot/Modules/Gambling/Common/Blackjack/Player.cs b/src/NadekoBot/Modules/Gambling/Common/Blackjack/Player.cs index 9a5d16b45..f40a37173 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Blackjack/Player.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Blackjack/Player.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace NadekoBot.Core.Modules.Gambling.Common.Blackjack +namespace NadekoBot.Modules.Gambling.Common.Blackjack { public abstract class Player { diff --git a/src/NadekoBot/Modules/Gambling/Common/CurrencyRaffleGame.cs b/src/NadekoBot/Modules/Gambling/Common/CurrencyRaffleGame.cs index 3fe7b1692..aaa19b4f5 100644 --- a/src/NadekoBot/Modules/Gambling/Common/CurrencyRaffleGame.cs +++ b/src/NadekoBot/Modules/Gambling/Common/CurrencyRaffleGame.cs @@ -3,7 +3,7 @@ using NadekoBot.Common; using System.Collections.Generic; using System.Linq; -namespace NadekoBot.Core.Modules.Gambling.Common +namespace NadekoBot.Modules.Gambling.Common { public class CurrencyRaffleGame { diff --git a/src/NadekoBot/Modules/Gambling/Common/Events/EventOptions.cs b/src/NadekoBot/Modules/Gambling/Common/Events/EventOptions.cs index 13803382a..d2df41981 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Events/EventOptions.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Events/EventOptions.cs @@ -1,7 +1,7 @@ using CommandLine; using NadekoBot.Core.Common; -namespace NadekoBot.Core.Modules.Gambling.Common.Events +namespace NadekoBot.Modules.Gambling.Common.Events { public class EventOptions : INadekoCommandOptions { diff --git a/src/NadekoBot/Modules/Gambling/Common/Events/GameStatusEvent.cs b/src/NadekoBot/Modules/Gambling/Common/Events/GameStatusEvent.cs index 4737418fb..f9eab8ddb 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Events/GameStatusEvent.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Events/GameStatusEvent.cs @@ -13,7 +13,7 @@ using System.Threading; using System.Threading.Tasks; using Serilog; -namespace NadekoBot.Core.Modules.Gambling.Common.Events +namespace NadekoBot.Modules.Gambling.Common.Events { public class GameStatusEvent : ICurrencyEvent { diff --git a/src/NadekoBot/Modules/Gambling/Common/Events/ReactionEvent.cs b/src/NadekoBot/Modules/Gambling/Common/Events/ReactionEvent.cs index 728368737..5000909e6 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Events/ReactionEvent.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Events/ReactionEvent.cs @@ -11,10 +11,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Services; using Serilog; -namespace NadekoBot.Core.Modules.Gambling.Common.Events +namespace NadekoBot.Modules.Gambling.Common.Events { public class ReactionEvent : ICurrencyEvent { diff --git a/src/NadekoBot/Modules/Gambling/Common/GamblingConfig.cs b/src/NadekoBot/Modules/Gambling/Common/GamblingConfig.cs index b452b6a8c..4e5d23333 100644 --- a/src/NadekoBot/Modules/Gambling/Common/GamblingConfig.cs +++ b/src/NadekoBot/Modules/Gambling/Common/GamblingConfig.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using NadekoBot.Common.Yml; -namespace NadekoBot.Core.Modules.Gambling.Common +namespace NadekoBot.Modules.Gambling.Common { public sealed class GamblingConfig { diff --git a/src/NadekoBot/Modules/Gambling/Common/GamblingTopLevelModule.cs b/src/NadekoBot/Modules/Gambling/Common/GamblingTopLevelModule.cs index 209ad9a81..62e08871a 100644 --- a/src/NadekoBot/Modules/Gambling/Common/GamblingTopLevelModule.cs +++ b/src/NadekoBot/Modules/Gambling/Common/GamblingTopLevelModule.cs @@ -3,9 +3,9 @@ using Discord; using NadekoBot.Core.Services; using NadekoBot.Modules; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Services; -namespace NadekoBot.Core.Modules.Gambling.Common +namespace NadekoBot.Modules.Gambling.Common { public abstract class GamblingModule : NadekoModule { diff --git a/src/NadekoBot/Modules/Gambling/Common/Payout.cs b/src/NadekoBot/Modules/Gambling/Common/Payout.cs index 5a3ad8764..2a2610d14 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Payout.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Payout.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Gambling.Common +namespace NadekoBot.Modules.Gambling.Common { public class Payout { diff --git a/src/NadekoBot/Modules/Gambling/Common/RollDuelGame.cs b/src/NadekoBot/Modules/Gambling/Common/RollDuelGame.cs index a93d7a895..66e55c1e1 100644 --- a/src/NadekoBot/Modules/Gambling/Common/RollDuelGame.cs +++ b/src/NadekoBot/Modules/Gambling/Common/RollDuelGame.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Gambling.Common +namespace NadekoBot.Modules.Gambling.Common { public class RollDuelGame { diff --git a/src/NadekoBot/Modules/Gambling/Common/Waifu/AffinityTitle.cs b/src/NadekoBot/Modules/Gambling/Common/Waifu/AffinityTitle.cs index 532edda74..9e4c9775a 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Waifu/AffinityTitle.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Waifu/AffinityTitle.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Gambling.Common.Waifu +namespace NadekoBot.Modules.Gambling.Common.Waifu { public enum AffinityTitle { diff --git a/src/NadekoBot/Modules/Gambling/Common/Waifu/ClaimTitle.cs b/src/NadekoBot/Modules/Gambling/Common/Waifu/ClaimTitle.cs index 3cf41d7f3..66b01b4ee 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Waifu/ClaimTitle.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Waifu/ClaimTitle.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Gambling.Common.Waifu +namespace NadekoBot.Modules.Gambling.Common.Waifu { public enum ClaimTitle { diff --git a/src/NadekoBot/Modules/Gambling/Common/Waifu/DivorceResult.cs b/src/NadekoBot/Modules/Gambling/Common/Waifu/DivorceResult.cs index 467ad074a..821cfe05c 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Waifu/DivorceResult.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Waifu/DivorceResult.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Gambling.Common.Waifu +namespace NadekoBot.Modules.Gambling.Common.Waifu { public enum DivorceResult { diff --git a/src/NadekoBot/Modules/Gambling/Common/Waifu/WaifuClaimResult.cs b/src/NadekoBot/Modules/Gambling/Common/Waifu/WaifuClaimResult.cs index 2895874ac..b126a5eed 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Waifu/WaifuClaimResult.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Waifu/WaifuClaimResult.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Gambling.Common.Waifu +namespace NadekoBot.Modules.Gambling.Common.Waifu { public enum WaifuClaimResult { diff --git a/src/NadekoBot/Modules/Gambling/Common/Waifu/WaifuProfileTitle.cs b/src/NadekoBot/Modules/Gambling/Common/Waifu/WaifuProfileTitle.cs index e02a77fde..e9d190735 100644 --- a/src/NadekoBot/Modules/Gambling/Common/Waifu/WaifuProfileTitle.cs +++ b/src/NadekoBot/Modules/Gambling/Common/Waifu/WaifuProfileTitle.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Gambling.Common.Waifu +namespace NadekoBot.Modules.Gambling.Common.Waifu { public struct WaifuProfileTitle { diff --git a/src/NadekoBot/Modules/Gambling/Common/WheelOfFortune/WheelOfFortune.cs b/src/NadekoBot/Modules/Gambling/Common/WheelOfFortune/WheelOfFortune.cs index a3cb5d817..ff532b1a3 100644 --- a/src/NadekoBot/Modules/Gambling/Common/WheelOfFortune/WheelOfFortune.cs +++ b/src/NadekoBot/Modules/Gambling/Common/WheelOfFortune/WheelOfFortune.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; using NadekoBot.Common; -using NadekoBot.Core.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Common; using NadekoBot.Core.Services; namespace NadekoBot.Modules.Gambling.Common.WheelOfFortune diff --git a/src/NadekoBot/Modules/Gambling/Connect4Commands.cs b/src/NadekoBot/Modules/Gambling/Connect4Commands.cs index f0a0e970e..c3c6231da 100644 --- a/src/NadekoBot/Modules/Gambling/Connect4Commands.cs +++ b/src/NadekoBot/Modules/Gambling/Connect4Commands.cs @@ -2,16 +2,15 @@ using Discord.Commands; using Discord.WebSocket; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Services; +using NadekoBot.Modules.Gambling.Common; using NadekoBot.Extensions; using NadekoBot.Modules.Gambling.Common.Connect4; using NadekoBot.Modules.Gambling.Services; using System.Linq; using System.Text; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Core.Common; +using NadekoBot.Core.Services; namespace NadekoBot.Modules.Gambling { diff --git a/src/NadekoBot/Modules/Gambling/CurrencyEventsCommands.cs b/src/NadekoBot/Modules/Gambling/CurrencyEventsCommands.cs index 22fc3dc0c..2fd632ad4 100644 --- a/src/NadekoBot/Modules/Gambling/CurrencyEventsCommands.cs +++ b/src/NadekoBot/Modules/Gambling/CurrencyEventsCommands.cs @@ -4,12 +4,11 @@ using NadekoBot.Extensions; using System.Threading.Tasks; using NadekoBot.Common.Attributes; using NadekoBot.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Common.Events; +using System; using NadekoBot.Core.Common; using NadekoBot.Core.Services.Database.Models; -using NadekoBot.Core.Modules.Gambling.Common.Events; -using System; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Common; namespace NadekoBot.Modules.Gambling { diff --git a/src/NadekoBot/Modules/Gambling/CurrencyRaffleCommands.cs b/src/NadekoBot/Modules/Gambling/CurrencyRaffleCommands.cs index 64e3bcdb1..d4bfb9a68 100644 --- a/src/NadekoBot/Modules/Gambling/CurrencyRaffleCommands.cs +++ b/src/NadekoBot/Modules/Gambling/CurrencyRaffleCommands.cs @@ -1,11 +1,11 @@ using NadekoBot.Common.Attributes; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Services; using System.Threading.Tasks; using Discord; using NadekoBot.Extensions; using System.Linq; using Discord.Commands; -using NadekoBot.Core.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Common; using NadekoBot.Core.Common; namespace NadekoBot.Modules.Gambling diff --git a/src/NadekoBot/Modules/Gambling/DiceRollCommands.cs b/src/NadekoBot/Modules/Gambling/DiceRollCommands.cs index 861c6389d..0b2341be1 100644 --- a/src/NadekoBot/Modules/Gambling/DiceRollCommands.cs +++ b/src/NadekoBot/Modules/Gambling/DiceRollCommands.cs @@ -2,7 +2,7 @@ using Discord; using Discord.Commands; using NadekoBot.Common; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Services; +using NadekoBot.Services; using NadekoBot.Extensions; using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; +using NadekoBot.Core.Services; using Image = SixLabors.ImageSharp.Image; namespace NadekoBot.Modules.Gambling diff --git a/src/NadekoBot/Modules/Gambling/DrawCommands.cs b/src/NadekoBot/Modules/Gambling/DrawCommands.cs index 32574e85c..d88f2037f 100644 --- a/src/NadekoBot/Modules/Gambling/DrawCommands.cs +++ b/src/NadekoBot/Modules/Gambling/DrawCommands.cs @@ -7,11 +7,12 @@ using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using NadekoBot.Common.Attributes; +using NadekoBot.Core.Services; using NadekoBot.Modules.Gambling.Common; using Image = SixLabors.ImageSharp.Image; using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; -using NadekoBot.Core.Services; +using NadekoBot.Services; namespace NadekoBot.Modules.Gambling { diff --git a/src/NadekoBot/Modules/Gambling/FlipCoinCommands.cs b/src/NadekoBot/Modules/Gambling/FlipCoinCommands.cs index 8fbbc2ecd..81e2fbaa7 100644 --- a/src/NadekoBot/Modules/Gambling/FlipCoinCommands.cs +++ b/src/NadekoBot/Modules/Gambling/FlipCoinCommands.cs @@ -2,9 +2,7 @@ using Discord; using Discord.Commands; using NadekoBot.Common; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Services; +using NadekoBot.Modules.Gambling.Common; using NadekoBot.Extensions; using NadekoBot.Modules.Gambling.Services; using SixLabors.ImageSharp; @@ -12,7 +10,8 @@ using SixLabors.ImageSharp.PixelFormats; using System; using System.Linq; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Core.Common; +using NadekoBot.Core.Services; using Image = SixLabors.ImageSharp.Image; namespace NadekoBot.Modules.Gambling diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 305f5383d..36a8d61f1 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -3,10 +3,8 @@ using Discord.Commands; using Discord.WebSocket; using NadekoBot.Common; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Services; -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Modules.Gambling.Common; +using NadekoBot.Services.Database.Models; using NadekoBot.Extensions; using NadekoBot.Modules.Gambling.Services; using System; @@ -15,8 +13,10 @@ using System.Globalization; using System.Linq; using System.Numerics; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Core.Common; +using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database; +using NadekoBot.Core.Services.Database.Models; namespace NadekoBot.Modules.Gambling { diff --git a/src/NadekoBot/Modules/Gambling/Services/BlackJackService.cs b/src/NadekoBot/Modules/Gambling/Services/BlackJackService.cs index 10c89eebf..a056d9523 100644 --- a/src/NadekoBot/Modules/Gambling/Services/BlackJackService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/BlackJackService.cs @@ -1,8 +1,8 @@ -using NadekoBot.Core.Modules.Gambling.Common.Blackjack; +using NadekoBot.Modules.Gambling.Common.Blackjack; using NadekoBot.Core.Services; using System.Collections.Concurrent; -namespace NadekoBot.Core.Modules.Gambling.Services +namespace NadekoBot.Modules.Gambling.Services { public class BlackJackService : INService { diff --git a/src/NadekoBot/Modules/Gambling/Services/CurrencyEventsService.cs b/src/NadekoBot/Modules/Gambling/Services/CurrencyEventsService.cs index 2ffd295ec..6c0b23325 100644 --- a/src/NadekoBot/Modules/Gambling/Services/CurrencyEventsService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/CurrencyEventsService.cs @@ -1,5 +1,5 @@ using NadekoBot.Core.Services; -using NadekoBot.Core.Modules.Gambling.Common.Events; +using NadekoBot.Modules.Gambling.Common.Events; using System.Collections.Concurrent; using NadekoBot.Modules.Gambling.Common; using Discord; @@ -10,7 +10,7 @@ using NadekoBot.Core.Services.Database.Models; using System.Net.Http; using Newtonsoft.Json; using System.Linq; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Services; using Serilog; namespace NadekoBot.Modules.Gambling.Services diff --git a/src/NadekoBot/Modules/Gambling/Services/CurrencyRaffleService.cs b/src/NadekoBot/Modules/Gambling/Services/CurrencyRaffleService.cs index 4773ff7f5..a3f71c7cb 100644 --- a/src/NadekoBot/Modules/Gambling/Services/CurrencyRaffleService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/CurrencyRaffleService.cs @@ -1,13 +1,13 @@ using System.Threading.Tasks; using NadekoBot.Core.Services; -using NadekoBot.Core.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Common; using System.Threading; using System.Linq; using System.Collections.Generic; using Discord; using System; -namespace NadekoBot.Core.Modules.Gambling.Services +namespace NadekoBot.Modules.Gambling.Services { public class CurrencyRaffleService : INService { diff --git a/src/NadekoBot/Modules/Gambling/Services/GamblingConfigService.cs b/src/NadekoBot/Modules/Gambling/Services/GamblingConfigService.cs index dd410d239..2459deb9c 100644 --- a/src/NadekoBot/Modules/Gambling/Services/GamblingConfigService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/GamblingConfigService.cs @@ -1,9 +1,9 @@ using NadekoBot.Core.Common; using NadekoBot.Core.Common.Configs; -using NadekoBot.Core.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Common; using NadekoBot.Core.Services; -namespace NadekoBot.Core.Modules.Gambling.Services +namespace NadekoBot.Modules.Gambling.Services { public sealed class GamblingConfigService : ConfigServiceBase { diff --git a/src/NadekoBot/Modules/Gambling/Services/GamblingService.cs b/src/NadekoBot/Modules/Gambling/Services/GamblingService.cs index 8cc9040fb..2d225188c 100644 --- a/src/NadekoBot/Modules/Gambling/Services/GamblingService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/GamblingService.cs @@ -1,5 +1,5 @@ using Discord.WebSocket; -using NadekoBot.Core.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Common; using NadekoBot.Core.Services; using NadekoBot.Modules.Gambling.Common.Connect4; using NadekoBot.Modules.Gambling.Common.WheelOfFortune; @@ -10,7 +10,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Services; using Serilog; namespace NadekoBot.Modules.Gambling.Services diff --git a/src/NadekoBot/Modules/Gambling/Services/IShopService.cs b/src/NadekoBot/Modules/Gambling/Services/IShopService.cs index 50367aa6f..e9b33d67b 100644 --- a/src/NadekoBot/Modules/Gambling/Services/IShopService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/IShopService.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Gambling.Services +namespace NadekoBot.Modules.Gambling.Services { public interface IShopService { diff --git a/src/NadekoBot/Modules/Gambling/Services/Impl/ShopService.cs b/src/NadekoBot/Modules/Gambling/Services/Impl/ShopService.cs index a19dc75b8..087deadfc 100644 --- a/src/NadekoBot/Modules/Gambling/Services/Impl/ShopService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/Impl/ShopService.cs @@ -6,8 +6,9 @@ using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database; using NadekoBot.Core.Services.Database.Models; using NadekoBot.Extensions; +using NadekoBot.Modules.Administration; -namespace NadekoBot.Core.Modules.Gambling.Services +namespace NadekoBot.Modules.Gambling.Services { public class ShopService : IShopService { @@ -19,7 +20,7 @@ namespace NadekoBot.Core.Modules.Gambling.Services } private IndexedCollection GetEntriesInternal(IUnitOfWork uow, ulong guildId) => - uow.GuildConfigs.ForId( + uow._context.GuildConfigsForId( guildId, set => set.Include(x => x.ShopEntries).ThenInclude(x => x.Items) ) diff --git a/src/NadekoBot/Modules/Gambling/Services/PlantPickService.cs b/src/NadekoBot/Modules/Gambling/Services/PlantPickService.cs index 98f4b5560..19b94ccf4 100644 --- a/src/NadekoBot/Modules/Gambling/Services/PlantPickService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/PlantPickService.cs @@ -5,7 +5,6 @@ using NadekoBot.Common; using NadekoBot.Common.Collections; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; -using NadekoBot.Core.Services.Database.Repositories; using NadekoBot.Core.Services.Impl; using NadekoBot.Extensions; using SixLabors.Fonts; @@ -20,7 +19,7 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Administration; using Image = SixLabors.ImageSharp.Image; using Color = SixLabors.ImageSharp.Color; @@ -80,7 +79,7 @@ namespace NadekoBot.Modules.Gambling.Services bool enabled; using (var uow = _db.GetDbContext()) { - var guildConfig = uow.GuildConfigs.ForId(gid, set => set.Include(gc => gc.GenerateCurrencyChannelIds)); + var guildConfig = uow._context.GuildConfigsForId(gid, set => set.Include(gc => gc.GenerateCurrencyChannelIds)); var toAdd = new GCChannelId() { ChannelId = cid }; if (!guildConfig.GenerateCurrencyChannelIds.Contains(toAdd)) @@ -104,11 +103,11 @@ namespace NadekoBot.Modules.Gambling.Services return enabled; } - public IEnumerable GetAllGeneratingChannels() + public IEnumerable GetAllGeneratingChannels() { using (var uow = _db.GetDbContext()) { - var chs = uow.GuildConfigs.GetGeneratingChannels(); + var chs = uow._context.GuildConfigs.GetGeneratingChannels(); return chs; } } diff --git a/src/NadekoBot/Modules/Gambling/Services/WaifuService.cs b/src/NadekoBot/Modules/Gambling/Services/WaifuService.cs index 36ca1dca4..7a97b93ce 100644 --- a/src/NadekoBot/Modules/Gambling/Services/WaifuService.cs +++ b/src/NadekoBot/Modules/Gambling/Services/WaifuService.cs @@ -1,6 +1,6 @@ using Discord; using Microsoft.EntityFrameworkCore; -using NadekoBot.Core.Modules.Gambling.Common.Waifu; +using NadekoBot.Modules.Gambling.Common.Waifu; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; using NadekoBot.Core.Services.Database.Repositories; @@ -8,8 +8,9 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Services; +using NadekoBot.Services.Database.Models; namespace NadekoBot.Modules.Gambling.Services { diff --git a/src/NadekoBot/Modules/Gambling/ShopCommands.cs b/src/NadekoBot/Modules/Gambling/ShopCommands.cs index b8a356d93..5e3a80c45 100644 --- a/src/NadekoBot/Modules/Gambling/ShopCommands.cs +++ b/src/NadekoBot/Modules/Gambling/ShopCommands.cs @@ -8,11 +8,12 @@ using Microsoft.EntityFrameworkCore; using NadekoBot.Common; using NadekoBot.Common.Attributes; using NadekoBot.Common.Collections; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Services; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; using NadekoBot.Extensions; +using NadekoBot.Modules.Administration; using Serilog; namespace NadekoBot.Modules.Gambling @@ -48,7 +49,7 @@ namespace NadekoBot.Modules.Gambling throw new ArgumentOutOfRangeException(nameof(page)); using var uow = _db.GetDbContext(); - var entries = uow.GuildConfigs.ForId(ctx.Guild.Id, + var entries = uow._context.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries .ToIndexed(); @@ -94,7 +95,7 @@ namespace NadekoBot.Modules.Gambling ShopEntry entry; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(ctx.Guild.Id, set => set + var config = uow._context.GuildConfigsForId(ctx.Guild.Id, set => set .Include(x => x.ShopEntries) .ThenInclude(x => x.Items)); var entries = new IndexedCollection(config.ShopEntries); @@ -188,7 +189,7 @@ namespace NadekoBot.Modules.Gambling entry.Price).ConfigureAwait(false); using (var uow = _db.GetDbContext()) { - var entries = new IndexedCollection(uow.GuildConfigs.ForId(ctx.Guild.Id, + var entries = new IndexedCollection(uow._context.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries); entry = entries.ElementAtOrDefault(index); @@ -234,13 +235,13 @@ namespace NadekoBot.Modules.Gambling }; using (var uow = _db.GetDbContext()) { - var entries = new IndexedCollection(uow.GuildConfigs.ForId(ctx.Guild.Id, + var entries = new IndexedCollection(uow._context.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries) { entry }; - uow.GuildConfigs.ForId(ctx.Guild.Id, set => set).ShopEntries = entries; + uow._context.GuildConfigsForId(ctx.Guild.Id, set => set).ShopEntries = entries; uow.SaveChanges(); } await ctx.Channel.EmbedAsync(EntryToEmbed(entry) @@ -262,13 +263,13 @@ namespace NadekoBot.Modules.Gambling }; using (var uow = _db.GetDbContext()) { - var entries = new IndexedCollection(uow.GuildConfigs.ForId(ctx.Guild.Id, + var entries = new IndexedCollection(uow._context.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries) { entry }; - uow.GuildConfigs.ForId(ctx.Guild.Id, set => set).ShopEntries = entries; + uow._context.GuildConfigsForId(ctx.Guild.Id, set => set).ShopEntries = entries; uow.SaveChanges(); } await ctx.Channel.EmbedAsync(EntryToEmbed(entry) @@ -292,7 +293,7 @@ namespace NadekoBot.Modules.Gambling bool added = false; using (var uow = _db.GetDbContext()) { - var entries = new IndexedCollection(uow.GuildConfigs.ForId(ctx.Guild.Id, + var entries = new IndexedCollection(uow._context.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries); entry = entries.ElementAtOrDefault(index); @@ -325,7 +326,7 @@ namespace NadekoBot.Modules.Gambling ShopEntry removed; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(ctx.Guild.Id, set => set + var config = uow._context.GuildConfigsForId(ctx.Guild.Id, set => set .Include(x => x.ShopEntries) .ThenInclude(x => x.Items)); diff --git a/src/NadekoBot/Modules/Gambling/SlotCommands.cs b/src/NadekoBot/Modules/Gambling/SlotCommands.cs index a5a4f21bf..89f8e30ed 100644 --- a/src/NadekoBot/Modules/Gambling/SlotCommands.cs +++ b/src/NadekoBot/Modules/Gambling/SlotCommands.cs @@ -1,7 +1,6 @@ using Discord; using Discord.Commands; using NadekoBot.Extensions; -using NadekoBot.Core.Services; using System; using System.Collections.Generic; using System.Linq; @@ -11,9 +10,9 @@ using System.Threading.Tasks; using NadekoBot.Common; using NadekoBot.Common.Attributes; using NadekoBot.Modules.Gambling.Services; -using NadekoBot.Core.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Common; using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Core.Services; using Image = SixLabors.ImageSharp.Image; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp; diff --git a/src/NadekoBot/Modules/Gambling/WaifuClaimCommands.cs b/src/NadekoBot/Modules/Gambling/WaifuClaimCommands.cs index 0b2d45010..ec2191efd 100644 --- a/src/NadekoBot/Modules/Gambling/WaifuClaimCommands.cs +++ b/src/NadekoBot/Modules/Gambling/WaifuClaimCommands.cs @@ -1,16 +1,13 @@ using Discord; using Discord.Commands; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Modules.Gambling.Common.Waifu; +using NadekoBot.Modules.Gambling.Common.Waifu; using NadekoBot.Extensions; using NadekoBot.Modules.Gambling.Services; using System; using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Internal; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Modules.Gambling.Services; -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Modules.Gambling.Common; namespace NadekoBot.Modules.Gambling { diff --git a/src/NadekoBot/Modules/Gambling/WheelOfFortuneCommands.cs b/src/NadekoBot/Modules/Gambling/WheelOfFortuneCommands.cs index 773ecf2bc..d1ace7a12 100644 --- a/src/NadekoBot/Modules/Gambling/WheelOfFortuneCommands.cs +++ b/src/NadekoBot/Modules/Gambling/WheelOfFortuneCommands.cs @@ -1,14 +1,13 @@ using Discord; using NadekoBot.Common.Attributes; using NadekoBot.Extensions; -using NadekoBot.Core.Services; using System.Threading.Tasks; using Wof = NadekoBot.Modules.Gambling.Common.WheelOfFortune.WheelOfFortuneGame; using NadekoBot.Modules.Gambling.Services; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Common; +using NadekoBot.Modules.Gambling.Common; using System.Collections.Immutable; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Core.Common; +using NadekoBot.Core.Services; namespace NadekoBot.Modules.Gambling { diff --git a/src/NadekoBot/Modules/Games/CleverBotCommands.cs b/src/NadekoBot/Modules/Games/CleverBotCommands.cs index 62bc6f84e..325552ca8 100644 --- a/src/NadekoBot/Modules/Games/CleverBotCommands.cs +++ b/src/NadekoBot/Modules/Games/CleverBotCommands.cs @@ -1,9 +1,11 @@ using Discord; using Discord.Commands; -using NadekoBot.Core.Services; +using NadekoBot.Services; using System; using System.Threading.Tasks; using NadekoBot.Common.Attributes; +using NadekoBot.Core.Services; +using NadekoBot.Modules.Administration; using NadekoBot.Modules.Games.Services; using NadekoBot.Modules.Games.Common.ChatterBot; @@ -32,7 +34,7 @@ namespace NadekoBot.Modules.Games { using (var uow = _db.GetDbContext()) { - uow.GuildConfigs.SetCleverbotEnabled(ctx.Guild.Id, false); + uow._context.GuildConfigs.SetCleverbotEnabled(ctx.Guild.Id, false); await uow.SaveChangesAsync(); } await ReplyConfirmLocalizedAsync("cleverbot_disabled").ConfigureAwait(false); @@ -43,7 +45,7 @@ namespace NadekoBot.Modules.Games using (var uow = _db.GetDbContext()) { - uow.GuildConfigs.SetCleverbotEnabled(ctx.Guild.Id, true); + uow._context.GuildConfigs.SetCleverbotEnabled(ctx.Guild.Id, true); await uow.SaveChangesAsync(); } diff --git a/src/NadekoBot/Modules/Games/Common/PollRunner.cs b/src/NadekoBot/Modules/Games/Common/PollRunner.cs index 0e5a069c8..a468d1f7c 100644 --- a/src/NadekoBot/Modules/Games/Common/PollRunner.cs +++ b/src/NadekoBot/Modules/Games/Common/PollRunner.cs @@ -1,10 +1,12 @@ using System.Threading.Tasks; using Discord; -using NadekoBot.Core.Services.Database.Models; -using NadekoBot.Core.Services; +using NadekoBot.Services.Database.Models; +using NadekoBot.Services; using System; using System.Linq; using System.Threading; +using NadekoBot.Core.Services; +using NadekoBot.Core.Services.Database.Models; namespace NadekoBot.Modules.Games.Common { diff --git a/src/NadekoBot/Modules/Games/Common/TicTacToe.cs b/src/NadekoBot/Modules/Games/Common/TicTacToe.cs index 2e6569ddd..ee5048e25 100644 --- a/src/NadekoBot/Modules/Games/Common/TicTacToe.cs +++ b/src/NadekoBot/Modules/Games/Common/TicTacToe.cs @@ -6,8 +6,10 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using CommandLine; +using NadekoBot.Common; using NadekoBot.Core.Common; using NadekoBot.Core.Services; +using NadekoBot.Services; namespace NadekoBot.Modules.Games.Common { diff --git a/src/NadekoBot/Modules/Games/Common/Trivia/TriviaGame.cs b/src/NadekoBot/Modules/Games/Common/Trivia/TriviaGame.cs index 0c21a3e9b..ef5977f59 100644 --- a/src/NadekoBot/Modules/Games/Common/Trivia/TriviaGame.cs +++ b/src/NadekoBot/Modules/Games/Common/Trivia/TriviaGame.cs @@ -10,7 +10,7 @@ using Discord.Net; using Discord.WebSocket; using NadekoBot.Extensions; using NadekoBot.Core.Services; -using NadekoBot.Core.Modules.Games.Common.Trivia; +using NadekoBot.Modules.Games.Common.Trivia; using NadekoBot.Modules.Games.Services; using Serilog; diff --git a/src/NadekoBot/Modules/Games/Common/Trivia/TriviaOptions.cs b/src/NadekoBot/Modules/Games/Common/Trivia/TriviaOptions.cs index 320f55411..8e687b5bc 100644 --- a/src/NadekoBot/Modules/Games/Common/Trivia/TriviaOptions.cs +++ b/src/NadekoBot/Modules/Games/Common/Trivia/TriviaOptions.cs @@ -1,7 +1,7 @@ using CommandLine; using NadekoBot.Core.Common; -namespace NadekoBot.Core.Modules.Games.Common.Trivia +namespace NadekoBot.Modules.Games.Common.Trivia { public class TriviaOptions : INadekoCommandOptions { diff --git a/src/NadekoBot/Modules/Games/PlantAndPickCommands.cs b/src/NadekoBot/Modules/Games/PlantAndPickCommands.cs index 5c7f2b3d6..21c76ded4 100644 --- a/src/NadekoBot/Modules/Games/PlantAndPickCommands.cs +++ b/src/NadekoBot/Modules/Games/PlantAndPickCommands.cs @@ -7,8 +7,7 @@ using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.Gambling.Services; using System.Linq; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Common; namespace NadekoBot.Modules.Games { diff --git a/src/NadekoBot/Modules/Games/Services/PollService.cs b/src/NadekoBot/Modules/Games/Services/PollService.cs index 1b504d054..c12db6ca6 100644 --- a/src/NadekoBot/Modules/Games/Services/PollService.cs +++ b/src/NadekoBot/Modules/Games/Services/PollService.cs @@ -6,9 +6,11 @@ using Discord; using Discord.WebSocket; using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Modules.Games.Common; +using NadekoBot.Services; +using NadekoBot.Services.Database.Models; +using NadekoBot.Common.Collections; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; -using NadekoBot.Common.Collections; using NadekoBot.Extensions; using Serilog; diff --git a/src/NadekoBot/Modules/Games/TriviaCommands.cs b/src/NadekoBot/Modules/Games/TriviaCommands.cs index 731eec5d4..7107497a3 100644 --- a/src/NadekoBot/Modules/Games/TriviaCommands.cs +++ b/src/NadekoBot/Modules/Games/TriviaCommands.cs @@ -8,7 +8,6 @@ using NadekoBot.Common.Attributes; using NadekoBot.Modules.Games.Common.Trivia; using NadekoBot.Modules.Games.Services; using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Games.Common.Trivia; namespace NadekoBot.Modules.Games { diff --git a/src/NadekoBot/Modules/Help/Common/CommandsOptions.cs b/src/NadekoBot/Modules/Help/Common/CommandsOptions.cs index abe947e6b..aae49f273 100644 --- a/src/NadekoBot/Modules/Help/Common/CommandsOptions.cs +++ b/src/NadekoBot/Modules/Help/Common/CommandsOptions.cs @@ -1,7 +1,7 @@ using CommandLine; using NadekoBot.Core.Common; -namespace NadekoBot.Core.Modules.Help.Common +namespace NadekoBot.Modules.Help.Common { public class CommandsOptions : INadekoCommandOptions { diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 2229ec6d2..874ece0e6 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -4,7 +4,7 @@ using NadekoBot.Common; using NadekoBot.Common.Attributes; using NadekoBot.Common.Replacements; using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Help.Common; +using NadekoBot.Modules.Help.Common; using NadekoBot.Core.Services; using NadekoBot.Extensions; using NadekoBot.Modules.Help.Services; diff --git a/src/NadekoBot/Modules/Music/Common/ICachableTrackData.cs b/src/NadekoBot/Modules/Music/Common/ICachableTrackData.cs index 8d09e965d..17e3e79d7 100644 --- a/src/NadekoBot/Modules/Music/Common/ICachableTrackData.cs +++ b/src/NadekoBot/Modules/Music/Common/ICachableTrackData.cs @@ -1,6 +1,6 @@ using System; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface ICachableTrackData { diff --git a/src/NadekoBot/Modules/Music/Common/ILocalTrackResolver.cs b/src/NadekoBot/Modules/Music/Common/ILocalTrackResolver.cs index 4a7e5fae9..0d826b716 100644 --- a/src/NadekoBot/Modules/Music/Common/ILocalTrackResolver.cs +++ b/src/NadekoBot/Modules/Music/Common/ILocalTrackResolver.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface ILocalTrackResolver : IPlatformQueryResolver { diff --git a/src/NadekoBot/Modules/Music/Common/IMusicPlayer.cs b/src/NadekoBot/Modules/Music/Common/IMusicPlayer.cs index ab64e3667..8897f170e 100644 --- a/src/NadekoBot/Modules/Music/Common/IMusicPlayer.cs +++ b/src/NadekoBot/Modules/Music/Common/IMusicPlayer.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using NadekoBot.Core.Services.Database.Models; #nullable enable -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface IMusicPlayer : IDisposable { diff --git a/src/NadekoBot/Modules/Music/Common/IMusicQueue.cs b/src/NadekoBot/Modules/Music/Common/IMusicQueue.cs index 81d4ea3d8..f6ff3c553 100644 --- a/src/NadekoBot/Modules/Music/Common/IMusicQueue.cs +++ b/src/NadekoBot/Modules/Music/Common/IMusicQueue.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface IMusicQueue { diff --git a/src/NadekoBot/Modules/Music/Common/IPlatformQueryResolver.cs b/src/NadekoBot/Modules/Music/Common/IPlatformQueryResolver.cs index 53950e710..1867762f8 100644 --- a/src/NadekoBot/Modules/Music/Common/IPlatformQueryResolver.cs +++ b/src/NadekoBot/Modules/Music/Common/IPlatformQueryResolver.cs @@ -1,7 +1,7 @@ #nullable enable using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface IPlatformQueryResolver { diff --git a/src/NadekoBot/Modules/Music/Common/IQueuedTrackInfo.cs b/src/NadekoBot/Modules/Music/Common/IQueuedTrackInfo.cs index 476c7c366..7df45a9dc 100644 --- a/src/NadekoBot/Modules/Music/Common/IQueuedTrackInfo.cs +++ b/src/NadekoBot/Modules/Music/Common/IQueuedTrackInfo.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface IQueuedTrackInfo : ITrackInfo { diff --git a/src/NadekoBot/Modules/Music/Common/IRadioResolver.cs b/src/NadekoBot/Modules/Music/Common/IRadioResolver.cs index 7262c75a2..cf28a9e06 100644 --- a/src/NadekoBot/Modules/Music/Common/IRadioResolver.cs +++ b/src/NadekoBot/Modules/Music/Common/IRadioResolver.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface IRadioResolver : IPlatformQueryResolver { diff --git a/src/NadekoBot/Modules/Music/Common/ISoundcloudResolver.cs b/src/NadekoBot/Modules/Music/Common/ISoundcloudResolver.cs index 2900214e3..1e4b4d739 100644 --- a/src/NadekoBot/Modules/Music/Common/ISoundcloudResolver.cs +++ b/src/NadekoBot/Modules/Music/Common/ISoundcloudResolver.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface ISoundcloudResolver : IPlatformQueryResolver { diff --git a/src/NadekoBot/Modules/Music/Common/ITrackCacher.cs b/src/NadekoBot/Modules/Music/Common/ITrackCacher.cs index a62f5c010..0d14ea65f 100644 --- a/src/NadekoBot/Modules/Music/Common/ITrackCacher.cs +++ b/src/NadekoBot/Modules/Music/Common/ITrackCacher.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface ITrackCacher { diff --git a/src/NadekoBot/Modules/Music/Common/ITrackInfo.cs b/src/NadekoBot/Modules/Music/Common/ITrackInfo.cs index 2362ec683..b22d98aa0 100644 --- a/src/NadekoBot/Modules/Music/Common/ITrackInfo.cs +++ b/src/NadekoBot/Modules/Music/Common/ITrackInfo.cs @@ -2,7 +2,7 @@ using System; using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface ITrackInfo { diff --git a/src/NadekoBot/Modules/Music/Common/ITrackResolveProvider.cs b/src/NadekoBot/Modules/Music/Common/ITrackResolveProvider.cs index 3d6e231ac..5df158184 100644 --- a/src/NadekoBot/Modules/Music/Common/ITrackResolveProvider.cs +++ b/src/NadekoBot/Modules/Music/Common/ITrackResolveProvider.cs @@ -1,7 +1,7 @@ #nullable enable using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface ITrackResolveProvider { diff --git a/src/NadekoBot/Modules/Music/Common/IYoutubeResolver.cs b/src/NadekoBot/Modules/Music/Common/IYoutubeResolver.cs index 3a69b316f..46486af68 100644 --- a/src/NadekoBot/Modules/Music/Common/IYoutubeResolver.cs +++ b/src/NadekoBot/Modules/Music/Common/IYoutubeResolver.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Text.RegularExpressions; using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public interface IYoutubeResolver : IPlatformQueryResolver { diff --git a/src/NadekoBot/Modules/Music/Common/Impl/CachableTrackData.cs b/src/NadekoBot/Modules/Music/Common/Impl/CachableTrackData.cs index 104fcf5b2..00f2566b4 100644 --- a/src/NadekoBot/Modules/Music/Common/Impl/CachableTrackData.cs +++ b/src/NadekoBot/Modules/Music/Common/Impl/CachableTrackData.cs @@ -1,7 +1,7 @@ using System; using System.Text.Json.Serialization; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public sealed class CachableTrackData : ICachableTrackData { diff --git a/src/NadekoBot/Modules/Music/Common/Impl/MultimediaTimer.cs b/src/NadekoBot/Modules/Music/Common/Impl/MultimediaTimer.cs index c091e9914..541aa3195 100644 --- a/src/NadekoBot/Modules/Music/Common/Impl/MultimediaTimer.cs +++ b/src/NadekoBot/Modules/Music/Common/Impl/MultimediaTimer.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; using Serilog; -namespace NadekoBot.Core.Modules.Music.Common +namespace NadekoBot.Modules.Music.Common { public sealed class MultimediaTimer : IDisposable { diff --git a/src/NadekoBot/Modules/Music/Common/Impl/MusicExtensions.cs b/src/NadekoBot/Modules/Music/Common/Impl/MusicExtensions.cs index 0c0008750..c35e0ab2f 100644 --- a/src/NadekoBot/Modules/Music/Common/Impl/MusicExtensions.cs +++ b/src/NadekoBot/Modules/Music/Common/Impl/MusicExtensions.cs @@ -2,7 +2,7 @@ using Discord; using NadekoBot.Extensions; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public static class MusicExtensions { diff --git a/src/NadekoBot/Modules/Music/Common/Impl/MusicPlatform.cs b/src/NadekoBot/Modules/Music/Common/Impl/MusicPlatform.cs index 467572602..e8f442a70 100644 --- a/src/NadekoBot/Modules/Music/Common/Impl/MusicPlatform.cs +++ b/src/NadekoBot/Modules/Music/Common/Impl/MusicPlatform.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public enum MusicPlatform { diff --git a/src/NadekoBot/Modules/Music/Common/Impl/MusicPlayer.cs b/src/NadekoBot/Modules/Music/Common/Impl/MusicPlayer.cs index 1809480ef..7dca92acd 100644 --- a/src/NadekoBot/Modules/Music/Common/Impl/MusicPlayer.cs +++ b/src/NadekoBot/Modules/Music/Common/Impl/MusicPlayer.cs @@ -10,13 +10,13 @@ using System.Threading; using System.Threading.Tasks; using Ayu.Discord.Voice; using NadekoBot.Common; -using NadekoBot.Core.Modules.Music.Common; +using NadekoBot.Modules.Music.Common; using NadekoBot.Core.Services.Database.Models; using NadekoBot.Extensions; using NadekoBot.Modules.Music; using Serilog; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public sealed class MusicPlayer : IMusicPlayer { diff --git a/src/NadekoBot/Modules/Music/Common/Impl/MusicQueue.cs b/src/NadekoBot/Modules/Music/Common/Impl/MusicQueue.cs index 283e334cd..c942eeed1 100644 --- a/src/NadekoBot/Modules/Music/Common/Impl/MusicQueue.cs +++ b/src/NadekoBot/Modules/Music/Common/Impl/MusicQueue.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public sealed partial class MusicQueue { diff --git a/src/NadekoBot/Modules/Music/Common/Impl/RedisTrackCacher.cs b/src/NadekoBot/Modules/Music/Common/Impl/RedisTrackCacher.cs index f7c4c0a55..25be1fe79 100644 --- a/src/NadekoBot/Modules/Music/Common/Impl/RedisTrackCacher.cs +++ b/src/NadekoBot/Modules/Music/Common/Impl/RedisTrackCacher.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Serilog; using StackExchange.Redis; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public sealed class RedisTrackCacher : ITrackCacher { diff --git a/src/NadekoBot/Modules/Music/Common/Impl/RemoteTrackInfo.cs b/src/NadekoBot/Modules/Music/Common/Impl/RemoteTrackInfo.cs index bea57514f..9427ecbed 100644 --- a/src/NadekoBot/Modules/Music/Common/Impl/RemoteTrackInfo.cs +++ b/src/NadekoBot/Modules/Music/Common/Impl/RemoteTrackInfo.cs @@ -2,7 +2,7 @@ using System; using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public sealed class RemoteTrackInfo : ITrackInfo { diff --git a/src/NadekoBot/Modules/Music/Common/Impl/SimpleTrackInfo.cs b/src/NadekoBot/Modules/Music/Common/Impl/SimpleTrackInfo.cs index b99cbb3dc..ec9391aba 100644 --- a/src/NadekoBot/Modules/Music/Common/Impl/SimpleTrackInfo.cs +++ b/src/NadekoBot/Modules/Music/Common/Impl/SimpleTrackInfo.cs @@ -2,7 +2,7 @@ using System; using System.Threading.Tasks; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public sealed class SimpleTrackInfo : ITrackInfo { diff --git a/src/NadekoBot/Modules/Music/Common/Resolvers/LocalTrackResolver.cs b/src/NadekoBot/Modules/Music/Common/Resolvers/LocalTrackResolver.cs index a72cba9ea..915a51851 100644 --- a/src/NadekoBot/Modules/Music/Common/Resolvers/LocalTrackResolver.cs +++ b/src/NadekoBot/Modules/Music/Common/Resolvers/LocalTrackResolver.cs @@ -6,7 +6,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Music; +using NadekoBot.Modules.Music; using NadekoBot.Extensions; using Serilog; diff --git a/src/NadekoBot/Modules/Music/Common/Resolvers/RadioResolveStrategy.cs b/src/NadekoBot/Modules/Music/Common/Resolvers/RadioResolveStrategy.cs index 57f651f28..052c6ee78 100644 --- a/src/NadekoBot/Modules/Music/Common/Resolvers/RadioResolveStrategy.cs +++ b/src/NadekoBot/Modules/Music/Common/Resolvers/RadioResolveStrategy.cs @@ -2,7 +2,7 @@ using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Music; +using NadekoBot.Modules.Music; using NadekoBot.Extensions; using Serilog; diff --git a/src/NadekoBot/Modules/Music/Common/Resolvers/SoundcloudResolver.cs b/src/NadekoBot/Modules/Music/Common/Resolvers/SoundcloudResolver.cs index f2a1ee47d..d96ce5af9 100644 --- a/src/NadekoBot/Modules/Music/Common/Resolvers/SoundcloudResolver.cs +++ b/src/NadekoBot/Modules/Music/Common/Resolvers/SoundcloudResolver.cs @@ -3,9 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Runtime.CompilerServices; -using NadekoBot.Core.Services.Impl; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Music; +using NadekoBot.Core.Services.Impl; using NadekoBot.Extensions; using Newtonsoft.Json.Linq; diff --git a/src/NadekoBot/Modules/Music/Common/Resolvers/TrackResolveProvider.cs b/src/NadekoBot/Modules/Music/Common/Resolvers/TrackResolveProvider.cs index 13b7a1baa..3aa42948f 100644 --- a/src/NadekoBot/Modules/Music/Common/Resolvers/TrackResolveProvider.cs +++ b/src/NadekoBot/Modules/Music/Common/Resolvers/TrackResolveProvider.cs @@ -3,7 +3,7 @@ using System; using System.Threading.Tasks; using Serilog; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public sealed class TrackResolveProvider : ITrackResolveProvider { diff --git a/src/NadekoBot/Modules/Music/Common/Resolvers/YtdlYoutubeResolver.cs b/src/NadekoBot/Modules/Music/Common/Resolvers/YtdlYoutubeResolver.cs index 1b34df0d6..af073ff9e 100644 --- a/src/NadekoBot/Modules/Music/Common/Resolvers/YtdlYoutubeResolver.cs +++ b/src/NadekoBot/Modules/Music/Common/Resolvers/YtdlYoutubeResolver.cs @@ -10,7 +10,7 @@ using NadekoBot.Core.Services.Impl; using NadekoBot.Extensions; using Serilog; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public sealed class YtdlYoutubeResolver : IYoutubeResolver { diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index a12d329af..62e8701cc 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -13,7 +13,7 @@ using NadekoBot.Modules; using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.Music.Services; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { [NoPublicBot] public sealed partial class Music : NadekoModule diff --git a/src/NadekoBot/Modules/Music/PlaylistCommands.cs b/src/NadekoBot/Modules/Music/PlaylistCommands.cs index 36068520f..4e76bcf3d 100644 --- a/src/NadekoBot/Modules/Music/PlaylistCommands.cs +++ b/src/NadekoBot/Modules/Music/PlaylistCommands.cs @@ -8,13 +8,15 @@ using Discord.Commands; using NadekoBot.Common.Attributes; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services; +using NadekoBot.Services.Database.Models; using NadekoBot.Extensions; using NadekoBot.Modules; using NadekoBot.Modules.Music; using NadekoBot.Modules.Music.Services; using Serilog; -namespace NadekoBot.Core.Modules.Music +namespace NadekoBot.Modules.Music { public sealed partial class Music { diff --git a/src/NadekoBot/Modules/Music/Services/IMusicService.cs b/src/NadekoBot/Modules/Music/Services/IMusicService.cs index 88648c459..67c82c471 100644 --- a/src/NadekoBot/Modules/Music/Services/IMusicService.cs +++ b/src/NadekoBot/Modules/Music/Services/IMusicService.cs @@ -4,7 +4,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using Discord; using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Music; +using NadekoBot.Modules.Music; using NadekoBot.Core.Services.Database.Models; namespace NadekoBot.Modules.Music.Services diff --git a/src/NadekoBot/Modules/Music/Services/MusicService.cs b/src/NadekoBot/Modules/Music/Services/MusicService.cs index d3b10d5d5..4ccf03d10 100644 --- a/src/NadekoBot/Modules/Music/Services/MusicService.cs +++ b/src/NadekoBot/Modules/Music/Services/MusicService.cs @@ -7,10 +7,13 @@ using System.Linq; using System.Threading.Tasks; using Discord; using Discord.WebSocket; -using NadekoBot.Core.Modules.Music; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; using NadekoBot.Core.Services.Database.Repositories.Impl; +using NadekoBot.Modules.Music; +using NadekoBot.Services; +using NadekoBot.Services.Database.Models; +using NadekoBot.Services.Database.Repositories.Impl; using NadekoBot.Extensions; using Serilog; diff --git a/src/NadekoBot/Modules/Music/Services/_OldMusicService.cs b/src/NadekoBot/Modules/Music/Services/_OldMusicService.cs index d4384544c..43da0fc32 100644 --- a/src/NadekoBot/Modules/Music/Services/_OldMusicService.cs +++ b/src/NadekoBot/Modules/Music/Services/_OldMusicService.cs @@ -82,7 +82,7 @@ // { // using (var uow = _db.GetDbContext()) // { -// return uow.GuildConfigs.ForId(guildId, set => set).DefaultMusicVolume; +// return uow._context.GuildConfigsForId(guildId, set => set).DefaultMusicVolume; // } // }); // } @@ -256,7 +256,7 @@ // bool val; // using (var uow = _db.GetDbContext()) // { -// var gc = uow.GuildConfigs.ForId(id, set => set); +// var gc = uow._context.GuildConfigsForId(id, set => set); // val = gc.AutoDcFromVc = !gc.AutoDcFromVc; // uow.SaveChanges(); // } @@ -278,7 +278,7 @@ // { // using (var uow = _db.GetDbContext()) // { -// var ms = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.MusicSettings)).MusicSettings; +// var ms = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.MusicSettings)).MusicSettings; // ms.MusicChannelId = cid; // uow.SaveChanges(); // } @@ -288,7 +288,7 @@ // { // using (var uow = _db.GetDbContext()) // { -// var ms = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.MusicSettings)).MusicSettings; +// var ms = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.MusicSettings)).MusicSettings; // ms.SongAutoDelete = val; // uow.SaveChanges(); // } diff --git a/src/NadekoBot/Modules/Music/_OldMusic.cs b/src/NadekoBot/Modules/Music/_OldMusic.cs index 21f34f981..7ffcb3114 100644 --- a/src/NadekoBot/Modules/Music/_OldMusic.cs +++ b/src/NadekoBot/Modules/Music/_OldMusic.cs @@ -395,7 +395,7 @@ // } // using (var uow = _db.GetDbContext()) // { -// uow.GuildConfigs.ForId(ctx.Guild.Id, set => set).DefaultMusicVolume = val / 100.0f; +// uow._context.GuildConfigsForId(ctx.Guild.Id, set => set).DefaultMusicVolume = val / 100.0f; // uow.SaveChanges(); // } // await ReplyConfirmLocalizedAsync("defvol_set", val).ConfigureAwait(false); diff --git a/src/NadekoBot/Modules/Nsfw/Nsfw.cs b/src/NadekoBot/Modules/Nsfw/Nsfw.cs index d0517c435..49328a3ae 100644 --- a/src/NadekoBot/Modules/Nsfw/Nsfw.cs +++ b/src/NadekoBot/Modules/Nsfw/Nsfw.cs @@ -12,7 +12,6 @@ using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Searches.Common; using Serilog; namespace NadekoBot.Modules.NSFW diff --git a/src/NadekoBot/Modules/Permissions/CmdCdsCommands.cs b/src/NadekoBot/Modules/Permissions/CmdCdsCommands.cs index 349e265e7..1b552a437 100644 --- a/src/NadekoBot/Modules/Permissions/CmdCdsCommands.cs +++ b/src/NadekoBot/Modules/Permissions/CmdCdsCommands.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using NadekoBot.Common.Attributes; using NadekoBot.Common.Collections; using NadekoBot.Common.TypeReaders; +using NadekoBot.Modules.Administration; using NadekoBot.Modules.Permissions.Services; namespace NadekoBot.Modules.Permissions @@ -47,7 +48,7 @@ namespace NadekoBot.Modules.Permissions var name = command.Name.ToLowerInvariant(); using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(channel.Guild.Id, set => set.Include(gc => gc.CommandCooldowns)); + var config = uow._context.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.CommandCooldowns)); var localSet = CommandCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet()); var toDelete = config.CommandCooldowns.FirstOrDefault(cc => cc.CommandName == name); diff --git a/src/NadekoBot/Modules/Permissions/FilterCommands.cs b/src/NadekoBot/Modules/Permissions/FilterCommands.cs index 82f35daeb..91d31babe 100644 --- a/src/NadekoBot/Modules/Permissions/FilterCommands.cs +++ b/src/NadekoBot/Modules/Permissions/FilterCommands.cs @@ -9,6 +9,7 @@ using NadekoBot.Common.Attributes; using NadekoBot.Common.Collections; using NadekoBot.Modules.Permissions.Services; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Modules.Administration; namespace NadekoBot.Modules.Permissions { @@ -42,7 +43,7 @@ namespace NadekoBot.Modules.Permissions bool enabled; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(channel.Guild.Id, set => set); + var config = uow._context.GuildConfigsForId(channel.Guild.Id, set => set); enabled = config.FilterInvites = !config.FilterInvites; await uow.SaveChangesAsync(); } @@ -68,7 +69,7 @@ namespace NadekoBot.Modules.Permissions FilterChannelId removed; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(channel.Guild.Id, set => set.Include(gc => gc.FilterInvitesChannelIds)); + var config = uow._context.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterInvitesChannelIds)); var match = new FilterChannelId() { ChannelId = channel.Id @@ -107,7 +108,7 @@ namespace NadekoBot.Modules.Permissions bool enabled; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(channel.Guild.Id, set => set); + var config = uow._context.GuildConfigsForId(channel.Guild.Id, set => set); enabled = config.FilterLinks = !config.FilterLinks; await uow.SaveChangesAsync(); } @@ -133,7 +134,7 @@ namespace NadekoBot.Modules.Permissions FilterLinksChannelId removed; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(channel.Guild.Id, set => set.Include(gc => gc.FilterLinksChannelIds)); + var config = uow._context.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterLinksChannelIds)); var match = new FilterLinksChannelId() { ChannelId = channel.Id @@ -172,7 +173,7 @@ namespace NadekoBot.Modules.Permissions bool enabled; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(channel.Guild.Id, set => set); + var config = uow._context.GuildConfigsForId(channel.Guild.Id, set => set); enabled = config.FilterWords = !config.FilterWords; await uow.SaveChangesAsync(); } @@ -198,7 +199,7 @@ namespace NadekoBot.Modules.Permissions FilterChannelId removed; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(channel.Guild.Id, set => set.Include(gc => gc.FilterWordsChannelIds)); + var config = uow._context.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterWordsChannelIds)); var match = new FilterChannelId() { @@ -242,7 +243,7 @@ namespace NadekoBot.Modules.Permissions FilteredWord removed; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(channel.Guild.Id, set => set.Include(gc => gc.FilteredWords)); + var config = uow._context.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilteredWords)); removed = config.FilteredWords.FirstOrDefault(fw => fw.Word.Trim().ToLowerInvariant() == word); diff --git a/src/NadekoBot/Modules/Permissions/Permissions.cs b/src/NadekoBot/Modules/Permissions/Permissions.cs index 4e61bf123..aad21c52a 100644 --- a/src/NadekoBot/Modules/Permissions/Permissions.cs +++ b/src/NadekoBot/Modules/Permissions/Permissions.cs @@ -10,6 +10,7 @@ using Discord.WebSocket; using NadekoBot.Common.Attributes; using NadekoBot.Common.TypeReaders; using NadekoBot.Common.TypeReaders.Models; +using NadekoBot.Modules.Administration; using NadekoBot.Modules.Permissions.Common; using NadekoBot.Modules.Permissions.Services; @@ -30,7 +31,7 @@ namespace NadekoBot.Modules.Permissions { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.GcWithPermissionsv2For(ctx.Guild.Id); + var config = uow._context.GcWithPermissionsv2For(ctx.Guild.Id); if (action == null) action = new PermissionAction(!config.VerbosePermissions); // New behaviour, can toggle. config.VerbosePermissions = action.Value; await uow.SaveChangesAsync(); @@ -72,7 +73,7 @@ namespace NadekoBot.Modules.Permissions using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.GcWithPermissionsv2For(ctx.Guild.Id); + var config = uow._context.GcWithPermissionsv2For(ctx.Guild.Id); config.PermissionRole = role.Id.ToString(); uow.SaveChanges(); _service.UpdateCache(config); @@ -91,7 +92,7 @@ namespace NadekoBot.Modules.Permissions { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.GcWithPermissionsv2For(ctx.Guild.Id); + var config = uow._context.GcWithPermissionsv2For(ctx.Guild.Id); config.PermissionRole = null; await uow.SaveChangesAsync(); _service.UpdateCache(config); @@ -147,7 +148,7 @@ namespace NadekoBot.Modules.Permissions Permissionv2 p; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.GcWithPermissionsv2For(ctx.Guild.Id); + var config = uow._context.GcWithPermissionsv2For(ctx.Guild.Id); var permsCol = new PermissionsCollection(config.Permissions); p = permsCol[index]; permsCol.RemoveAt(index); @@ -178,7 +179,7 @@ namespace NadekoBot.Modules.Permissions Permissionv2 fromPerm; using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.GcWithPermissionsv2For(ctx.Guild.Id); + var config = uow._context.GcWithPermissionsv2For(ctx.Guild.Id); var permsCol = new PermissionsCollection(config.Permissions); var fromFound = from < permsCol.Count; diff --git a/src/NadekoBot/Modules/Permissions/Services/FilterService.cs b/src/NadekoBot/Modules/Permissions/Services/FilterService.cs index c7dbb6bb7..af57d6024 100644 --- a/src/NadekoBot/Modules/Permissions/Services/FilterService.cs +++ b/src/NadekoBot/Modules/Permissions/Services/FilterService.cs @@ -11,6 +11,7 @@ using NadekoBot.Core.Services; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Internal; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Modules.Administration; using Serilog; namespace NadekoBot.Modules.Permissions.Services @@ -46,7 +47,7 @@ namespace NadekoBot.Modules.Permissions.Services { using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.FilteredWords) .Include(x => x.FilterWordsChannelIds)); diff --git a/src/NadekoBot/Modules/Permissions/Services/PermissionsService.cs b/src/NadekoBot/Modules/Permissions/Services/PermissionsService.cs index ff2f8cf37..e291cddfa 100644 --- a/src/NadekoBot/Modules/Permissions/Services/PermissionsService.cs +++ b/src/NadekoBot/Modules/Permissions/Services/PermissionsService.cs @@ -11,6 +11,7 @@ using NadekoBot.Extensions; using NadekoBot.Modules.Permissions.Common; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Modules.Administration; namespace NadekoBot.Modules.Permissions.Services { @@ -34,7 +35,7 @@ namespace NadekoBot.Modules.Permissions.Services using (var uow = _db.GetDbContext()) { - foreach (var x in uow.GuildConfigs.Permissionsv2ForAll(client.Guilds.ToArray().Select(x => x.Id).ToList())) + foreach (var x in uow._context.GuildConfigs.Permissionsv2ForAll(client.Guilds.ToArray().Select(x => x.Id).ToList())) { Cache.TryAdd(x.GuildId, new PermissionCache() { @@ -52,7 +53,7 @@ namespace NadekoBot.Modules.Permissions.Services { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(guildId, + var config = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.Permissions)); UpdateCache(config); } @@ -67,7 +68,7 @@ namespace NadekoBot.Modules.Permissions.Services { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.GcWithPermissionsv2For(guildId); + var config = uow._context.GcWithPermissionsv2For(guildId); //var orderedPerms = new PermissionsCollection(config.Permissions); var max = config.Permissions.Max(x => x.Index); //have to set its index to be the highest foreach (var perm in perms) @@ -174,7 +175,7 @@ namespace NadekoBot.Modules.Permissions.Services { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.GcWithPermissionsv2For(guildId); + var config = uow._context.GcWithPermissionsv2For(guildId); config.Permissions = Permissionv2.GetDefaultPermlist; await uow.SaveChangesAsync(); UpdateCache(config); diff --git a/src/NadekoBot/Modules/Searches/Common/BibleVerses.cs b/src/NadekoBot/Modules/Searches/Common/BibleVerses.cs index f170929b6..91164452e 100644 --- a/src/NadekoBot/Modules/Searches/Common/BibleVerses.cs +++ b/src/NadekoBot/Modules/Searches/Common/BibleVerses.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class BibleVerses { diff --git a/src/NadekoBot/Modules/Searches/Common/CryptoData.cs b/src/NadekoBot/Modules/Searches/Common/CryptoData.cs index 75d533a6e..070f7b507 100644 --- a/src/NadekoBot/Modules/Searches/Common/CryptoData.cs +++ b/src/NadekoBot/Modules/Searches/Common/CryptoData.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using System.Collections.Generic; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class CryptoResponse { diff --git a/src/NadekoBot/Modules/Searches/Common/Gallery.cs b/src/NadekoBot/Modules/Searches/Common/Gallery.cs index bf58ccf1b..c83ee7ca9 100644 --- a/src/NadekoBot/Modules/Searches/Common/Gallery.cs +++ b/src/NadekoBot/Modules/Searches/Common/Gallery.cs @@ -1,6 +1,6 @@ using System; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public sealed class Tag { diff --git a/src/NadekoBot/Modules/Searches/Common/GatariUserResponse.cs b/src/NadekoBot/Modules/Searches/Common/GatariUserResponse.cs index 240289847..15a325337 100644 --- a/src/NadekoBot/Modules/Searches/Common/GatariUserResponse.cs +++ b/src/NadekoBot/Modules/Searches/Common/GatariUserResponse.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class UserData { diff --git a/src/NadekoBot/Modules/Searches/Common/GatariUserStatsResponse.cs b/src/NadekoBot/Modules/Searches/Common/GatariUserStatsResponse.cs index eb91ed560..dbe63d286 100644 --- a/src/NadekoBot/Modules/Searches/Common/GatariUserStatsResponse.cs +++ b/src/NadekoBot/Modules/Searches/Common/GatariUserStatsResponse.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class UserStats { diff --git a/src/NadekoBot/Modules/Searches/Common/HearthstoneCardData.cs b/src/NadekoBot/Modules/Searches/Common/HearthstoneCardData.cs index 0a7f13de9..8101b4562 100644 --- a/src/NadekoBot/Modules/Searches/Common/HearthstoneCardData.cs +++ b/src/NadekoBot/Modules/Searches/Common/HearthstoneCardData.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class HearthstoneCardData { diff --git a/src/NadekoBot/Modules/Searches/Common/MtgData.cs b/src/NadekoBot/Modules/Searches/Common/MtgData.cs index aa1a35208..8c8d630f8 100644 --- a/src/NadekoBot/Modules/Searches/Common/MtgData.cs +++ b/src/NadekoBot/Modules/Searches/Common/MtgData.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class MtgData { diff --git a/src/NadekoBot/Modules/Searches/Common/NhentaiApiModel.cs b/src/NadekoBot/Modules/Searches/Common/NhentaiApiModel.cs index 70073659f..acff5ae2c 100644 --- a/src/NadekoBot/Modules/Searches/Common/NhentaiApiModel.cs +++ b/src/NadekoBot/Modules/Searches/Common/NhentaiApiModel.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public static class NhentaiApiModel { diff --git a/src/NadekoBot/Modules/Searches/Common/OmdbMovie.cs b/src/NadekoBot/Modules/Searches/Common/OmdbMovie.cs index cc5f67c5b..f93b8f0e0 100644 --- a/src/NadekoBot/Modules/Searches/Common/OmdbMovie.cs +++ b/src/NadekoBot/Modules/Searches/Common/OmdbMovie.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class OmdbMovie { diff --git a/src/NadekoBot/Modules/Searches/Common/OsuUserData.cs b/src/NadekoBot/Modules/Searches/Common/OsuUserData.cs index 5a3df36d8..4f16bbd99 100644 --- a/src/NadekoBot/Modules/Searches/Common/OsuUserData.cs +++ b/src/NadekoBot/Modules/Searches/Common/OsuUserData.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class OsuUserData { diff --git a/src/NadekoBot/Modules/Searches/Common/PathOfExileModels.cs b/src/NadekoBot/Modules/Searches/Common/PathOfExileModels.cs index b64d3e296..cebfd7ae3 100644 --- a/src/NadekoBot/Modules/Searches/Common/PathOfExileModels.cs +++ b/src/NadekoBot/Modules/Searches/Common/PathOfExileModels.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using System; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class Account diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/PicartoChannelResponse.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/PicartoChannelResponse.cs index 7bd71a739..122696f6a 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/PicartoChannelResponse.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/PicartoChannelResponse.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class PicartoChannelResponse { diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/StreamData.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/StreamData.cs index 2a03a57ce..1591e0d06 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/StreamData.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/StreamData.cs @@ -1,6 +1,7 @@ using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class StreamData { diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/StreamDataKey.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/StreamDataKey.cs index e89cc9c3e..476419a3c 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/StreamDataKey.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/StreamDataKey.cs @@ -1,6 +1,7 @@ using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public readonly struct StreamDataKey { diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchResponseHelix.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchResponseHelix.cs index c06c4b998..0b3fceca4 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchResponseHelix.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchResponseHelix.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { // // public class TwitchResponse diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchResponseV5.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchResponseV5.cs index 7ebf307e4..ab1ae8259 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchResponseV5.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchResponseV5.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class TwitchResponseV5 { diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchUsersResponseV5.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchUsersResponseV5.cs index c7486f5bb..e7665c0b8 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchUsersResponseV5.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Models/TwitchUsersResponseV5.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class TwitchUsersResponseV5 { diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/NotifChecker.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/NotifChecker.cs index f0112c40d..848c4c057 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/NotifChecker.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/NotifChecker.cs @@ -3,14 +3,15 @@ using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Searches.Common.StreamNotifications.Providers; +using NadekoBot.Modules.Searches.Common.StreamNotifications.Providers; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using Newtonsoft.Json; using Serilog; using StackExchange.Redis; #nullable enable -namespace NadekoBot.Core.Modules.Searches.Common.StreamNotifications +namespace NadekoBot.Modules.Searches.Common.StreamNotifications { public class NotifChecker { diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/PicartoProvider.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/PicartoProvider.cs index 1d53bf02f..4464178d9 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/PicartoProvider.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/PicartoProvider.cs @@ -6,11 +6,12 @@ using System.Net.Http.Headers; using System.Text.RegularExpressions; using System.Threading.Tasks; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using Newtonsoft.Json; using Serilog; #nullable enable -namespace NadekoBot.Core.Modules.Searches.Common.StreamNotifications.Providers +namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers { public class PicartoProvider : Provider { diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/Provider.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/Provider.cs index c3fef85c7..0bcf695b2 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/Provider.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/Provider.cs @@ -4,9 +4,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; #nullable enable -namespace NadekoBot.Core.Modules.Searches.Common.StreamNotifications.Providers +namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers { /// /// Abstract class implemented by providers of all supported platforms diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/TwitchHelixProvider.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/TwitchHelixProvider.cs index 3d3e6a356..3f2e208ff 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/TwitchHelixProvider.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/TwitchHelixProvider.cs @@ -11,7 +11,7 @@ // using Serilog; // using JsonSerializer = System.Text.Json.JsonSerializer; // -// namespace NadekoBot.Core.Modules.Searches.Common.StreamNotifications.Providers +// namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers // { // public sealed class TwitchHelixProvider : Provider // { diff --git a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/TwitchProvider.cs b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/TwitchProvider.cs index 0a0f871bf..6b2c04f45 100644 --- a/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/TwitchProvider.cs +++ b/src/NadekoBot/Modules/Searches/Common/StreamNotifications/Providers/TwitchProvider.cs @@ -5,11 +5,12 @@ using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using Newtonsoft.Json; using Serilog; #nullable enable -namespace NadekoBot.Core.Modules.Searches.Common.StreamNotifications.Providers +namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers { public class TwitchProvider : Provider { diff --git a/src/NadekoBot/Modules/Searches/Common/TimeData.cs b/src/NadekoBot/Modules/Searches/Common/TimeData.cs index ec1102b09..939069af2 100644 --- a/src/NadekoBot/Modules/Searches/Common/TimeData.cs +++ b/src/NadekoBot/Modules/Searches/Common/TimeData.cs @@ -1,6 +1,6 @@ using System; -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class TimeData { diff --git a/src/NadekoBot/Modules/Searches/Common/UrbanDef.cs b/src/NadekoBot/Modules/Searches/Common/UrbanDef.cs index b54d59209..6ca520e6b 100644 --- a/src/NadekoBot/Modules/Searches/Common/UrbanDef.cs +++ b/src/NadekoBot/Modules/Searches/Common/UrbanDef.cs @@ -1,4 +1,4 @@ -namespace NadekoBot.Core.Modules.Searches.Common +namespace NadekoBot.Modules.Searches.Common { public class UrbanResponse { diff --git a/src/NadekoBot/Modules/Searches/CryptoCommands.cs b/src/NadekoBot/Modules/Searches/CryptoCommands.cs index 0c3e93ff3..fc412d595 100644 --- a/src/NadekoBot/Modules/Searches/CryptoCommands.cs +++ b/src/NadekoBot/Modules/Searches/CryptoCommands.cs @@ -1,6 +1,6 @@ using Discord; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Modules.Searches.Services; +using NadekoBot.Modules.Searches.Services; using NadekoBot.Extensions; using System.Threading.Tasks; diff --git a/src/NadekoBot/Modules/Searches/OsuCommands.cs b/src/NadekoBot/Modules/Searches/OsuCommands.cs index 4245fb2ef..b251b6f80 100644 --- a/src/NadekoBot/Modules/Searches/OsuCommands.cs +++ b/src/NadekoBot/Modules/Searches/OsuCommands.cs @@ -9,7 +9,7 @@ using System.Net.Http; using System.Threading.Tasks; using NadekoBot.Common.Attributes; using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Searches.Common; +using NadekoBot.Modules.Searches.Common; using Newtonsoft.Json; using Serilog; diff --git a/src/NadekoBot/Modules/Searches/PathOfExileCommands.cs b/src/NadekoBot/Modules/Searches/PathOfExileCommands.cs index 78416a761..9633f0b7a 100644 --- a/src/NadekoBot/Modules/Searches/PathOfExileCommands.cs +++ b/src/NadekoBot/Modules/Searches/PathOfExileCommands.cs @@ -2,7 +2,7 @@ using Discord.Commands; using Discord.WebSocket; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Modules.Searches.Common; +using NadekoBot.Modules.Searches.Common; using NadekoBot.Extensions; using NadekoBot.Modules.Searches.Services; using Newtonsoft.Json; diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 3ff5b6bfc..4d7adf6aa 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -5,10 +5,9 @@ using Discord.Commands; using Microsoft.Extensions.Caching.Memory; using NadekoBot.Common; using NadekoBot.Common.Attributes; -using NadekoBot.Core.Modules.Searches.Common; +using NadekoBot.Modules.Searches.Common; using NadekoBot.Core.Services; using NadekoBot.Extensions; -using NadekoBot.Modules.Searches.Common; using NadekoBot.Modules.Searches.Services; using Newtonsoft.Json; using Newtonsoft.Json.Linq; diff --git a/src/NadekoBot/Modules/Searches/Services/CryptoService.cs b/src/NadekoBot/Modules/Searches/Services/CryptoService.cs index c036b243f..66ff26b95 100644 --- a/src/NadekoBot/Modules/Searches/Services/CryptoService.cs +++ b/src/NadekoBot/Modules/Searches/Services/CryptoService.cs @@ -1,4 +1,4 @@ -using NadekoBot.Core.Modules.Searches.Common; +using NadekoBot.Modules.Searches.Common; using NadekoBot.Core.Services; using NadekoBot.Extensions; using Newtonsoft.Json; @@ -10,7 +10,7 @@ using System.Threading; using System.Threading.Tasks; using Serilog; -namespace NadekoBot.Core.Modules.Searches.Services +namespace NadekoBot.Modules.Searches.Services { public class CryptoService : INService { diff --git a/src/NadekoBot/Modules/Searches/Services/FeedsService.cs b/src/NadekoBot/Modules/Searches/Services/FeedsService.cs index 2463f07ad..a2fe15047 100644 --- a/src/NadekoBot/Modules/Searches/Services/FeedsService.cs +++ b/src/NadekoBot/Modules/Searches/Services/FeedsService.cs @@ -10,6 +10,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using NadekoBot.Modules.Administration; namespace NadekoBot.Modules.Searches.Services { @@ -166,7 +167,7 @@ namespace NadekoBot.Modules.Searches.Services { using (var uow = _db.GetDbContext()) { - return uow.GuildConfigs.ForId(guildId, + return uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.FeedSubs) .ThenInclude(x => x.GuildConfig)) .FeedSubs @@ -187,7 +188,7 @@ namespace NadekoBot.Modules.Searches.Services using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.FeedSubs) .ThenInclude(x => x.GuildConfig)); @@ -223,7 +224,7 @@ namespace NadekoBot.Modules.Searches.Services using (var uow = _db.GetDbContext()) { - var items = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.FeedSubs)) + var items = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.FeedSubs)) .FeedSubs .OrderBy(x => x.Id) .ToList(); diff --git a/src/NadekoBot/Modules/Searches/Services/SearchesService.cs b/src/NadekoBot/Modules/Searches/Services/SearchesService.cs index 4fdd0f367..7fd91c9c1 100644 --- a/src/NadekoBot/Modules/Searches/Services/SearchesService.cs +++ b/src/NadekoBot/Modules/Searches/Services/SearchesService.cs @@ -2,12 +2,11 @@ using Discord.WebSocket; using Microsoft.EntityFrameworkCore; using NadekoBot.Common; -using NadekoBot.Core.Modules.Searches.Common; +using NadekoBot.Modules.Searches.Common; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; using NadekoBot.Core.Services.Impl; using NadekoBot.Extensions; -using NadekoBot.Modules.Searches.Common; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SixLabors.ImageSharp; @@ -21,16 +20,14 @@ using System.IO; using System.Linq; using System.Net; using System.Net.Http; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; using AngleSharp.Html.Dom; using AngleSharp.Html.Parser; -using Microsoft.EntityFrameworkCore.Internal; +using NadekoBot.Modules.Administration; using Serilog; using HorizontalAlignment = SixLabors.Fonts.HorizontalAlignment; using Image = SixLabors.ImageSharp.Image; -using JsonSerializer = System.Text.Json.JsonSerializer; namespace NadekoBot.Modules.Searches.Services { @@ -413,7 +410,7 @@ namespace NadekoBot.Modules.Searches.Services bool added; using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(y => y.NsfwBlacklistedTags)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(y => y.NsfwBlacklistedTags)); if (gc.NsfwBlacklistedTags.Add(tagObj)) added = true; else diff --git a/src/NadekoBot/Modules/Searches/Services/StreamNotificationService.cs b/src/NadekoBot/Modules/Searches/Services/StreamNotificationService.cs index e3bc6f63a..63c802361 100644 --- a/src/NadekoBot/Modules/Searches/Services/StreamNotificationService.cs +++ b/src/NadekoBot/Modules/Searches/Services/StreamNotificationService.cs @@ -6,8 +6,8 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using NadekoBot.Common; -using NadekoBot.Core.Modules.Searches.Common; -using NadekoBot.Core.Modules.Searches.Common.StreamNotifications; +using NadekoBot.Modules.Searches.Common; +using NadekoBot.Modules.Searches.Common.StreamNotifications; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; using NadekoBot.Extensions; @@ -17,6 +17,8 @@ using Discord; using Discord.WebSocket; using NadekoBot.Common.Collections; using NadekoBot.Common.Replacements; +using NadekoBot.Modules.Administration; +using NadekoBot.Services.Database.Models; using Serilog; namespace NadekoBot.Modules.Searches.Services @@ -318,7 +320,7 @@ namespace NadekoBot.Modules.Searches.Services { using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guild.Id, set => set.Include(x => x.FollowedStreams)); + var gc = uow._context.GuildConfigsForId(guild.Id, set => set.Include(x => x.FollowedStreams)); _offlineNotificationServers.TryRemove(gc.GuildId); @@ -340,7 +342,7 @@ namespace NadekoBot.Modules.Searches.Services int count; using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.FollowedStreams)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.FollowedStreams)); count = gc.FollowedStreams.Count; gc.FollowedStreams.Clear(); uow.SaveChanges(); @@ -409,7 +411,7 @@ namespace NadekoBot.Modules.Searches.Services FollowedStream fs; using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.FollowedStreams)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.FollowedStreams)); // add it to the database fs = new FollowedStream() @@ -479,7 +481,7 @@ namespace NadekoBot.Modules.Searches.Services bool newValue; using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); newValue = gc.NotifyStreamOffline = !gc.NotifyStreamOffline; uow.SaveChanges(); diff --git a/src/NadekoBot/Modules/Searches/Services/YtTrackService.cs b/src/NadekoBot/Modules/Searches/Services/YtTrackService.cs index 8420e9d94..c913afd70 100644 --- a/src/NadekoBot/Modules/Searches/Services/YtTrackService.cs +++ b/src/NadekoBot/Modules/Searches/Services/YtTrackService.cs @@ -1,6 +1,6 @@ using NadekoBot.Core.Services; -namespace NadekoBot.Core.Modules.Searches.Services +namespace NadekoBot.Modules.Searches.Services { // public class YtTrackService : INService // { @@ -88,7 +88,7 @@ namespace NadekoBot.Core.Modules.Searches.Services // // using(var uow = _db.GetDbContext()) // { - // var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.YtFollowedChannels)); + // var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.YtFollowedChannels)); // // // see if this yt channel was already followed on this discord channel // var oldObj = gc.YtFollowedChannels diff --git a/src/NadekoBot/Modules/Searches/StreamNotificationCommands.cs b/src/NadekoBot/Modules/Searches/StreamNotificationCommands.cs index 0bfbc70ac..a9b68d38f 100644 --- a/src/NadekoBot/Modules/Searches/StreamNotificationCommands.cs +++ b/src/NadekoBot/Modules/Searches/StreamNotificationCommands.cs @@ -10,6 +10,8 @@ using NadekoBot.Common.Attributes; using NadekoBot.Extensions; using NadekoBot.Modules.Searches.Services; using Discord.WebSocket; +using NadekoBot.Modules.Administration; +using NadekoBot.Services.Database.Models; namespace NadekoBot.Modules.Searches { @@ -87,8 +89,8 @@ namespace NadekoBot.Modules.Searches List streams = new List(); using (var uow = _db.GetDbContext()) { - var all = uow.GuildConfigs - .ForId(ctx.Guild.Id, set => set.Include(gc => gc.FollowedStreams)) + var all = uow._context + .GuildConfigsForId(ctx.Guild.Id, set => set.Include(gc => gc.FollowedStreams)) .FollowedStreams .OrderBy(x => x.Id) .ToList(); diff --git a/src/NadekoBot/Modules/Searches/YtUploadCommands.cs b/src/NadekoBot/Modules/Searches/YtUploadCommands.cs index 6f12fb1a3..47627aa74 100644 --- a/src/NadekoBot/Modules/Searches/YtUploadCommands.cs +++ b/src/NadekoBot/Modules/Searches/YtUploadCommands.cs @@ -1,8 +1,8 @@ using Discord.Commands; -using NadekoBot.Core.Modules.Searches.Services; +using NadekoBot.Modules.Searches.Services; using NadekoBot.Modules; -namespace NadekoBot.Core.Modules.Searches +namespace NadekoBot.Modules.Searches { public partial class Searches { diff --git a/src/NadekoBot/Modules/Utility/CommandMapCommands.cs b/src/NadekoBot/Modules/Utility/CommandMapCommands.cs index 9aba00d0a..4805728ea 100644 --- a/src/NadekoBot/Modules/Utility/CommandMapCommands.cs +++ b/src/NadekoBot/Modules/Utility/CommandMapCommands.cs @@ -3,13 +3,16 @@ using Discord.Commands; using Discord.WebSocket; using Microsoft.EntityFrameworkCore; using NadekoBot.Extensions; -using NadekoBot.Core.Services; -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services; +using NadekoBot.Services.Database.Models; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using NadekoBot.Common.Attributes; +using NadekoBot.Core.Services; +using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Modules.Administration; using NadekoBot.Modules.Utility.Services; namespace NadekoBot.Modules.Utility @@ -60,7 +63,7 @@ namespace NadekoBot.Modules.Utility using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases)); + var config = uow._context.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases)); var toAdd = new CommandAlias() { Mapping = mapping, @@ -79,7 +82,7 @@ namespace NadekoBot.Modules.Utility { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases)); + var config = uow._context.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases)); config.CommandAliases.Add(new CommandAlias() { Mapping = mapping, @@ -94,7 +97,7 @@ namespace NadekoBot.Modules.Utility { using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigs.ForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases)); + var config = uow._context.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases)); var toAdd = new CommandAlias() { Mapping = mapping, diff --git a/src/NadekoBot/Modules/Utility/Extensions/StreamRoleExtensions.cs b/src/NadekoBot/Modules/Utility/Extensions/StreamRoleExtensions.cs deleted file mode 100644 index de0d3a862..000000000 --- a/src/NadekoBot/Modules/Utility/Extensions/StreamRoleExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using NadekoBot.Core.Services.Database.Models; -using NadekoBot.Core.Services.Database.Repositories; - -namespace NadekoBot.Modules.Utility.Extensions -{ - public static class StreamRoleExtensions - { - /// - /// Gets full stream role settings for the guild with the specified id. - /// - /// - /// Id of the guild to get stream role settings for. - /// - public static StreamRoleSettings GetStreamRoleSettings(this IGuildConfigRepository gc, ulong guildId) - { - var conf = gc.ForId(guildId, set => set.Include(y => y.StreamRole) - .Include(y => y.StreamRole.Whitelist) - .Include(y => y.StreamRole.Blacklist)); - - if (conf.StreamRole == null) - conf.StreamRole = new StreamRoleSettings(); - - return conf.StreamRole; - } - } -} diff --git a/src/NadekoBot/Modules/Utility/InviteCommands.cs b/src/NadekoBot/Modules/Utility/InviteCommands.cs index ba42eb812..f1e339bac 100644 --- a/src/NadekoBot/Modules/Utility/InviteCommands.cs +++ b/src/NadekoBot/Modules/Utility/InviteCommands.cs @@ -3,7 +3,7 @@ using Discord; using Discord.Commands; using NadekoBot.Common.Attributes; using NadekoBot.Core.Common; -using NadekoBot.Core.Modules.Utility.Services; +using NadekoBot.Modules.Utility.Services; using NadekoBot.Extensions; using System.Linq; using System.Threading.Tasks; diff --git a/src/NadekoBot/Modules/Utility/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/QuoteCommands.cs index 9d995a3fa..3bd9038a8 100644 --- a/src/NadekoBot/Modules/Utility/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/QuoteCommands.cs @@ -3,13 +3,16 @@ using Discord.Commands; using NadekoBot.Common; using NadekoBot.Common.Attributes; using NadekoBot.Common.Replacements; -using NadekoBot.Core.Services; -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services; +using NadekoBot.Services.Database.Models; using NadekoBot.Extensions; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using NadekoBot.Core.Services; +using NadekoBot.Core.Services.Database.Models; using NadekoBot.Core.Services.Database.Repositories.Impl; +using NadekoBot.Services.Database.Repositories.Impl; using NadekoBot.Db; namespace NadekoBot.Modules.Utility diff --git a/src/NadekoBot/Modules/Utility/RemindCommands.cs b/src/NadekoBot/Modules/Utility/RemindCommands.cs index a31bae185..0b4587e3b 100644 --- a/src/NadekoBot/Modules/Utility/RemindCommands.cs +++ b/src/NadekoBot/Modules/Utility/RemindCommands.cs @@ -7,6 +7,8 @@ using Discord.Commands; using NadekoBot.Common.Attributes; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services; +using NadekoBot.Services.Database.Models; using NadekoBot.Extensions; using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.Utility.Common; diff --git a/src/NadekoBot/Modules/Utility/RepeatCommands.cs b/src/NadekoBot/Modules/Utility/RepeatCommands.cs index c940217f9..56b896747 100644 --- a/src/NadekoBot/Modules/Utility/RepeatCommands.cs +++ b/src/NadekoBot/Modules/Utility/RepeatCommands.cs @@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Utility var removed = await _service.RemoveByIndexAsync(ctx.Guild.Id, index); if (removed is null) { - await ReplyErrorLocalizedAsync("repeater_remove_failed").ConfigureAwait(false); + await ReplyErrorLocalizedAsync("repeater_remove_fail").ConfigureAwait(false); return; } diff --git a/src/NadekoBot/Modules/Utility/Services/CommandMapService.cs b/src/NadekoBot/Modules/Utility/Services/CommandMapService.cs index 6ebecf620..b2d92d30e 100644 --- a/src/NadekoBot/Modules/Utility/Services/CommandMapService.cs +++ b/src/NadekoBot/Modules/Utility/Services/CommandMapService.cs @@ -5,11 +5,14 @@ using System.Threading.Tasks; using Discord; using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Extensions; -using NadekoBot.Core.Services; -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services; +using NadekoBot.Services.Database.Models; using System; using Discord.WebSocket; using Microsoft.EntityFrameworkCore; +using NadekoBot.Core.Services; +using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Modules.Administration; namespace NadekoBot.Modules.Utility.Services { @@ -50,7 +53,7 @@ namespace NadekoBot.Modules.Utility.Services int count; using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set.Include(x => x.CommandAliases)); + var gc = uow._context.GuildConfigsForId(guildId, set => set.Include(x => x.CommandAliases)); count = gc.CommandAliases.Count; gc.CommandAliases.Clear(); uow.SaveChanges(); diff --git a/src/NadekoBot/Modules/Utility/Services/InviteService.cs b/src/NadekoBot/Modules/Utility/Services/InviteService.cs index ac3f50482..bf2e71d77 100644 --- a/src/NadekoBot/Modules/Utility/Services/InviteService.cs +++ b/src/NadekoBot/Modules/Utility/Services/InviteService.cs @@ -2,7 +2,7 @@ using NadekoBot.Core.Common; using NadekoBot.Core.Services; -namespace NadekoBot.Core.Modules.Utility.Services +namespace NadekoBot.Modules.Utility.Services { public class InviteService : INService { diff --git a/src/NadekoBot/Modules/Utility/Services/PatreonRewardsService.cs b/src/NadekoBot/Modules/Utility/Services/PatreonRewardsService.cs index 2a11c8e1b..e8bdd87c4 100644 --- a/src/NadekoBot/Modules/Utility/Services/PatreonRewardsService.cs +++ b/src/NadekoBot/Modules/Utility/Services/PatreonRewardsService.cs @@ -10,7 +10,7 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Discord; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Services; using NadekoBot.Extensions; using Serilog; diff --git a/src/NadekoBot/Modules/Utility/Services/RepeaterService.cs b/src/NadekoBot/Modules/Utility/Services/RepeaterService.cs index 6a1959e78..af22ad4f5 100644 --- a/src/NadekoBot/Modules/Utility/Services/RepeaterService.cs +++ b/src/NadekoBot/Modules/Utility/Services/RepeaterService.cs @@ -1,8 +1,8 @@ #nullable enable using Discord.WebSocket; using Microsoft.EntityFrameworkCore; -using NadekoBot.Core.Services; -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services; +using NadekoBot.Services.Database.Models; using NadekoBot.Extensions; using System; using System.Collections.Generic; @@ -15,6 +15,8 @@ using NadekoBot.Common; using NadekoBot.Common.Collections; using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.Replacements; +using NadekoBot.Core.Services; +using NadekoBot.Core.Services.Database.Models; using Serilog; namespace NadekoBot.Modules.Utility.Services diff --git a/src/NadekoBot/Modules/Utility/Services/StreamRoleService.cs b/src/NadekoBot/Modules/Utility/Services/StreamRoleService.cs index e73822d21..4a1bbc5c7 100644 --- a/src/NadekoBot/Modules/Utility/Services/StreamRoleService.cs +++ b/src/NadekoBot/Modules/Utility/Services/StreamRoleService.cs @@ -7,11 +7,11 @@ using Discord.WebSocket; using NadekoBot.Extensions; using NadekoBot.Core.Services; using NadekoBot.Core.Services.Database.Models; -using NadekoBot.Modules.Utility.Extensions; using NadekoBot.Common.TypeReaders; using NadekoBot.Modules.Utility.Common; using NadekoBot.Modules.Utility.Common.Exceptions; using Discord.Net; +using NadekoBot.Modules.Administration; using Serilog; namespace NadekoBot.Modules.Utility.Services @@ -81,7 +81,7 @@ namespace NadekoBot.Modules.Utility.Services bool success = false; using (var uow = _db.GetDbContext()) { - var streamRoleSettings = uow.GuildConfigs.GetStreamRoleSettings(guild.Id); + var streamRoleSettings = uow._context.GetStreamRoleSettings(guild.Id); if (listType == StreamRoleListType.Whitelist) { @@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Utility.Services using (var uow = _db.GetDbContext()) { - var streamRoleSettings = uow.GuildConfigs.GetStreamRoleSettings(guild.Id); + var streamRoleSettings = uow._context.GetStreamRoleSettings(guild.Id); streamRoleSettings.Keyword = keyword; UpdateCache(guild.Id, streamRoleSettings); @@ -170,7 +170,7 @@ namespace NadekoBot.Modules.Utility.Services StreamRoleSettings setting; using (var uow = _db.GetDbContext()) { - setting = uow.GuildConfigs.GetStreamRoleSettings(guildId); + setting = uow._context.GetStreamRoleSettings(guildId); } UpdateCache(guildId, setting); @@ -192,7 +192,7 @@ namespace NadekoBot.Modules.Utility.Services StreamRoleSettings setting; using (var uow = _db.GetDbContext()) { - var streamRoleSettings = uow.GuildConfigs.GetStreamRoleSettings(fromRole.Guild.Id); + var streamRoleSettings = uow._context.GetStreamRoleSettings(fromRole.Guild.Id); streamRoleSettings.Enabled = true; streamRoleSettings.AddRoleId = addRole.Id; @@ -219,7 +219,7 @@ namespace NadekoBot.Modules.Utility.Services { using (var uow = _db.GetDbContext()) { - var streamRoleSettings = uow.GuildConfigs.GetStreamRoleSettings(guild.Id); + var streamRoleSettings = uow._context.GetStreamRoleSettings(guild.Id); streamRoleSettings.Enabled = false; streamRoleSettings.AddRoleId = 0; streamRoleSettings.FromRoleId = 0; diff --git a/src/NadekoBot/Modules/Utility/Services/VerboseErrorsService.cs b/src/NadekoBot/Modules/Utility/Services/VerboseErrorsService.cs index 70aac0430..41ae00f8d 100644 --- a/src/NadekoBot/Modules/Utility/Services/VerboseErrorsService.cs +++ b/src/NadekoBot/Modules/Utility/Services/VerboseErrorsService.cs @@ -6,6 +6,7 @@ using NadekoBot.Common.Collections; using NadekoBot.Extensions; using NadekoBot.Modules.Help.Services; using NadekoBot.Core.Services; +using NadekoBot.Modules.Administration; namespace NadekoBot.Modules.Utility.Services { @@ -60,7 +61,7 @@ namespace NadekoBot.Modules.Utility.Services { using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); if (enabled==null) enabled = gc.VerboseErrors = !gc.VerboseErrors; // Old behaviour, now behind a condition else gc.VerboseErrors = (bool)enabled; // New behaviour, just set it. diff --git a/src/NadekoBot/Modules/Xp/Club.cs b/src/NadekoBot/Modules/Xp/Club.cs index b01971d78..27eb34fb4 100644 --- a/src/NadekoBot/Modules/Xp/Club.cs +++ b/src/NadekoBot/Modules/Xp/Club.cs @@ -7,6 +7,7 @@ using NadekoBot.Modules.Xp.Services; using System; using System.Linq; using System.Threading.Tasks; +using NadekoBot.Services.Database.Models; namespace NadekoBot.Modules.Xp { diff --git a/src/NadekoBot/Modules/Xp/Common/FullUserStats.cs b/src/NadekoBot/Modules/Xp/Common/FullUserStats.cs index 7b19685bd..712cce5b4 100644 --- a/src/NadekoBot/Modules/Xp/Common/FullUserStats.cs +++ b/src/NadekoBot/Modules/Xp/Common/FullUserStats.cs @@ -1,4 +1,5 @@ using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; namespace NadekoBot.Modules.Xp { diff --git a/src/NadekoBot/Modules/Xp/Common/XpTemplate.cs b/src/NadekoBot/Modules/Xp/Common/XpTemplate.cs index fb873b458..2bb3eda87 100644 --- a/src/NadekoBot/Modules/Xp/Common/XpTemplate.cs +++ b/src/NadekoBot/Modules/Xp/Common/XpTemplate.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; -namespace NadekoBot.Core.Modules.Xp +namespace NadekoBot.Modules.Xp { public class XpTemplate { diff --git a/src/NadekoBot/Modules/Xp/Services/ClubService.cs b/src/NadekoBot/Modules/Xp/Services/ClubService.cs index 1a1f6f253..44505e747 100644 --- a/src/NadekoBot/Modules/Xp/Services/ClubService.cs +++ b/src/NadekoBot/Modules/Xp/Services/ClubService.cs @@ -1,12 +1,13 @@ -using NadekoBot.Core.Services; +using NadekoBot.Services; using System; using System.Collections.Generic; -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using Discord; using System.Linq; using NadekoBot.Extensions; using System.Net.Http; using System.Threading.Tasks; +using NadekoBot.Core.Services; using NadekoBot.Modules.Xp.Common; namespace NadekoBot.Modules.Xp.Services diff --git a/src/NadekoBot/Modules/Xp/Services/XpService.cs b/src/NadekoBot/Modules/Xp/Services/XpService.cs index de4458de3..8bc3851b1 100644 --- a/src/NadekoBot/Modules/Xp/Services/XpService.cs +++ b/src/NadekoBot/Modules/Xp/Services/XpService.cs @@ -2,9 +2,8 @@ using Discord; using Discord.WebSocket; using NadekoBot.Common; using NadekoBot.Common.Collections; -using NadekoBot.Core.Services; -using NadekoBot.Core.Services.Database.Models; -using NadekoBot.Core.Services.Impl; +using NadekoBot.Services; +using NadekoBot.Services.Database.Models; using NadekoBot.Extensions; using Newtonsoft.Json; using SixLabors.Fonts; @@ -23,7 +22,12 @@ using System.Threading.Tasks; using AngleSharp.Common; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Internal; -using NadekoBot.Core.Modules.Xp; +using NadekoBot.Core.Services; +using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Core.Services.Impl; +using NadekoBot.Modules.Administration; +using NadekoBot.Modules.Xp; +using NadekoBot.Modules.Xp.Common; using Serilog; using StackExchange.Redis; using Image = SixLabors.ImageSharp.Image; @@ -163,7 +167,7 @@ namespace NadekoBot.Modules.Xp.Services //2. (better but much harder) Move everything to the database, and get old and new xp // amounts for every user (in order to give rewards) - var usr = uow.Xp.GetOrCreateUser(item.Key.GuildId, item.Key.User.Id); + var usr = uow._context.GetOrCreateUserXpStats(item.Key.GuildId, item.Key.User.Id); var du = uow.DiscordUsers.GetOrCreate(item.Key.User); var globalXp = du.TotalXp; @@ -197,13 +201,13 @@ namespace NadekoBot.Modules.Xp.Services //give role if (!roleRewards.TryGetValue(usr.GuildId, out var rrews)) { - rrews = uow.GuildConfigs.XpSettingsFor(usr.GuildId).RoleRewards.ToList(); + rrews = uow._context.XpSettingsFor(usr.GuildId).RoleRewards.ToList(); roleRewards.Add(usr.GuildId, rrews); } if (!curRewards.TryGetValue(usr.GuildId, out var crews)) { - crews = uow.GuildConfigs.XpSettingsFor(usr.GuildId).CurrencyRewards.ToList(); + crews = uow._context.XpSettingsFor(usr.GuildId).CurrencyRewards.ToList(); curRewards.Add(usr.GuildId, crews); } @@ -313,7 +317,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - var settings = uow.GuildConfigs.XpSettingsFor(guildId); + var settings = uow._context.XpSettingsFor(guildId); if (amount <= 0) { @@ -346,7 +350,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - return uow.GuildConfigs.XpSettingsFor(id) + return uow._context.XpSettingsFor(id) .CurrencyRewards .ToArray(); } @@ -355,7 +359,7 @@ namespace NadekoBot.Modules.Xp.Services public IEnumerable GetRoleRewards(ulong id) { using var uow = _db.GetDbContext(); - return uow.GuildConfigs.XpSettingsFor(id) + return uow._context.XpSettingsFor(id) .RoleRewards .ToArray(); } @@ -363,7 +367,7 @@ namespace NadekoBot.Modules.Xp.Services public void ResetRoleReward(ulong guildId, int level) { using var uow = _db.GetDbContext(); - var settings = uow.GuildConfigs.XpSettingsFor(guildId); + var settings = uow._context.XpSettingsFor(guildId); var toRemove = settings.RoleRewards.FirstOrDefault(x => x.Level == level); if (toRemove != null) @@ -378,7 +382,7 @@ namespace NadekoBot.Modules.Xp.Services public void SetRoleReward(ulong guildId, int level, ulong roleId, bool remove) { using var uow = _db.GetDbContext(); - var settings = uow.GuildConfigs.XpSettingsFor(guildId); + var settings = uow._context.XpSettingsFor(guildId); var rew = settings.RoleRewards.FirstOrDefault(x => x.Level == level); @@ -405,7 +409,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - return uow.Xp.GetUsersFor(guildId, page); + return uow._context.UserXpStats.GetUsersFor(guildId, page); } } @@ -413,7 +417,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - return uow.Xp.GetTopUserXps(guildId, count); + return uow._context.UserXpStats.GetTopUserXps(guildId, count); } } @@ -429,7 +433,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - var user = uow.Xp.GetOrCreateUser(guildId, userId); + var user = uow._context.GetOrCreateUserXpStats(guildId, userId); user.NotifyOnLevelUp = type; await uow.SaveChangesAsync(); } @@ -439,7 +443,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - var user = uow.Xp.GetOrCreateUser(guildId, userId); + var user = uow._context.GetOrCreateUserXpStats(guildId, userId); return user.NotifyOnLevelUp; } } @@ -653,7 +657,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - var usr = uow.Xp.GetOrCreateUser(guildId, userId); + var usr = uow._context.GetOrCreateUserXpStats(guildId, userId); usr.AwardedXp += amount; @@ -705,8 +709,8 @@ namespace NadekoBot.Modules.Xp.Services du = uow.DiscordUsers.GetOrCreate(user); totalXp = du.TotalXp; globalRank = uow.DiscordUsers.GetUserGlobalRank(user.Id); - guildRank = uow.Xp.GetUserGuildRanking(user.Id, user.GuildId); - stats = uow.Xp.GetOrCreateUser(user.GuildId, user.Id); + guildRank = uow._context.UserXpStats.GetUserGuildRanking(user.Id, user.GuildId); + stats = uow._context.GetOrCreateUserXpStats(user.GuildId, user.Id); await uow.SaveChangesAsync(); } @@ -743,7 +747,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - var xpSetting = uow.GuildConfigs.XpSettingsFor(id); + var xpSetting = uow._context.XpSettingsFor(id); if (_excludedServers.Add(id)) { xpSetting.ServerExcluded = true; @@ -763,7 +767,7 @@ namespace NadekoBot.Modules.Xp.Services var roles = _excludedRoles.GetOrAdd(guildId, _ => new ConcurrentHashSet()); using (var uow = _db.GetDbContext()) { - var xpSetting = uow.GuildConfigs.XpSettingsFor(guildId); + var xpSetting = uow._context.XpSettingsFor(guildId); var excludeObj = new ExcludedItem { ItemId = rId, @@ -800,7 +804,7 @@ namespace NadekoBot.Modules.Xp.Services var channels = _excludedChannels.GetOrAdd(guildId, _ => new ConcurrentHashSet()); using (var uow = _db.GetDbContext()) { - var xpSetting = uow.GuildConfigs.XpSettingsFor(guildId); + var xpSetting = uow._context.XpSettingsFor(guildId); var excludeObj = new ExcludedItem { ItemId = chId, @@ -1196,7 +1200,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - uow.Xp.ResetGuildUserXp(userId, guildId); + uow._context.UserXpStats.ResetGuildUserXp(userId, guildId); uow.SaveChanges(); } } @@ -1205,7 +1209,7 @@ namespace NadekoBot.Modules.Xp.Services { using (var uow = _db.GetDbContext()) { - uow.Xp.ResetGuildXp(guildId); + uow._context.UserXpStats.ResetGuildXp(guildId); uow.SaveChanges(); } } @@ -1213,7 +1217,7 @@ namespace NadekoBot.Modules.Xp.Services public async Task ResetXpRewards(ulong guildId) { using var uow = _db.GetDbContext(); - var guildConfig = uow.GuildConfigs.ForId(guildId, + var guildConfig = uow._context.GuildConfigsForId(guildId, set => set .Include(x => x.XpSettings) .ThenInclude(x => x.CurrencyRewards) diff --git a/src/NadekoBot/Modules/Xp/Xp.cs b/src/NadekoBot/Modules/Xp/Xp.cs index 5758874d6..65eb7a3a9 100644 --- a/src/NadekoBot/Modules/Xp/Xp.cs +++ b/src/NadekoBot/Modules/Xp/Xp.cs @@ -9,7 +9,7 @@ using NadekoBot.Modules.Xp.Services; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Services; namespace NadekoBot.Modules.Xp { diff --git a/src/NadekoBot/Services/CommandHandler.cs b/src/NadekoBot/Services/CommandHandler.cs index 5780bb66f..6cf17b450 100644 --- a/src/NadekoBot/Services/CommandHandler.cs +++ b/src/NadekoBot/Services/CommandHandler.cs @@ -17,6 +17,7 @@ using System.Threading; using System.Threading.Tasks; using NadekoBot.Core.Common.Configs; using NadekoBot.Core.Services.Impl; +using NadekoBot.Modules.Administration; using Serilog; namespace NadekoBot.Core.Services @@ -107,7 +108,7 @@ namespace NadekoBot.Core.Services using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guild.Id, set => set); + var gc = uow._context.GuildConfigsForId(guild.Id, set => set); gc.Prefix = prefix; uow.SaveChanges(); } diff --git a/src/NadekoBot/Services/Database/IUnitOfWork.cs b/src/NadekoBot/Services/Database/IUnitOfWork.cs index 6de6135fc..9dff44478 100644 --- a/src/NadekoBot/Services/Database/IUnitOfWork.cs +++ b/src/NadekoBot/Services/Database/IUnitOfWork.cs @@ -7,10 +7,8 @@ namespace NadekoBot.Core.Services.Database public interface IUnitOfWork : IDisposable { NadekoContext _context { get; } - IGuildConfigRepository GuildConfigs { get; } IWaifuRepository Waifus { get; } IDiscordUserRepository DiscordUsers { get; } - IXpRepository Xp { get; } int SaveChanges(); Task SaveChangesAsync(); diff --git a/src/NadekoBot/Services/Database/Models/ClubInfo.cs b/src/NadekoBot/Services/Database/Models/ClubInfo.cs index b898d6a02..f7f97995d 100644 --- a/src/NadekoBot/Services/Database/Models/ClubInfo.cs +++ b/src/NadekoBot/Services/Database/Models/ClubInfo.cs @@ -1,7 +1,8 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using NadekoBot.Core.Services.Database.Models; -namespace NadekoBot.Core.Services.Database.Models +namespace NadekoBot.Services.Database.Models { public class ClubInfo : DbEntity { diff --git a/src/NadekoBot/Services/Database/Models/DiscordUser.cs b/src/NadekoBot/Services/Database/Models/DiscordUser.cs index d93a3889b..bd9395604 100644 --- a/src/NadekoBot/Services/Database/Models/DiscordUser.cs +++ b/src/NadekoBot/Services/Database/Models/DiscordUser.cs @@ -1,6 +1,7 @@ using System; +using NadekoBot.Core.Services.Database.Models; -namespace NadekoBot.Core.Services.Database.Models +namespace NadekoBot.Services.Database.Models { public class DiscordUser : DbEntity { diff --git a/src/NadekoBot/Services/Database/Models/FollowedStream.cs b/src/NadekoBot/Services/Database/Models/FollowedStream.cs index 4bd131550..421761c7e 100644 --- a/src/NadekoBot/Services/Database/Models/FollowedStream.cs +++ b/src/NadekoBot/Services/Database/Models/FollowedStream.cs @@ -1,7 +1,8 @@ using System; -using NadekoBot.Core.Modules.Searches.Common; +using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Modules.Searches.Common; -namespace NadekoBot.Core.Services.Database.Models +namespace NadekoBot.Services.Database.Models { public class FollowedStream : DbEntity { diff --git a/src/NadekoBot/Services/Database/Models/GuildConfig.cs b/src/NadekoBot/Services/Database/Models/GuildConfig.cs index cfc98a2d8..98149635e 100644 --- a/src/NadekoBot/Services/Database/Models/GuildConfig.cs +++ b/src/NadekoBot/Services/Database/Models/GuildConfig.cs @@ -1,6 +1,7 @@ using System; using NadekoBot.Common.Collections; using System.Collections.Generic; +using NadekoBot.Services.Database.Models; namespace NadekoBot.Core.Services.Database.Models { diff --git a/src/NadekoBot/Services/Database/Models/Waifu.cs b/src/NadekoBot/Services/Database/Models/Waifu.cs index bfacc0f29..66432f232 100644 --- a/src/NadekoBot/Services/Database/Models/Waifu.cs +++ b/src/NadekoBot/Services/Database/Models/Waifu.cs @@ -1,6 +1,7 @@ using NadekoBot.Extensions; using System.Collections.Generic; -using NadekoBot.Core.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Common; +using NadekoBot.Services.Database.Models; namespace NadekoBot.Core.Services.Database.Models { diff --git a/src/NadekoBot/Services/Database/Models/WaifuUpdate.cs b/src/NadekoBot/Services/Database/Models/WaifuUpdate.cs index bfb235154..3bd8ccc9d 100644 --- a/src/NadekoBot/Services/Database/Models/WaifuUpdate.cs +++ b/src/NadekoBot/Services/Database/Models/WaifuUpdate.cs @@ -1,4 +1,6 @@ -namespace NadekoBot.Core.Services.Database.Models +using NadekoBot.Services.Database.Models; + +namespace NadekoBot.Core.Services.Database.Models { public class WaifuUpdate : DbEntity { diff --git a/src/NadekoBot/Services/Database/NadekoContext.cs b/src/NadekoBot/Services/Database/NadekoContext.cs index f735f980f..bfbdf92a1 100644 --- a/src/NadekoBot/Services/Database/NadekoContext.cs +++ b/src/NadekoBot/Services/Database/NadekoContext.cs @@ -6,6 +6,7 @@ using NadekoBot.Core.Services.Impl; using System; using System.IO; using Microsoft.Extensions.Logging; +using NadekoBot.Services.Database.Models; namespace NadekoBot.Core.Services.Database { diff --git a/src/NadekoBot/Services/Database/Repositories/IDiscordUserRepository.cs b/src/NadekoBot/Services/Database/Repositories/IDiscordUserRepository.cs index c96061f41..4827ddefc 100644 --- a/src/NadekoBot/Services/Database/Repositories/IDiscordUserRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/IDiscordUserRepository.cs @@ -4,6 +4,8 @@ using NadekoBot.Core.Services.Database.Models; using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore; +using NadekoBot.Services.Database.Models; +using NadekoBot.Services.Database.Repositories; namespace NadekoBot.Core.Services.Database.Repositories { diff --git a/src/NadekoBot/Services/Database/Repositories/IGuildConfigRepository.cs b/src/NadekoBot/Services/Database/Repositories/IGuildConfigRepository.cs deleted file mode 100644 index 8a65863ab..000000000 --- a/src/NadekoBot/Services/Database/Repositories/IGuildConfigRepository.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using NadekoBot.Core.Services.Database.Models; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace NadekoBot.Core.Services.Database.Repositories -{ - public interface IGuildConfigRepository : IRepository - { - GuildConfig ForId(ulong guildId, Func, IQueryable> includes = null); - GuildConfig LogSettingsFor(ulong guildId); - IEnumerable GetAllGuildConfigs(List availableGuilds); - IEnumerable GetFollowedStreams(List included); - IEnumerable GetFollowedStreams(); - void SetCleverbotEnabled(ulong id, bool cleverbotEnabled); - IEnumerable Permissionsv2ForAll(List include); - GuildConfig GcWithPermissionsv2For(ulong guildId); - XpSettings XpSettingsFor(ulong guildId); - IEnumerable GetGeneratingChannels(); - } - - public class GeneratingChannel - { - public ulong GuildId { get; set; } - public ulong ChannelId { get; set; } - } -} diff --git a/src/NadekoBot/Services/Database/Repositories/IRepository.cs b/src/NadekoBot/Services/Database/Repositories/IRepository.cs index 7d2645da4..bde82d803 100644 --- a/src/NadekoBot/Services/Database/Repositories/IRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/IRepository.cs @@ -1,21 +1,11 @@ using System.Collections.Generic; using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; -namespace NadekoBot.Core.Services.Database.Repositories +namespace NadekoBot.Services.Database.Repositories { public interface IRepository where T : DbEntity { - T GetById(int id); - IEnumerable GetAll(); - void Add(T obj); - void AddRange(params T[] objs); - - void Remove(int id); - void Remove(T obj); - void RemoveRange(params T[] objs); - - void Update(T obj); - void UpdateRange(params T[] objs); } } diff --git a/src/NadekoBot/Services/Database/Repositories/IWaifuRepository.cs b/src/NadekoBot/Services/Database/Repositories/IWaifuRepository.cs index 16c94d52c..d810ffd75 100644 --- a/src/NadekoBot/Services/Database/Repositories/IWaifuRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/IWaifuRepository.cs @@ -3,6 +3,7 @@ using NadekoBot.Core.Services.Database.Models; using System; using System.Collections.Generic; using System.Linq; +using NadekoBot.Services.Database.Repositories; namespace NadekoBot.Core.Services.Database.Repositories { diff --git a/src/NadekoBot/Services/Database/Repositories/IXpRepository.cs b/src/NadekoBot/Services/Database/Repositories/IXpRepository.cs deleted file mode 100644 index 544a6a045..000000000 --- a/src/NadekoBot/Services/Database/Repositories/IXpRepository.cs +++ /dev/null @@ -1,15 +0,0 @@ -using NadekoBot.Core.Services.Database.Models; -using System.Collections.Generic; - -namespace NadekoBot.Core.Services.Database.Repositories -{ - public interface IXpRepository : IRepository - { - UserXpStats GetOrCreateUser(ulong guildId, ulong userId); - int GetUserGuildRanking(ulong userId, ulong guildId); - List GetUsersFor(ulong guildId, int page); - void ResetGuildUserXp(ulong userId, ulong guildId); - void ResetGuildXp(ulong guildId); - List GetTopUserXps(ulong guildId, int count); - } -} diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/ClubExtensions.cs b/src/NadekoBot/Services/Database/Repositories/Impl/ClubExtensions.cs index 7de60f80c..1b1ba27a9 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/ClubExtensions.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/ClubExtensions.cs @@ -2,6 +2,7 @@ using System.Linq; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; +using NadekoBot.Services.Database.Models; namespace NadekoBot.Modules.Xp.Common { diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/CustomReactionsExtensions.cs b/src/NadekoBot/Services/Database/Repositories/Impl/CustomReactionsExtensions.cs index 5c060df76..5710ba464 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/CustomReactionsExtensions.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/CustomReactionsExtensions.cs @@ -1,8 +1,9 @@ -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; using System.Linq; using LinqToDB; +using NadekoBot.Core.Services.Database.Models; namespace NadekoBot.Modules.CustomReactions { diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/DiscordUserRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/DiscordUserRepository.cs index 8b590075d..91077204f 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/DiscordUserRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/DiscordUserRepository.cs @@ -1,11 +1,12 @@ -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using System.Linq; using Microsoft.EntityFrameworkCore; using Discord; using System.Collections.Generic; using System; +using NadekoBot.Core.Services.Database.Repositories; -namespace NadekoBot.Core.Services.Database.Repositories.Impl +namespace NadekoBot.Services.Database.Repositories.Impl { public class DiscordUserRepository : Repository, IDiscordUserRepository { diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigExtensions.cs similarity index 57% rename from src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs rename to src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigExtensions.cs index 18995e9fd..069689d3f 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigExtensions.cs @@ -3,41 +3,38 @@ using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore; using System; -using System.Threading.Tasks; +using NadekoBot.Core.Services.Database; +using NadekoBot.Services.Database.Models; -namespace NadekoBot.Core.Services.Database.Repositories.Impl +namespace NadekoBot.Modules.Administration { - public static class MusicPlayerSettingsExtensions + public static class GuildConfigExtensions { - public static async Task ForGuildAsync(this DbSet settings, ulong guildId) + public class GeneratingChannel { - var toReturn = await settings - .AsQueryable() - .FirstOrDefaultAsync(x => x.GuildId == guildId); - - if (toReturn is null) - { - var newSettings = new MusicPlayerSettings() - { - GuildId = guildId, - PlayerRepeat = PlayerRepeatType.Queue - }; - - await settings.AddAsync(newSettings); - return newSettings; - } - - return toReturn; + public ulong GuildId { get; set; } + public ulong ChannelId { get; set; } } - } - - public class GuildConfigRepository : Repository, IGuildConfigRepository - { - public GuildConfigRepository(DbContext context) : base(context) + + /// + /// Gets full stream role settings for the guild with the specified id. + /// + /// Db Context + /// Id of the guild to get stream role settings for. + /// Guild'p stream role settings + public static StreamRoleSettings GetStreamRoleSettings(this NadekoContext ctx, ulong guildId) { - } + var conf = ctx.GuildConfigsForId(guildId, set => set.Include(y => y.StreamRole) + .Include(y => y.StreamRole.Whitelist) + .Include(y => y.StreamRole.Blacklist)); - private List DefaultWarnPunishments => + if (conf.StreamRole == null) + conf.StreamRole = new StreamRoleSettings(); + + return conf.StreamRole; + } + + private static List DefaultWarnPunishments => new List() { new WarningPunishment() { Count = 3, @@ -49,59 +46,62 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl } }; - public IEnumerable GetAllGuildConfigs(List availableGuilds) => - IncludeEverything() - .AsNoTracking() - .Where(x => availableGuilds.Contains(x.GuildId)) - .ToList(); - - private IQueryable IncludeEverything() + private static IQueryable IncludeEverything(this DbSet configs) { - return _set - .AsQueryable() - .Include(gc => gc.CommandCooldowns) - .Include(gc => gc.FollowedStreams) - .Include(gc => gc.StreamRole) - .Include(gc => gc.NsfwBlacklistedTags) - .Include(gc => gc.XpSettings) + return configs + .AsQueryable() + .Include(gc => gc.CommandCooldowns) + .Include(gc => gc.FollowedStreams) + .Include(gc => gc.StreamRole) + .Include(gc => gc.NsfwBlacklistedTags) + .Include(gc => gc.XpSettings) .ThenInclude(x => x.ExclusionList) - .Include(gc => gc.DelMsgOnCmdChannels) - .Include(gc => gc.ReactionRoleMessages) + .Include(gc => gc.DelMsgOnCmdChannels) + .Include(gc => gc.ReactionRoleMessages) .ThenInclude(x => x.ReactionRoles) ; } + public static IEnumerable GetAllGuildConfigs(this DbSet configs, List availableGuilds) + => configs + .IncludeEverything() + .AsNoTracking() + .Where(x => availableGuilds.Contains(x.GuildId)) + .ToList(); + /// /// Gets and creates if it doesn't exist a config for a guild. /// /// For which guild /// Use to manipulate the set however you want /// Config for the guild - public GuildConfig ForId(ulong guildId, Func, IQueryable> includes) + public static GuildConfig GuildConfigsForId(this NadekoContext ctx, ulong guildId, Func, IQueryable> includes = null) { GuildConfig config; if (includes == null) { - config = IncludeEverything() + config = ctx + .GuildConfigs + .IncludeEverything() .FirstOrDefault(c => c.GuildId == guildId); } else { - var set = includes(_set); + var set = includes(ctx.GuildConfigs); config = set.FirstOrDefault(c => c.GuildId == guildId); } if (config == null) { - _set.Add((config = new GuildConfig + ctx.GuildConfigs.Add((config = new GuildConfig { GuildId = guildId, Permissions = Permissionv2.GetDefaultPermlist, WarningsInitialized = true, WarnPunishments = DefaultWarnPunishments, })); - _context.SaveChanges(); + ctx.SaveChanges(); } if (!config.WarningsInitialized) @@ -113,9 +113,10 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl return config; } - public GuildConfig LogSettingsFor(ulong guildId) + public static GuildConfig LogSettingsFor(this NadekoContext ctx, ulong guildId) { - var config = _set + var config = ctx + .GuildConfigs .AsQueryable() .Include(gc => gc.LogSetting) .ThenInclude(gc => gc.IgnoredChannels) @@ -123,14 +124,14 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl if (config == null) { - _set.Add((config = new GuildConfig + ctx.GuildConfigs.Add((config = new GuildConfig { GuildId = guildId, Permissions = Permissionv2.GetDefaultPermlist, WarningsInitialized = true, WarnPunishments = DefaultWarnPunishments, })); - _context.SaveChanges(); + ctx.SaveChanges(); } if (!config.WarningsInitialized) @@ -141,61 +142,63 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl return config; } - public IEnumerable Permissionsv2ForAll(List include) + public static IEnumerable Permissionsv2ForAll(this DbSet configs, List include) { - var query = _set.AsQueryable() + var query = configs.AsQueryable() .Where(x => include.Contains(x.GuildId)) .Include(gc => gc.Permissions); return query.ToList(); } - public GuildConfig GcWithPermissionsv2For(ulong guildId) + public static GuildConfig GcWithPermissionsv2For(this NadekoContext ctx, ulong guildId) { - var config = _set.AsQueryable() + var config = ctx + .GuildConfigs + .AsQueryable() .Where(gc => gc.GuildId == guildId) .Include(gc => gc.Permissions) .FirstOrDefault(); if (config == null) // if there is no guildconfig, create new one { - _set.Add((config = new GuildConfig + ctx.GuildConfigs.Add((config = new GuildConfig { GuildId = guildId, Permissions = Permissionv2.GetDefaultPermlist })); - _context.SaveChanges(); + ctx.SaveChanges(); } else if (config.Permissions == null || !config.Permissions.Any()) // if no perms, add default ones { config.Permissions = Permissionv2.GetDefaultPermlist; - _context.SaveChanges(); + ctx.SaveChanges(); } return config; } - public IEnumerable GetFollowedStreams() + public static IEnumerable GetFollowedStreams(this DbSet configs) { - return _set + return configs .AsQueryable() .Include(x => x.FollowedStreams) .SelectMany(gc => gc.FollowedStreams) .ToArray(); } - public IEnumerable GetFollowedStreams(List included) + public static IEnumerable GetFollowedStreams(this DbSet configs, List included) { - return _set.AsQueryable() + return configs.AsQueryable() .Where(gc => included.Contains(gc.GuildId)) .Include(gc => gc.FollowedStreams) .SelectMany(gc => gc.FollowedStreams) .ToList(); } - public void SetCleverbotEnabled(ulong id, bool cleverbotEnabled) + public static void SetCleverbotEnabled(this DbSet configs, ulong id, bool cleverbotEnabled) { - var conf = _set.FirstOrDefault(gc => gc.GuildId == id); + var conf = configs.FirstOrDefault(gc => gc.GuildId == id); if (conf == null) return; @@ -203,9 +206,9 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl conf.CleverbotEnabled = cleverbotEnabled; } - public XpSettings XpSettingsFor(ulong guildId) + public static XpSettings XpSettingsFor(this NadekoContext ctx, ulong guildId) { - var gc = ForId(guildId, + var gc = ctx.GuildConfigsForId(guildId, set => set.Include(x => x.XpSettings) .ThenInclude(x => x.RoleRewards) .Include(x => x.XpSettings) @@ -219,9 +222,9 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl return gc.XpSettings; } - public IEnumerable GetGeneratingChannels() + public static IEnumerable GetGeneratingChannels(this DbSet configs) { - return _set + return configs .AsQueryable() .Include(x => x.GenerateCurrencyChannelIds) .Where(x => x.GenerateCurrencyChannelIds.Any()) diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/MusicPlayerSettingsExtensions.cs b/src/NadekoBot/Services/Database/Repositories/Impl/MusicPlayerSettingsExtensions.cs new file mode 100644 index 000000000..f7d1ee061 --- /dev/null +++ b/src/NadekoBot/Services/Database/Repositories/Impl/MusicPlayerSettingsExtensions.cs @@ -0,0 +1,30 @@ +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using NadekoBot.Core.Services.Database.Models; + +namespace NadekoBot.Core.Services.Database.Repositories.Impl +{ + public static class MusicPlayerSettingsExtensions + { + public static async Task ForGuildAsync(this DbSet settings, ulong guildId) + { + var toReturn = await settings + .AsQueryable() + .FirstOrDefaultAsync(x => x.GuildId == guildId); + + if (toReturn is null) + { + var newSettings = new MusicPlayerSettings() + { + GuildId = guildId, + PlayerRepeat = PlayerRepeatType.Queue + }; + + await settings.AddAsync(newSettings); + return newSettings; + } + + return toReturn; + } + } +} \ No newline at end of file diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/MusicPlaylistExtensions.cs b/src/NadekoBot/Services/Database/Repositories/Impl/MusicPlaylistExtensions.cs index 6ebef5158..d6f1d9f83 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/MusicPlaylistExtensions.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/MusicPlaylistExtensions.cs @@ -1,8 +1,9 @@ -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using System; using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore; +using NadekoBot.Core.Services.Database.Models; namespace NadekoBot.Modules.Music { diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/PollExtensions.cs b/src/NadekoBot/Services/Database/Repositories/Impl/PollExtensions.cs index 380d719d5..132a81cb0 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/PollExtensions.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/PollExtensions.cs @@ -1,8 +1,10 @@ -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore; using NadekoBot.Core.Services.Database; +using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database; namespace NadekoBot.Modules.Games.Common { diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/ReminderRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/ReminderExtensions.cs similarity index 100% rename from src/NadekoBot/Services/Database/Repositories/Impl/ReminderRepository.cs rename to src/NadekoBot/Services/Database/Repositories/Impl/ReminderExtensions.cs diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/Repository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/Repository.cs index 972a7ab09..9504e0f85 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/Repository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/Repository.cs @@ -1,9 +1,10 @@ using Microsoft.EntityFrameworkCore; -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using System.Collections.Generic; using System.Linq; +using NadekoBot.Core.Services.Database.Models; -namespace NadekoBot.Core.Services.Database.Repositories.Impl +namespace NadekoBot.Services.Database.Repositories.Impl { public abstract class Repository : IRepository where T : DbEntity { @@ -18,29 +19,5 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl public void Add(T obj) => _set.Add(obj); - - public void AddRange(params T[] objs) => - _set.AddRange(objs); - - public T GetById(int id) => - _set.FirstOrDefault(e => e.Id == id); - - public IEnumerable GetAll() => - _set.ToList(); - - public void Remove(int id) => - _set.Remove(this.GetById(id)); - - public void Remove(T obj) => - _set.Remove(obj); - - public void RemoveRange(params T[] objs) => - _set.RemoveRange(objs); - - public void Update(T obj) => - _set.Update(obj); - - public void UpdateRange(params T[] objs) => - _set.UpdateRange(objs); } } diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/XpRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/UserXpExtensions.cs similarity index 56% rename from src/NadekoBot/Services/Database/Repositories/Impl/XpRepository.cs rename to src/NadekoBot/Services/Database/Repositories/Impl/UserXpExtensions.cs index 89389913c..581c7c8e3 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/XpRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/UserXpExtensions.cs @@ -1,23 +1,23 @@ -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using System.Linq; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; +using LinqToDB; +using NadekoBot.Core.Services.Database; +using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database; -namespace NadekoBot.Core.Services.Database.Repositories.Impl +namespace NadekoBot.Modules.Xp.Common { - public class XpRepository : Repository, IXpRepository + public static class UserXpExtensions { - public XpRepository(DbContext context) : base(context) + public static UserXpStats GetOrCreateUserXpStats(this NadekoContext ctx, ulong guildId, ulong userId) { - } - - public UserXpStats GetOrCreateUser(ulong guildId, ulong userId) - { - var usr = _set.FirstOrDefault(x => x.UserId == userId && x.GuildId == guildId); + var usr = ctx.UserXpStats.FirstOrDefault(x => x.UserId == userId && x.GuildId == guildId); if (usr == null) { - _context.Add(usr = new UserXpStats() + ctx.Add(usr = new UserXpStats() { Xp = 0, UserId = userId, @@ -29,9 +29,9 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl return usr; } - public List GetUsersFor(ulong guildId, int page) + public static List GetUsersFor(this DbSet xps, ulong guildId, int page) { - return _set + return xps .AsQueryable() .AsNoTracking() .Where(x => x.GuildId == guildId) @@ -41,9 +41,9 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl .ToList(); } - public List GetTopUserXps(ulong guildId, int count) + public static List GetTopUserXps(this DbSet xps, ulong guildId, int count) { - return _set + return xps .AsQueryable() .AsNoTracking() .Where(x => x.GuildId == guildId) @@ -52,7 +52,7 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl .ToList(); } - public int GetUserGuildRanking(ulong userId, ulong guildId) + public static int GetUserGuildRanking(this DbSet xps, ulong userId, ulong guildId) { // @"SELECT COUNT(*) + 1 //FROM UserXpStats @@ -61,11 +61,11 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl // WHERE UserId = @p2 AND GuildId = @p1 // LIMIT 1));"; - return _set + return xps .AsQueryable() .AsNoTracking() .Where(x => x.GuildId == guildId && ((x.Xp + x.AwardedXp) > - (_set.AsQueryable() + (xps.AsQueryable() .Where(y => y.UserId == userId && y.GuildId == guildId) .Select(y => y.Xp + y.AwardedXp) .FirstOrDefault()) @@ -73,14 +73,14 @@ namespace NadekoBot.Core.Services.Database.Repositories.Impl .Count() + 1; } - public void ResetGuildUserXp(ulong userId, ulong guildId) + public static void ResetGuildUserXp(this DbSet xps, ulong userId, ulong guildId) { - _context.Database.ExecuteSqlInterpolated($"DELETE FROM UserXpStats WHERE UserId={userId} AND GuildId={guildId};"); + xps.Delete(x => x.UserId == userId && x.GuildId == guildId); } - public void ResetGuildXp(ulong guildId) + public static void ResetGuildXp(this DbSet xps, ulong guildId) { - _context.Database.ExecuteSqlInterpolated($"DELETE FROM UserXpStats WHERE GuildId={guildId};"); + xps.Delete(x => x.GuildId == guildId); } } } diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/WaifuRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/WaifuRepository.cs index 26166680a..9875b5057 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/WaifuRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/WaifuRepository.cs @@ -1,10 +1,12 @@ using Microsoft.EntityFrameworkCore; -using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Services.Database.Models; using System; using System.Collections.Generic; using System.Linq; +using NadekoBot.Core.Services.Database.Models; +using NadekoBot.Core.Services.Database.Repositories; -namespace NadekoBot.Core.Services.Database.Repositories.Impl +namespace NadekoBot.Services.Database.Repositories.Impl { public class WaifuRepository : Repository, IWaifuRepository { diff --git a/src/NadekoBot/Services/Database/UnitOfWork.cs b/src/NadekoBot/Services/Database/UnitOfWork.cs index e50cb20e4..a11d16f03 100644 --- a/src/NadekoBot/Services/Database/UnitOfWork.cs +++ b/src/NadekoBot/Services/Database/UnitOfWork.cs @@ -1,26 +1,22 @@ -using NadekoBot.Core.Services.Database.Repositories; -using NadekoBot.Core.Services.Database.Repositories.Impl; +using NadekoBot.Services.Database.Repositories; +using NadekoBot.Services.Database.Repositories.Impl; using System; using System.Threading.Tasks; +using NadekoBot.Core.Services.Database; +using NadekoBot.Core.Services.Database.Repositories; -namespace NadekoBot.Core.Services.Database +namespace NadekoBot.Services.Database { public sealed class UnitOfWork : IUnitOfWork { public NadekoContext _context { get; } - private IGuildConfigRepository _guildConfigs; - public IGuildConfigRepository GuildConfigs => _guildConfigs ?? (_guildConfigs = new GuildConfigRepository(_context)); - private IWaifuRepository _waifus; public IWaifuRepository Waifus => _waifus ?? (_waifus = new WaifuRepository(_context)); private IDiscordUserRepository _discordUsers; public IDiscordUserRepository DiscordUsers => _discordUsers ?? (_discordUsers = new DiscordUserRepository(_context)); - private IXpRepository _xp; - public IXpRepository Xp => _xp ?? (_xp = new XpRepository(_context)); - public UnitOfWork(NadekoContext context) { _context = context; diff --git a/src/NadekoBot/Services/DbService.cs b/src/NadekoBot/Services/DbService.cs index e5db0e261..694000393 100644 --- a/src/NadekoBot/Services/DbService.cs +++ b/src/NadekoBot/Services/DbService.cs @@ -4,6 +4,7 @@ using NadekoBot.Core.Services.Database; using System; using System.IO; using System.Linq; +using NadekoBot.Services.Database; namespace NadekoBot.Core.Services { diff --git a/src/NadekoBot/Services/GreetSettingsService.cs b/src/NadekoBot/Services/GreetSettingsService.cs index 9a22d7b54..1ee701c50 100644 --- a/src/NadekoBot/Services/GreetSettingsService.cs +++ b/src/NadekoBot/Services/GreetSettingsService.cs @@ -9,6 +9,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using NadekoBot.Modules.Administration; using Serilog; namespace NadekoBot.Core.Services @@ -106,7 +107,7 @@ namespace NadekoBot.Core.Services { using (var uow = _db.GetDbContext()) { - return uow.GuildConfigs.ForId(id, set => set)?.DmGreetMessageText; + return uow._context.GuildConfigsForId(id, set => set)?.DmGreetMessageText; } } @@ -114,7 +115,7 @@ namespace NadekoBot.Core.Services { using (var uow = _db.GetDbContext()) { - return uow.GuildConfigs.ForId(gid, set => set).ChannelGreetMessageText; + return uow._context.GuildConfigsForId(gid, set => set).ChannelGreetMessageText; } } @@ -318,7 +319,7 @@ namespace NadekoBot.Core.Services { using (var uow = _db.GetDbContext()) { - return uow.GuildConfigs.ForId(gid, set => set).ChannelByeMessageText; + return uow._context.GuildConfigsForId(gid, set => set).ChannelByeMessageText; } } @@ -330,7 +331,7 @@ namespace NadekoBot.Core.Services using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); settings = GreetSettings.Create(gc); } @@ -350,7 +351,7 @@ namespace NadekoBot.Core.Services using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); conf.DmGreetMessageText = settings.DmGreetMessageText?.SanitizeMentions(); conf.ChannelGreetMessageText = settings.ChannelGreetMessageText?.SanitizeMentions(); conf.ChannelByeMessageText = settings.ChannelByeMessageText?.SanitizeMentions(); @@ -381,7 +382,7 @@ namespace NadekoBot.Core.Services bool enabled; using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); enabled = conf.SendChannelGreetMessage = value ?? !conf.SendChannelGreetMessage; conf.GreetMessageChannelId = channelId; @@ -403,7 +404,7 @@ namespace NadekoBot.Core.Services bool greetMsgEnabled; using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); conf.ChannelGreetMessageText = message; greetMsgEnabled = conf.SendChannelGreetMessage; @@ -420,7 +421,7 @@ namespace NadekoBot.Core.Services bool enabled; using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); enabled = conf.SendDmGreetMessage = value ?? !conf.SendDmGreetMessage; var toAdd = GreetSettings.Create(conf); @@ -436,7 +437,7 @@ namespace NadekoBot.Core.Services { using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); return conf.SendDmGreetMessage; } } @@ -445,7 +446,7 @@ namespace NadekoBot.Core.Services { using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); return conf.SendChannelGreetMessage; } } @@ -454,7 +455,7 @@ namespace NadekoBot.Core.Services { using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); return conf.SendChannelByeMessage; } } @@ -491,7 +492,7 @@ namespace NadekoBot.Core.Services bool greetMsgEnabled; using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); conf.DmGreetMessageText = message; greetMsgEnabled = conf.SendDmGreetMessage; @@ -508,7 +509,7 @@ namespace NadekoBot.Core.Services bool enabled; using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); enabled = conf.SendChannelByeMessage = value ?? !conf.SendChannelByeMessage; conf.ByeMessageChannelId = channelId; @@ -530,7 +531,7 @@ namespace NadekoBot.Core.Services bool byeMsgEnabled; using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); conf.ChannelByeMessageText = message; byeMsgEnabled = conf.SendChannelByeMessage; @@ -549,7 +550,7 @@ namespace NadekoBot.Core.Services using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(guildId, set => set); + var conf = uow._context.GuildConfigsForId(guildId, set => set); conf.AutoDeleteByeMessagesTimer = timer; var toAdd = GreetSettings.Create(conf); @@ -566,7 +567,7 @@ namespace NadekoBot.Core.Services using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigs.ForId(id, set => set); + var conf = uow._context.GuildConfigsForId(id, set => set); conf.AutoDeleteGreetMessagesTimer = timer; var toAdd = GreetSettings.Create(conf); diff --git a/src/NadekoBot/Services/Impl/CurrencyService.cs b/src/NadekoBot/Services/Impl/CurrencyService.cs index 78e1ac9a2..6536b6cf5 100644 --- a/src/NadekoBot/Services/Impl/CurrencyService.cs +++ b/src/NadekoBot/Services/Impl/CurrencyService.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Services; namespace NadekoBot.Core.Services { diff --git a/src/NadekoBot/Services/Impl/Localization.cs b/src/NadekoBot/Services/Impl/Localization.cs index f07c4ce9c..acb4a3da4 100644 --- a/src/NadekoBot/Services/Impl/Localization.cs +++ b/src/NadekoBot/Services/Impl/Localization.cs @@ -6,6 +6,7 @@ using Discord; using NadekoBot.Common; using Newtonsoft.Json; using System.IO; +using NadekoBot.Modules.Administration; namespace NadekoBot.Core.Services.Impl { @@ -55,7 +56,7 @@ namespace NadekoBot.Core.Services.Impl using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); gc.Locale = ci.Name; uow.SaveChanges(); } @@ -73,7 +74,7 @@ namespace NadekoBot.Core.Services.Impl { using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigs.ForId(guildId, set => set); + var gc = uow._context.GuildConfigsForId(guildId, set => set); gc.Locale = null; uow.SaveChanges(); } diff --git a/src/NadekoBot/Services/NadekoBot.cs b/src/NadekoBot/Services/NadekoBot.cs index d2b38ac68..f78983b1a 100644 --- a/src/NadekoBot/Services/NadekoBot.cs +++ b/src/NadekoBot/Services/NadekoBot.cs @@ -25,7 +25,8 @@ using LinqToDB.EntityFrameworkCore; using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Core.Common; using NadekoBot.Core.Common.Configs; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Administration; +using NadekoBot.Modules.Gambling.Services; using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.CustomReactions.Services; using NadekoBot.Modules.Utility.Services; @@ -135,7 +136,7 @@ namespace NadekoBot public IEnumerable GetCurrentGuildConfigs() { using var uow = _db.GetDbContext(); - return uow.GuildConfigs.GetAllGuildConfigs(GetCurrentGuildIds()).ToImmutableArray(); + return uow._context.GuildConfigs.GetAllGuildConfigs(GetCurrentGuildIds()).ToImmutableArray(); } private void AddServices() @@ -147,7 +148,7 @@ namespace NadekoBot using (var uow = _db.GetDbContext()) { uow.DiscordUsers.EnsureCreated(_bot.Id, _bot.Username, _bot.Discriminator, _bot.AvatarId); - AllGuildConfigs = uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList).ToImmutableArray(); + AllGuildConfigs = uow._context.GuildConfigs.GetAllGuildConfigs(startingGuildIdList).ToImmutableArray(); } var s = new ServiceCollection() @@ -307,13 +308,13 @@ namespace NadekoBot private Task Client_JoinedGuild(SocketGuild arg) { - Log.Information($"Joined server: {0} [{1}]", arg?.Name, arg?.Id); + Log.Information($"Joined server: {0} [{1}]", arg.Name, arg.Id); var _ = Task.Run(async () => { GuildConfig gc; using (var uow = _db.GetDbContext()) { - gc = uow.GuildConfigs.ForId(arg.Id); + gc = uow._context.GuildConfigsForId(arg.Id); } await JoinedGuild.Invoke(gc).ConfigureAwait(false); }); diff --git a/src/NadekoBot/Services/Settings/GamblingConfigMigrator.cs b/src/NadekoBot/Services/Settings/GamblingConfigMigrator.cs index 8de364ec8..51fb79b4e 100644 --- a/src/NadekoBot/Services/Settings/GamblingConfigMigrator.cs +++ b/src/NadekoBot/Services/Settings/GamblingConfigMigrator.cs @@ -1,8 +1,8 @@ using System; using System.Data.Common; using Microsoft.EntityFrameworkCore; -using NadekoBot.Core.Modules.Gambling.Common; -using NadekoBot.Core.Modules.Gambling.Services; +using NadekoBot.Modules.Gambling.Common; +using NadekoBot.Modules.Gambling.Services; using Serilog; namespace NadekoBot.Core.Services diff --git a/src/NadekoBot/_Extensions/IUserExtensions.cs b/src/NadekoBot/_Extensions/IUserExtensions.cs index 9d0da6023..3696c5b18 100644 --- a/src/NadekoBot/_Extensions/IUserExtensions.cs +++ b/src/NadekoBot/_Extensions/IUserExtensions.cs @@ -3,6 +3,7 @@ using NadekoBot.Core.Services.Database.Models; using System; using System.IO; using System.Threading.Tasks; +using NadekoBot.Services.Database.Models; namespace NadekoBot.Extensions {