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

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