Compare commits

...

2 commits

Author SHA1 Message Date
9c94a66323
I apparently updated this file? 2024-09-20 19:27:30 +12:00
e896c14303
Hopefully fixed the startup issue 2024-09-20 19:15:37 +12:00
3 changed files with 36 additions and 26 deletions

View file

@ -688,7 +688,7 @@ public abstract class EllieContext : DbContext
x.GuildId, x.GuildId,
x.GreetType x.GreetType
}) })
.IsUnique()); .IsUnique());
modelBuilder.Entity<GreetSettings>(gs => modelBuilder.Entity<GreetSettings>(gs =>
{ {

View file

@ -244,7 +244,7 @@ public class UserPunishService : IEService, IReadyExecutor
{ {
await using var uow = _db.GetDbContext(); await using var uow = _db.GetDbContext();
var cleared = await uow.GetTable<Warning>() var toClear = await uow.GetTable<Warning>()
.Where(x => uow.GetTable<GuildConfig>() .Where(x => uow.GetTable<GuildConfig>()
.Count(y => y.GuildId == x.GuildId .Count(y => y.GuildId == x.GuildId
&& y.WarnExpireHours > 0 && y.WarnExpireHours > 0
@ -256,30 +256,40 @@ public class UserPunishService : IEService, IReadyExecutor
.Where(y => x.GuildId == y.GuildId) .Where(y => x.GuildId == y.GuildId)
.Select(y => y.WarnExpireHours) .Select(y => y.WarnExpireHours)
.First())) .First()))
.UpdateAsync(_ => new() .Select(x => x.Id)
{ .ToListAsyncLinqToDB();
Forgiven = true,
ForgivenBy = "expiry" var cleared = await uow.GetTable<Warning>()
}); .Where(x => toClear.Contains(x.Id))
.UpdateAsync(_ => new()
{
Forgiven = true,
ForgivenBy = "expiry"
});
var toDelete = await uow.GetTable<Warning>()
.Where(x => uow.GetTable<GuildConfig>()
.Count(y => y.GuildId == x.GuildId
&& y.WarnExpireHours > 0
&& y.WarnExpireAction == WarnExpireAction.Delete)
> 0
&& x.DateAdded
< DateTime.UtcNow.AddHours(-uow.GetTable<GuildConfig>()
.Where(y => x.GuildId == y.GuildId)
.Select(y => y.WarnExpireHours)
.First()))
.Select(x => x.Id)
.ToListAsyncLinqToDB();
var deleted = await uow.GetTable<Warning>() var deleted = await uow.GetTable<Warning>()
.Where(x => uow.GetTable<GuildConfig>() .Where(x => toDelete.Contains(x.Id))
.Count(y => y.GuildId == x.GuildId .DeleteAsync();
&& y.WarnExpireHours > 0
&& y.WarnExpireAction == WarnExpireAction.Delete)
> 0
&& x.DateAdded
< DateTime.UtcNow.AddHours(-uow.GetTable<GuildConfig>()
.Where(y => x.GuildId == y.GuildId)
.Select(y => y.WarnExpireHours)
.First()))
.DeleteAsync();
if (cleared > 0 || deleted > 0) if (cleared > 0 || deleted > 0)
{ {
Log.Information("Cleared {ClearedWarnings} warnings and deleted {DeletedWarnings} warnings due to expiry", Log.Information("Cleared {ClearedWarnings} warnings and deleted {DeletedWarnings} warnings due to expiry",
cleared, cleared,
deleted); toDelete.Count);
} }
} }

View file

@ -44,13 +44,13 @@ public sealed partial class BotConfig : ICloneable<BotConfig>
or all owners? (this might cause the bot to lag if there's a lot of owners specified) or all owners? (this might cause the bot to lag if there's a lot of owners specified)
""")] """)]
public bool ForwardToAllOwners { get; set; } public bool ForwardToAllOwners { get; set; }
[Comment(""" [Comment("""
Any messages sent by users in Bot's DM to be forwarded to the specified channel. Any messages sent by users in Bot's DM to be forwarded to the specified channel.
This option will only work when ForwardToAllOwners is set to false This option will only work when ForwardToAllOwners is set to false
""")] """)]
public ulong? ForwardToChannel { get; set; } public ulong? ForwardToChannel { get; set; }
[Comment(""" [Comment("""
Should the bot ignore messages from other bots? Should the bot ignore messages from other bots?
Settings this to false might get your bot banned if it gets into a spam loop with another bot. Settings this to false might get your bot banned if it gets into a spam loop with another bot.
@ -141,11 +141,11 @@ public sealed partial class BotConfig : ICloneable<BotConfig>
]; ];
} }
// [Comment(@"Whether the prefix will be a suffix, or prefix. // [Comment(@"Whether the prefix will be a suffix, or prefix.
// For example, if your prefix is ! you will run a command called 'cash' by typing either // For example, if your prefix is ! you will run a command called 'cash' by typing either
// '!cash @Someone' if your prefixIsSuffix: false or // '!cash @Someone' if your prefixIsSuffix: false or
// 'cash @Someone!' if your prefixIsSuffix: true")] // 'cash @Someone!' if your prefixIsSuffix: true")]
// public bool PrefixIsSuffix { get; set; } // public bool PrefixIsSuffix { get; set; }
// public string Prefixed(string text) => PrefixIsSuffix // public string Prefixed(string text) => PrefixIsSuffix
// ? text + Prefix // ? text + Prefix