mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Fixed .log commands
This commit is contained in:
@@ -113,33 +113,15 @@ namespace NadekoBot.Db
|
||||
return config;
|
||||
}
|
||||
|
||||
public static GuildConfig LogSettingsFor(this NadekoContext ctx, ulong guildId)
|
||||
public static LogSetting LogSettingsFor(this NadekoContext ctx, ulong guildId)
|
||||
{
|
||||
var config = ctx
|
||||
.GuildConfigs
|
||||
var logSetting = ctx.LogSettings
|
||||
.AsQueryable()
|
||||
.Include(gc => gc.LogSetting)
|
||||
.ThenInclude(gc => gc.IgnoredChannels)
|
||||
.FirstOrDefault(x => x.GuildId == guildId);
|
||||
|
||||
if (config is null)
|
||||
{
|
||||
ctx.GuildConfigs.Add((config = new GuildConfig
|
||||
{
|
||||
GuildId = guildId,
|
||||
Permissions = Permissionv2.GetDefaultPermlist,
|
||||
WarningsInitialized = true,
|
||||
WarnPunishments = DefaultWarnPunishments,
|
||||
}));
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
if (!config.WarningsInitialized)
|
||||
{
|
||||
config.WarningsInitialized = true;
|
||||
config.WarnPunishments = DefaultWarnPunishments;
|
||||
}
|
||||
return config;
|
||||
.Include(x => x.IgnoredChannels)
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.FirstOrDefault();
|
||||
|
||||
return logSetting;
|
||||
}
|
||||
|
||||
public static IEnumerable<GuildConfig> Permissionsv2ForAll(this DbSet<GuildConfig> configs, List<ulong> include)
|
||||
|
@@ -41,8 +41,6 @@ namespace NadekoBot.Services.Database.Models
|
||||
public bool SendChannelByeMessage { get; set; }
|
||||
public string ChannelByeMessageText { get; set; } = "%user% has left!";
|
||||
|
||||
public LogSetting LogSetting { get; set; } = new LogSetting();
|
||||
|
||||
//self assignable roles
|
||||
public bool ExclusiveSelfAssignedRoles { get; set; }
|
||||
public bool AutoDeleteSelfAssignedRoleMessages { get; set; }
|
||||
|
@@ -8,6 +8,7 @@ namespace NadekoBot.Services.Database.Models
|
||||
public HashSet<IgnoredLogChannel> IgnoredChannels { get; set; } = new HashSet<IgnoredLogChannel>();
|
||||
public HashSet<IgnoredVoicePresenceChannel> IgnoredVoicePresenceChannelIds { get; set; } = new HashSet<IgnoredVoicePresenceChannel>();
|
||||
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong? LogOtherId { get; set; }
|
||||
public ulong? MessageUpdatedId { get; set; }
|
||||
public ulong? MessageDeletedId { get; set; }
|
||||
|
@@ -337,6 +337,14 @@ namespace NadekoBot.Services.Database
|
||||
.OnDelete(DeleteBehavior.Cascade));
|
||||
|
||||
#endregion
|
||||
|
||||
#region LogSettings
|
||||
|
||||
modelBuilder.Entity<LogSetting>(ls => ls
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user