Skip to content

Commit

Permalink
logging now saves params
Browse files Browse the repository at this point in the history
  • Loading branch information
SylveonDeko committed Oct 11, 2024
1 parent 94b0ca7 commit b072192
Show file tree
Hide file tree
Showing 8 changed files with 5,015 additions and 77 deletions.
36 changes: 6 additions & 30 deletions src/Mewdeko/Database/Extensions/GuildConfigExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,37 +176,13 @@ public static async Task<XpSettings> XpSettingsFor(this MewdekoContext ctx, ulon
/// <param name="ctx">The database context.</param>
/// <param name="guildId">The ID of the guild.</param>
/// <returns>The GuildConfig for the guild.</returns>
public static async Task<GuildConfig> LogSettingsFor(this MewdekoContext ctx, ulong guildId)
public static async Task<LoggingV2> LogSettingsFor(this MewdekoContext ctx, ulong guildId)
{
var config = await ctx.GuildConfigs
.Include(gc => gc.LogSetting)
.ThenInclude(gc => gc.IgnoredChannels)
.ToLinqToDB()
.FirstOrDefaultAsyncLinqToDB(x => x.GuildId == guildId);

if (config == null)
{
await ctx.AddAsync(config = new GuildConfig
{
GuildId = guildId,
Permissions = Permissionv2.GetDefaultPermlist,
WarningsInitialized = true,
WarnPunishments = DefaultWarnPunishments
});
await ctx.SaveChangesAsync();
}

if (config.LogSetting == null)
{
config.LogSetting = new LogSetting();
await ctx.SaveChangesAsync();
}

if (config.WarningsInitialized) return config;
config.WarningsInitialized = true;
config.WarnPunishments = DefaultWarnPunishments;

return config;
var log = await ctx.LoggingV2.FirstOrDefaultAsync(x => x.GuildId == guildId) ?? new LoggingV2()
{
GuildId = guildId
};
return log;
}

/// <summary>
Expand Down
11 changes: 11 additions & 0 deletions src/Mewdeko/Database/MewdekoContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Mewdeko.Common.Attributes.DB;
using Mewdeko.Modules.OwnerOnly.Services;
using Mewdeko.Services.Impl;
using Microsoft.EntityFrameworkCore;

Expand Down Expand Up @@ -120,6 +121,11 @@ public MewdekoContext(DbContextOptions options) : base(options)
/// </summary>
public DbSet<AutoBanRoles> AutoBanRoles { get; set; }

/// <summary>
/// Logging settings for guilds
/// </summary>
public DbSet<LoggingV2> LoggingV2 { get; set; }

/// <summary>
/// Gets or sets the publish word blacklists.
/// </summary>
Expand Down Expand Up @@ -410,6 +416,11 @@ public MewdekoContext(DbContextOptions options) : base(options)
/// </summary>
public DbSet<WarningPunishment2> WarningPunishments2 { get; set; }

/// <summary>
/// gets or sets the local running instances, for dashboard management.
/// </summary>
public DbSet<LocalBotInstances> BotInstances { get; set; }

/// <summary>
/// Configures the model that was discovered by convention from the entity types
/// exposed in <see cref="DbSet{TEntity}" /> properties on your derived context.
Expand Down
Loading

0 comments on commit b072192

Please sign in to comment.