Updated Db models

I hate working on database stuff
This commit is contained in:
Toastie (DCS Team) 2024-06-14 00:20:21 +12:00
parent 97e81ac0f4
commit 29c0b4acfc
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
32 changed files with 357 additions and 185 deletions

View file

@ -28,7 +28,6 @@ public abstract class EllieContext : DbContext
//logging //logging
public DbSet<LogSetting> LogSettings { get; set; } public DbSet<LogSetting> LogSettings { get; set; }
public DbSet<IgnoredVoicePresenceChannel> IgnoredVoicePresenceCHannels { get; set; }
public DbSet<IgnoredLogItem> IgnoredLogChannels { get; set; } public DbSet<IgnoredLogItem> IgnoredLogChannels { get; set; }
public DbSet<RotatingPlayingStatus> RotatingStatus { get; set; } public DbSet<RotatingPlayingStatus> RotatingStatus { get; set; }
@ -86,15 +85,84 @@ public abstract class EllieContext : DbContext
#region GuildConfig #region GuildConfig
var configEntity = modelBuilder.Entity<GuildConfig>(); var configEntity = modelBuilder.Entity<GuildConfig>();
configEntity.HasIndex(c => c.GuildId) configEntity.HasIndex(c => c.GuildId)
.IsUnique(); .IsUnique();
configEntity.Property(x => x.VerboseErrors) configEntity.Property(x => x.VerboseErrors)
.HasDefaultValue(true); .HasDefaultValue(true);
modelBuilder.Entity<AntiSpamSetting>().HasOne(x => x.GuildConfig).WithOne(x => x.AntiSpamSetting); modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.DelMsgOnCmdChannels)
.WithOne()
.HasForeignKey(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<AntiRaidSetting>().HasOne(x => x.GuildConfig).WithOne(x => x.AntiRaidSetting); modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FollowedStreams)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.GenerateCurrencyChannelIds)
.WithOne(x => x.GuildConfig)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.Permissions)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.CommandCooldowns)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FilterInvitesChannelIds)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FilterLinksChannelIds)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FilteredWords)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FilterWordsChannelIds)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.MutedUsers)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.AntiRaidSetting)
.WithOne()
.HasForeignKey<AntiRaidSetting>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
// start antispam
modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.AntiSpamSetting)
.WithOne()
.HasForeignKey<AntiSpamSetting>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<AntiSpamSetting>()
.HasMany(x => x.IgnoredChannels)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
// end antispam
modelBuilder.Entity<GuildConfig>() modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.AntiAltSetting) .HasOne(x => x.AntiAltSetting)
@ -102,6 +170,98 @@ public abstract class EllieContext : DbContext
.HasForeignKey<AntiAltSetting>(x => x.GuildConfigId) .HasForeignKey<AntiAltSetting>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.UnmuteTimers)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.UnbanTimer)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.UnroleTimer)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.VcRoleInfos)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.CommandAliases)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.WarnPunishments)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.SlowmodeIgnoredRoles)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.SlowmodeIgnoredUsers)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
// start shop
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.ShopEntries)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<ShopEntry>()
.HasMany(x => x.Items)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
// end shop
// start streamrole
modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.StreamRole)
.WithOne(x => x.GuildConfig)
.HasForeignKey<StreamRoleSettings>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<StreamRoleSettings>()
.HasMany(x => x.Whitelist)
.WithOne(x => x.StreamRoleSettings)
.HasForeignKey(x => x.StreamRoleSettingsId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<StreamRoleSettings>()
.HasMany(x => x.Blacklist)
.WithOne(x => x.StreamRoleSettings)
.HasForeignKey(x => x.StreamRoleSettingsId)
.OnDelete(DeleteBehavior.Cascade);
// end streamrole
modelBuilder.Entity<GuildConfig>()
.HasOne(x => x.XpSettings)
.WithOne(x => x.GuildConfig)
.HasForeignKey<XpSettings>(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.FeedSubs)
.WithOne(x => x.GuildConfig)
.HasForeignKey(x => x.GuildConfigId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GuildConfig>()
.HasMany(x => x.SelfAssignableRoleGroupNames)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<FeedSub>() modelBuilder.Entity<FeedSub>()
.HasAlternateKey(x => new .HasAlternateKey(x => new
{ {
@ -117,11 +277,6 @@ public abstract class EllieContext : DbContext
#endregion #endregion
#region streamrole
modelBuilder.Entity<StreamRoleSettings>().HasOne(x => x.GuildConfig).WithOne(x => x.StreamRole);
#endregion
#region Self Assignable Roles #region Self Assignable Roles
@ -217,12 +372,6 @@ public abstract class EllieContext : DbContext
#endregion #endregion
#region XpSettings
modelBuilder.Entity<XpSettings>().HasOne(x => x.GuildConfig).WithOne(x => x.XpSettings);
#endregion
#region XpRoleReward #region XpRoleReward
modelBuilder.Entity<XpRoleReward>() modelBuilder.Entity<XpRoleReward>()
@ -233,6 +382,21 @@ public abstract class EllieContext : DbContext
}) })
.IsUnique(); .IsUnique();
modelBuilder.Entity<XpSettings>()
.HasMany(x => x.RoleRewards)
.WithOne(x => x.XpSettings)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<XpSettings>()
.HasMany(x => x.CurrencyRewards)
.WithOne(x => x.XpSettings)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<XpSettings>()
.HasMany(x => x.ExclusionList)
.WithOne(x => x.XpSettings)
.OnDelete(DeleteBehavior.Cascade);
#endregion #endregion
#region Club #region Club
@ -331,9 +495,9 @@ public abstract class EllieContext : DbContext
modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique(); modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique();
modelBuilder.Entity<BanTemplate>() modelBuilder.Entity<BanTemplate>()
.Property(x => x.PruneDays) .Property(x => x.PruneDays)
.HasDefaultValue(null) .HasDefaultValue(null)
.IsRequired(false); .IsRequired(false);
#endregion #endregion
@ -458,7 +622,7 @@ public abstract class EllieContext : DbContext
model.ItemType, model.ItemType,
model.ItemKey model.ItemKey
}) })
.IsUnique(); .IsUnique();
}); });
#endregion #endregion
@ -466,16 +630,16 @@ public abstract class EllieContext : DbContext
#region AutoPublish #region AutoPublish
modelBuilder.Entity<AutoPublishChannel>(apc => apc modelBuilder.Entity<AutoPublishChannel>(apc => apc
.HasIndex(x => x.GuildId) .HasIndex(x => x.GuildId)
.IsUnique()); .IsUnique());
#endregion #endregion
#region GamblingStats #region GamblingStats
modelBuilder.Entity<GamblingStats>(gs => gs modelBuilder.Entity<GamblingStats>(gs => gs
.HasIndex(x => x.Feature) .HasIndex(x => x.Feature)
.IsUnique()); .IsUnique());
#endregion #endregion
@ -485,7 +649,8 @@ public abstract class EllieContext : DbContext
{ {
x.GuildId, x.GuildId,
x.UserId x.UserId
}).IsUnique()); })
.IsUnique());
#endregion #endregion
@ -493,18 +658,18 @@ public abstract class EllieContext : DbContext
#region Giveaway #region Giveaway
modelBuilder.Entity<GiveawayModel>() modelBuilder.Entity<GiveawayModel>()
.HasMany(x => x.Participants) .HasMany(x => x.Participants)
.WithOne() .WithOne()
.HasForeignKey(x => x.GiveawayId) .HasForeignKey(x => x.GiveawayId)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GiveawayUser>(gu => gu modelBuilder.Entity<GiveawayUser>(gu => gu
.HasIndex(x => new .HasIndex(x => new
{ {
x.GiveawayId, x.GiveawayId,
x.UserId x.UserId
}) })
.IsUnique()); .IsUnique());
#endregion #endregion
@ -514,14 +679,14 @@ public abstract class EllieContext : DbContext
.HasKey(x => x.Id); .HasKey(x => x.Id);
modelBuilder.Entity<TodoModel>() modelBuilder.Entity<TodoModel>()
.HasIndex(x => x.UserId) .HasIndex(x => x.UserId)
.IsUnique(false); .IsUnique(false);
modelBuilder.Entity<ArchivedTodoListModel>() modelBuilder.Entity<ArchivedTodoListModel>()
.HasMany(x => x.Items) .HasMany(x => x.Items)
.WithOne() .WithOne()
.HasForeignKey(x => x.ArchiveId) .HasForeignKey(x => x.ArchiveId)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
#endregion #endregion
} }

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Db.Models; using EllieBot.Db.Models;

View file

@ -20,48 +20,48 @@ public static class DiscordUserExtensions
string discrim, string discrim,
string avatarId) string avatarId)
=> ctx.GetTable<DiscordUser>() => ctx.GetTable<DiscordUser>()
.InsertOrUpdate( .InsertOrUpdate(
() => new() () => new()
{ {
UserId = userId, UserId = userId,
Username = username, Username = username,
Discriminator = discrim, Discriminator = discrim,
AvatarId = avatarId, AvatarId = avatarId,
TotalXp = 0, TotalXp = 0,
CurrencyAmount = 0 CurrencyAmount = 0
}, },
old => new() old => new()
{ {
Username = username, Username = username,
Discriminator = discrim, Discriminator = discrim,
AvatarId = avatarId AvatarId = avatarId
}, },
() => new() () => new()
{ {
UserId = userId UserId = userId
}); });
public static Task EnsureUserCreatedAsync( public static Task EnsureUserCreatedAsync(
this DbContext ctx, this DbContext ctx,
ulong userId) ulong userId)
=> ctx.GetTable<DiscordUser>() => ctx.GetTable<DiscordUser>()
.InsertOrUpdateAsync( .InsertOrUpdateAsync(
() => new() () => new()
{ {
UserId = userId, UserId = userId,
Username = "Unknown", Username = "Unknown",
Discriminator = "????", Discriminator = "????",
AvatarId = string.Empty, AvatarId = string.Empty,
TotalXp = 0, TotalXp = 0,
CurrencyAmount = 0 CurrencyAmount = 0
}, },
old => new() old => new()
{ {
}, },
() => new() () => new()
{ {
UserId = userId UserId = userId
}); });
//temp is only used in updatecurrencystate, so that i don't overwrite real usernames/discrims with Unknown //temp is only used in updatecurrencystate, so that i don't overwrite real usernames/discrims with Unknown
public static DiscordUser GetOrCreateUser( public static DiscordUser GetOrCreateUser(
@ -83,25 +83,29 @@ public static class DiscordUserExtensions
public static int GetUserGlobalRank(this DbSet<DiscordUser> users, ulong id) public static int GetUserGlobalRank(this DbSet<DiscordUser> users, ulong id)
=> users.AsQueryable() => users.AsQueryable()
.Where(x => x.TotalXp .Where(x => x.TotalXp
> users.AsQueryable().Where(y => y.UserId == id).Select(y => y.TotalXp).FirstOrDefault()) > users.AsQueryable().Where(y => y.UserId == id).Select(y => y.TotalXp).FirstOrDefault())
.Count() .Count()
+ 1; + 1;
public static DiscordUser[] GetUsersXpLeaderboardFor(this DbSet<DiscordUser> users, int page, int perPage) public static async Task<IReadOnlyCollection<DiscordUser>> GetUsersXpLeaderboardFor(this DbSet<DiscordUser> users, int page, int perPage)
=> users.AsQueryable().OrderByDescending(x => x.TotalXp).Skip(page * perPage).Take(perPage).AsEnumerable() => await users.ToLinqToDBTable()
.ToArray(); .OrderByDescending(x => x.TotalXp)
.Skip(page * perPage)
.Take(perPage)
.ToArrayAsyncLinqToDB();
public static Task<List<DiscordUser>> GetTopRichest( public static Task<List<DiscordUser>> GetTopRichest(
this DbSet<DiscordUser> users, this DbSet<DiscordUser> users,
ulong botId, ulong botId,
int page = 0, int perPage = 9) int page = 0,
int perPage = 9)
=> users.AsQueryable() => users.AsQueryable()
.Where(c => c.CurrencyAmount > 0 && botId != c.UserId) .Where(c => c.CurrencyAmount > 0 && botId != c.UserId)
.OrderByDescending(c => c.CurrencyAmount) .OrderByDescending(c => c.CurrencyAmount)
.Skip(page * perPage) .Skip(page * perPage)
.Take(perPage) .Take(perPage)
.ToListAsyncLinqToDB(); .ToListAsyncLinqToDB();
public static async Task<long> GetUserCurrencyAsync(this DbSet<DiscordUser> users, ulong userId) public static async Task<long> GetUserCurrencyAsync(this DbSet<DiscordUser> users, ulong userId)
=> (await users.FirstOrDefaultAsyncLinqToDB(x => x.UserId == userId))?.CurrencyAmount ?? 0; => (await users.FirstOrDefaultAsyncLinqToDB(x => x.UserId == userId))?.CurrencyAmount ?? 0;
@ -118,8 +122,8 @@ public static class DiscordUserExtensions
public static decimal GetTopOnePercentCurrency(this DbSet<DiscordUser> users, ulong botId) public static decimal GetTopOnePercentCurrency(this DbSet<DiscordUser> users, ulong botId)
=> users.AsQueryable() => users.AsQueryable()
.Where(x => x.UserId != botId) .Where(x => x.UserId != botId)
.OrderByDescending(x => x.CurrencyAmount) .OrderByDescending(x => x.CurrencyAmount)
.Take(users.Count() / 100 == 0 ? 1 : users.Count() / 100) .Take(users.Count() / 100 == 0 ? 1 : users.Count() / 100)
.Sum(x => x.CurrencyAmount); .Sum(x => x.CurrencyAmount);
} }

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Db.Models; using EllieBot.Db.Models;
@ -7,19 +7,20 @@ namespace EllieBot.Db;
public static class GuildConfigExtensions public static class GuildConfigExtensions
{ {
private static List<WarningPunishment> DefaultWarnPunishments private static List<WarningPunishment> DefaultWarnPunishments
=> new() =>
{ [
new() new()
{ {
Count = 3, Count = 3,
Punishment = PunishmentAction.Kick Punishment = PunishmentAction.Kick
}, },
new() new()
{ {
Count = 5, Count = 5,
Punishment = PunishmentAction.Ban Punishment = PunishmentAction.Ban
} }
}; ];
/// <summary> /// <summary>
/// Gets full stream role settings for the guild with the specified id. /// Gets full stream role settings for the guild with the specified id.

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using EllieBot.Db.Models; using EllieBot.Db.Models;

View file

@ -26,33 +26,33 @@ public static class UserXpExtensions
return usr; return usr;
} }
public static List<UserXpStats> GetUsersFor(this DbSet<UserXpStats> xps, ulong guildId, int page) public static async Task<IReadOnlyCollection<UserXpStats>> GetUsersFor(
=> xps.AsQueryable() this DbSet<UserXpStats> xps,
.AsNoTracking() ulong guildId,
.Where(x => x.GuildId == guildId) int page)
.OrderByDescending(x => x.Xp + x.AwardedXp) => await xps.ToLinqToDBTable()
.Skip(page * 9) .Where(x => x.GuildId == guildId)
.Take(9) .OrderByDescending(x => x.Xp + x.AwardedXp)
.ToList(); .Skip(page * 9)
.Take(9)
.ToArrayAsyncLinqToDB();
public static List<UserXpStats> GetTopUserXps(this DbSet<UserXpStats> xps, ulong guildId, int count) public static async Task<List<UserXpStats>> GetTopUserXps(this DbSet<UserXpStats> xps, ulong guildId, int count)
=> xps.AsQueryable() => await xps.ToLinqToDBTable()
.AsNoTracking() .Where(x => x.GuildId == guildId)
.Where(x => x.GuildId == guildId) .OrderByDescending(x => x.Xp + x.AwardedXp)
.OrderByDescending(x => x.Xp + x.AwardedXp) .Take(count)
.Take(count) .ToListAsyncLinqToDB();
.ToList();
public static int GetUserGuildRanking(this DbSet<UserXpStats> xps, ulong userId, ulong guildId) public static async Task<int> GetUserGuildRanking(this DbSet<UserXpStats> xps, ulong userId, ulong guildId)
=> xps.AsQueryable() => await xps.ToLinqToDBTable()
.AsNoTracking() .Where(x => x.GuildId == guildId
.Where(x => x.GuildId == guildId && x.Xp + x.AwardedXp
&& x.Xp + x.AwardedXp > xps.AsQueryable()
> xps.AsQueryable() .Where(y => y.UserId == userId && y.GuildId == guildId)
.Where(y => y.UserId == userId && y.GuildId == guildId) .Select(y => y.Xp + y.AwardedXp)
.Select(y => y.Xp + y.AwardedXp) .FirstOrDefault())
.FirstOrDefault()) .CountAsyncLinqToDB()
.Count()
+ 1; + 1;
public static void ResetGuildUserXp(this DbSet<UserXpStats> xps, ulong userId, ulong guildId) public static void ResetGuildUserXp(this DbSet<UserXpStats> xps, ulong userId, ulong guildId)
@ -62,10 +62,9 @@ public static class UserXpExtensions
=> xps.Delete(x => x.GuildId == guildId); => xps.Delete(x => x.GuildId == guildId);
public static async Task<LevelStats> GetLevelDataFor(this ITable<UserXpStats> userXp, ulong guildId, ulong userId) public static async Task<LevelStats> GetLevelDataFor(this ITable<UserXpStats> userXp, ulong guildId, ulong userId)
=> await userXp => await userXp
.Where(x => x.GuildId == guildId && x.UserId == userId) .Where(x => x.GuildId == guildId && x.UserId == userId)
.FirstOrDefaultAsyncLinqToDB() is UserXpStats uxs .FirstOrDefaultAsyncLinqToDB() is UserXpStats uxs
? new(uxs.Xp + uxs.AwardedXp) ? new(uxs.Xp + uxs.AwardedXp)
: new(0); : new(0);
} }

View file

@ -22,8 +22,7 @@ public static class WarningExtensions
string mod, string mod,
int index) int index)
{ {
if (index < 0) ArgumentOutOfRangeException.ThrowIfNegative(index);
throw new ArgumentOutOfRangeException(nameof(index));
var warn = warnings.AsQueryable() var warn = warnings.AsQueryable()
.Where(x => x.GuildId == guildId && x.UserId == userId) .Where(x => x.GuildId == guildId && x.UserId == userId)

View file

@ -1,4 +1,4 @@
namespace EllieBot.Db; namespace EllieBot.Db;
public enum DbActivityType public enum DbActivityType
{ {

View file

@ -1,4 +1,4 @@
namespace EllieBot.Db; namespace EllieBot.Db;
[Flags] [Flags]
public enum GuildPerm : ulong public enum GuildPerm : ulong

View file

@ -1,4 +1,4 @@
#nullable disable #nullable disable
namespace EllieBot.Db; namespace EllieBot.Db;
public readonly struct LevelStats public readonly struct LevelStats

View file

@ -3,6 +3,8 @@ namespace EllieBot.Db.Models;
public class DelMsgOnCmdChannel : DbEntity public class DelMsgOnCmdChannel : DbEntity
{ {
public int GuildConfigId { get; set; }
public ulong ChannelId { get; set; } public ulong ChannelId { get; set; }
public bool State { get; set; } public bool State { get; set; }

View file

@ -3,6 +3,7 @@ namespace EllieBot.Db.Models;
public class GuildConfig : DbEntity public class GuildConfig : DbEntity
{ {
// public bool Keep { get; set; }
public ulong GuildId { get; set; } public ulong GuildId { get; set; }
public string Prefix { get; set; } public string Prefix { get; set; }

View file

@ -1,8 +0,0 @@
#nullable disable
namespace EllieBot.Db.Models;
public class IgnoredVoicePresenceChannel : DbEntity
{
public LogSetting LogSetting { get; set; }
public ulong ChannelId { get; set; }
}

View file

@ -33,10 +33,7 @@ public class Permissionv2 : DbEntity, IIndexed
}; };
public static List<Permissionv2> GetDefaultPermlist public static List<Permissionv2> GetDefaultPermlist
=> new() => [AllowAllPerm];
{
AllowAllPerm
};
} }
public enum PrimaryPermissionType public enum PrimaryPermissionType

View file

@ -40,6 +40,9 @@ public class StreamRoleSettings : DbEntity
public class StreamRoleBlacklistedUser : DbEntity public class StreamRoleBlacklistedUser : DbEntity
{ {
public int StreamRoleSettingsId { get; set; }
public StreamRoleSettings StreamRoleSettings { get; set; }
public ulong UserId { get; set; } public ulong UserId { get; set; }
public string Username { get; set; } public string Username { get; set; }
@ -57,6 +60,9 @@ public class StreamRoleBlacklistedUser : DbEntity
public class StreamRoleWhitelistedUser : DbEntity public class StreamRoleWhitelistedUser : DbEntity
{ {
public int StreamRoleSettingsId { get; set; }
public StreamRoleSettings StreamRoleSettings { get; set; }
public ulong UserId { get; set; } public ulong UserId { get; set; }
public string Username { get; set; } public string Username { get; set; }

View file

@ -1,7 +1,7 @@
#nullable disable #nullable disable
using EllieBot.Db.Models; using EllieBot.Db.Models;
namespace EllieBot.Services.Database.Models; namespace NadekoBot.Services.Database.Models;
public class WaifuInfo : DbEntity public class WaifuInfo : DbEntity
{ {

View file

@ -2,8 +2,9 @@
public class AntiAltSetting public class AntiAltSetting
{ {
public int Id { get; set; }
public int GuildConfigId { get; set; } public int GuildConfigId { get; set; }
public int Id { get; set; }
public TimeSpan MinAge { get; set; } public TimeSpan MinAge { get; set; }
public PunishmentAction Action { get; set; } public PunishmentAction Action { get; set; }
public int ActionDurationMinutes { get; set; } public int ActionDurationMinutes { get; set; }

View file

@ -1,11 +1,12 @@
#nullable disable #nullable disable
using System.ComponentModel.DataAnnotations.Schema;
namespace EllieBot.Db.Models; namespace EllieBot.Db.Models;
public class AntiRaidSetting : DbEntity public class AntiRaidSetting : DbEntity
{ {
public int GuildConfigId { get; set; } public int GuildConfigId { get; set; }
public GuildConfig GuildConfig { get; set; }
public int UserThreshold { get; set; } public int UserThreshold { get; set; }
public int Seconds { get; set; } public int Seconds { get; set; }

View file

@ -4,7 +4,6 @@
public class AntiSpamSetting : DbEntity public class AntiSpamSetting : DbEntity
{ {
public int GuildConfigId { get; set; } public int GuildConfigId { get; set; }
public GuildConfig GuildConfig { get; set; }
public PunishmentAction Action { get; set; } public PunishmentAction Action { get; set; }
public int MessageThreshold { get; set; } = 3; public int MessageThreshold { get; set; } = 3;

View file

@ -14,17 +14,3 @@ public class FilterChannelId : DbEntity
public override int GetHashCode() public override int GetHashCode()
=> ChannelId.GetHashCode(); => ChannelId.GetHashCode();
} }
public class FilterWordsChannelId : DbEntity
{
public ulong ChannelId { get; set; }
public bool Equals(FilterWordsChannelId other)
=> ChannelId == other.ChannelId;
public override bool Equals(object obj)
=> obj is FilterWordsChannelId fci && Equals(fci);
public override int GetHashCode()
=> ChannelId.GetHashCode();
}

View file

@ -0,0 +1,17 @@
#nullable disable
namespace EllieBot.Db.Models;
public class FilterWordsChannelId : DbEntity
{
public int? GuildConfigId { get; set; }
public ulong ChannelId { get; set; }
public bool Equals(FilterWordsChannelId other)
=> ChannelId == other.ChannelId;
public override bool Equals(object obj)
=> obj is FilterWordsChannelId fci && Equals(fci);
public override int GetHashCode()
=> ChannelId.GetHashCode();
}

View file

@ -51,6 +51,8 @@ public class XpCurrencyReward : DbEntity
public class ExcludedItem : DbEntity public class ExcludedItem : DbEntity
{ {
public XpSettings XpSettings { get; set; }
public ulong ItemId { get; set; } public ulong ItemId { get; set; }
public ExcludedItemType ItemType { get; set; } public ExcludedItemType ItemType { get; set; }