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
This commit is contained in:
Kwoth
2021-06-19 03:32:48 +02:00
parent c7ff982ec1
commit 15dac7e3ed
191 changed files with 563 additions and 571 deletions

View File

@@ -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();

View File

@@ -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
{

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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.