diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cb4785..be9f21c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -188,7 +188,7 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except da - Self Assigned Roles reworked! Use `.h .sar` for the list of commands - `.sar autodel` - - Toggles the automatic deletion of the user's message and Nadeko's confirmations for .iam and .iamn commands. + - Toggles the automatic deletion of the user's message and Ellie's confirmations for .iam and .iamn commands. - `.sar ad` - Adds a role to the list of self-assignable roles. You can also specify a group. - If 'Exclusive self-assignable roles' feature is enabled (.sar exclusive), users will be able to pick one role diff --git a/src/EllieBot/Bot.cs b/src/EllieBot/Bot.cs index 065fca3..25cc874 100644 --- a/src/EllieBot/Bot.cs +++ b/src/EllieBot/Bot.cs @@ -1,12 +1,9 @@ #nullable disable using DryIoc; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; using EllieBot.Common.Configs; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db.Models; -using System.Collections.Immutable; using System.Diagnostics; using System.Reflection; using RunMode = Discord.Commands.RunMode; @@ -15,10 +12,7 @@ namespace EllieBot; public sealed class Bot : IBot { - public event Func<GuildConfig, Task> JoinedGuild = delegate { return Task.CompletedTask; }; - public DiscordSocketClient Client { get; } - public IReadOnlyCollection<GuildConfig> AllGuildConfigs { get; private set; } private IContainer Services { get; set; } @@ -102,7 +96,6 @@ public sealed class Bot : IBot await using (var uow = _db.GetDbContext()) { - AllGuildConfigs = await uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList); uow.EnsureUserCreated(bot.Id, bot.Username, bot.Discriminator, bot.AvatarId); } @@ -114,10 +107,6 @@ public sealed class Bot : IBot var svcs = new Container(); - // this is required in order for marmalade unloading to work - // svcs.Components.Remove<IPlanner, Planner>(); - // svcs.Components.Add<IPlanner, RemovablePlanner>(); - svcs.AddSingleton<IBotCreds>(_ => _credsProvider.GetCreds()); svcs.AddSingleton<DbService, DbService>(_db); svcs.AddSingleton<IBotCredsProvider>(_credsProvider); @@ -245,16 +234,6 @@ public sealed class Bot : IBot private Task Client_JoinedGuild(SocketGuild arg) { Log.Information("Joined server: {GuildName} [{GuildId}]", arg.Name, arg.Id); - _ = Task.Run(async () => - { - GuildConfig gc; - await using (var uow = _db.GetDbContext()) - { - gc = uow.GuildConfigsForId(arg.Id, null); - } - - await JoinedGuild.Invoke(gc); - }); return Task.CompletedTask; } diff --git a/src/EllieBot/Db/EllieContext.cs b/src/EllieBot/Db/EllieContext.cs index f21c57b..1134692 100644 --- a/src/EllieBot/Db/EllieContext.cs +++ b/src/EllieBot/Db/EllieContext.cs @@ -1,8 +1,8 @@ #nullable disable using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Logging; using EllieBot.Db.Models; -using EllieBot.Modules.Administration.Services; // ReSharper disable UnusedAutoPropertyAccessor.Global @@ -11,6 +11,11 @@ namespace EllieBot.Db; public abstract class EllieContext : DbContext { public DbSet<GuildConfig> GuildConfigs { get; set; } + public DbSet<Permissionv2> Permissions { get; set; } + + //new + public DbSet<XpSettings> XpSettings { get; set; } + public DbSet<GreetSettings> GreetSettings { get; set; } public DbSet<Quote> Quotes { get; set; } @@ -46,7 +51,6 @@ public abstract class EllieContext : DbContext public DbSet<AutoTranslateChannel> AutoTranslateChannels { get; set; } public DbSet<AutoTranslateUser> AutoTranslateUsers { get; set; } - public DbSet<Permissionv2> Permissions { get; set; } public DbSet<BankUser> BankUsers { get; set; } @@ -76,7 +80,7 @@ public abstract class EllieContext : DbContext { // load all entities from current assembly modelBuilder.ApplyConfigurationsFromAssembly(typeof(EllieContext).Assembly); - + #region Notify modelBuilder.Entity<Notify>(e => @@ -170,10 +174,10 @@ public abstract class EllieContext : DbContext modelBuilder.Entity<UserBetStats>(ubs => { ubs.HasIndex(x => new - { - x.UserId, - x.Game - }) + { + x.UserId, + x.Game + }) .IsUnique(); ubs.HasIndex(x => x.MaxWin) @@ -221,174 +225,8 @@ public abstract class EllieContext : DbContext configEntity.Property(x => x.VerboseErrors) .HasDefaultValue(true); - - modelBuilder.Entity<GuildConfig>() - .HasMany(x => x.DelMsgOnCmdChannels) - .WithOne() - .HasForeignKey(x => x.GuildConfigId) - .OnDelete(DeleteBehavior.Cascade); - - 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>() - .HasOne(x => x.AntiAltSetting) - .WithOne() - .HasForeignKey<AntiAltSetting>(x => x.GuildConfigId) - .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.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<FeedSub>() - .HasAlternateKey(x => new - { - x.GuildConfigId, - x.Url - }); - modelBuilder.Entity<PlantedCurrency>().HasIndex(x => x.MessageId).IsUnique(); modelBuilder.Entity<PlantedCurrency>().HasIndex(x => x.ChannelId); @@ -397,9 +235,7 @@ public abstract class EllieContext : DbContext #endregion - #region WarningPunishments - - var warnpunishmentEntity = modelBuilder.Entity<WarningPunishment>(b => + modelBuilder.Entity<WarningPunishment>(b => { b.HasAlternateKey(x => new { @@ -408,8 +244,6 @@ public abstract class EllieContext : DbContext }); }); - #endregion - #region MusicPlaylists var musicPlaylistEntity = modelBuilder.Entity<MusicPlaylist>(); @@ -489,33 +323,6 @@ public abstract class EllieContext : DbContext #endregion - #region XpRoleReward - - modelBuilder.Entity<XpRoleReward>() - .HasIndex(x => new - { - x.XpSettingsId, - x.Level - }) - .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 - #region Club var ci = modelBuilder.Entity<ClubInfo>(); @@ -806,8 +613,15 @@ public abstract class EllieContext : DbContext #if DEBUG private static readonly ILoggerFactory _debugLoggerFactory = LoggerFactory.Create(x => x.AddConsole()); +#endif protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseLoggerFactory(_debugLoggerFactory); + { +#if DEBUG + optionsBuilder.UseLoggerFactory(_debugLoggerFactory); #endif + + optionsBuilder.ConfigureWarnings(x => x.Log(RelationalEventId.PendingModelChangesWarning) + .Ignore()); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/EllieDbService.cs b/src/EllieBot/Db/EllieDbService.cs index a9f0781..a351c8c 100644 --- a/src/EllieBot/Db/EllieDbService.cs +++ b/src/EllieBot/Db/EllieDbService.cs @@ -2,7 +2,6 @@ using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using EllieBot.Migrations; namespace EllieBot.Db; @@ -28,14 +27,14 @@ public sealed class EllieDbService : DbService public override async Task SetupAsync() { await using var context = CreateRawDbContext(DbType, ConnString); - + + await RunMigration(context); + // make sure sqlite db is in wal journal mode if (context is SqliteContext) { await context.Database.ExecuteSqlRawAsync("PRAGMA journal_mode=WAL"); } - - await RunMigration(context); } public override EllieContext CreateRawDbContext(string dbType, string connString) diff --git a/src/EllieBot/Db/Extensions/DbExtensions.cs b/src/EllieBot/Db/Extensions/DbExtensions.cs index fafade9..7541918 100644 --- a/src/EllieBot/Db/Extensions/DbExtensions.cs +++ b/src/EllieBot/Db/Extensions/DbExtensions.cs @@ -9,4 +9,40 @@ public static class DbExtensions public static T GetById<T>(this DbSet<T> set, int id) where T : DbEntity => set.FirstOrDefault(x => x.Id == id); + + public static GuildConfig GuildConfigsForId(this DbContext ctx, ulong guildId) + { + var query = ctx.Set<GuildConfig>().Where(gc => gc.GuildId == guildId); + return query.FirstOrDefault(); + } + + public static GuildFilterConfig FilterConfigForId( + this DbContext ctx, + ulong guildId, + Func<IQueryable<GuildFilterConfig>, IQueryable<GuildFilterConfig>> includes = default) + { + includes ??= static set => set; + + var gfc = includes(ctx.Set<GuildFilterConfig>() + .Where(gc => gc.GuildId == guildId)) + .FirstOrDefault(); + + if (gfc is null) + { + ctx.Add(gfc = new GuildFilterConfig() + { + }); + } + + return gfc; + } + + public static GuildConfig GuildConfigsForId( + this DbContext ctx, + ulong guildId, + Func<IQueryable<GuildConfig>, IQueryable<GuildConfig>> set) + { + var query = ctx.Set<GuildConfig>().Where(gc => gc.GuildId == guildId); + return query.FirstOrDefault(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Extensions/DiscordUserExtensions.cs b/src/EllieBot/Db/Extensions/DiscordUserExtensions.cs index ab2b46f..f8105c3 100644 --- a/src/EllieBot/Db/Extensions/DiscordUserExtensions.cs +++ b/src/EllieBot/Db/Extensions/DiscordUserExtensions.cs @@ -84,7 +84,7 @@ public static class DiscordUserExtensions > users.AsQueryable().Where(y => y.UserId == id).Select(y => y.TotalXp).FirstOrDefault()) .Count() + 1; - + public static Task<List<DiscordUser>> GetTopRichest( this DbSet<DiscordUser> users, ulong botId, diff --git a/src/EllieBot/Db/Extensions/GuildConfigExtensions.cs b/src/EllieBot/Db/Extensions/GuildConfigExtensions.cs index 86d22be..865ae8e 100644 --- a/src/EllieBot/Db/Extensions/GuildConfigExtensions.cs +++ b/src/EllieBot/Db/Extensions/GuildConfigExtensions.cs @@ -1,4 +1,5 @@ #nullable disable +using LinqToDB; using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using EllieBot.Db.Models; @@ -29,102 +30,23 @@ public static class GuildConfigExtensions /// <param name="ctx">Db Context</param> /// <param name="guildId">Id of the guild to get stream role settings for.</param> /// <returns>Guild'p stream role settings</returns> - public static StreamRoleSettings GetStreamRoleSettings(this DbContext ctx, ulong guildId) + public static async Task<StreamRoleSettings> GetOrCreateStreamRoleSettings(this DbContext ctx, ulong guildId) { - var conf = ctx.GuildConfigsForId(guildId, - set => set.Include(y => y.StreamRole) - .Include(y => y.StreamRole.Whitelist) - .Include(y => y.StreamRole.Blacklist)); + var srs = await ctx.GetTable<StreamRoleSettings>() + .Where(x => x.GuildId == guildId) + .FirstOrDefaultAsyncEF(); - if (conf.StreamRole is null) - conf.StreamRole = new(); + if (srs is not null) + return srs; - return conf.StreamRole; - } - - private static IQueryable<GuildConfig> IncludeEverything(this DbSet<GuildConfig> configs) - => configs - .AsSplitQuery() - .Include(gc => gc.CommandCooldowns) - .Include(gc => gc.FollowedStreams) - .Include(gc => gc.StreamRole) - .Include(gc => gc.DelMsgOnCmdChannels) - .Include(gc => gc.XpSettings) - .ThenInclude(x => x.ExclusionList); - - public static async Task<GuildConfig[]> GetAllGuildConfigs( - this DbSet<GuildConfig> configs, - List<ulong> availableGuilds) - { - var result = await configs - .IncludeEverything() - .Where(x => availableGuilds.Contains(x.GuildId)) - .AsNoTracking() - .ToArrayAsync(); - - return result; - } - - /// <summary> - /// Gets and creates if it doesn't exist a config for a guild. - /// </summary> - /// <param name="ctx">Context</param> - /// <param name="guildId">Id of the guide</param> - /// <param name="includes">Use to manipulate the set however you want. Pass null to include everything</param> - /// <returns>Config for the guild</returns> - public static GuildConfig GuildConfigsForId( - this DbContext ctx, - ulong guildId, - Func<DbSet<GuildConfig>, IQueryable<GuildConfig>> includes) - { - GuildConfig config; - - if (includes is null) - config = ctx.Set<GuildConfig>().IncludeEverything().FirstOrDefault(c => c.GuildId == guildId); - else + srs = new() { - var set = includes(ctx.Set<GuildConfig>()); - config = set.FirstOrDefault(c => c.GuildId == guildId); - } + GuildId = guildId, + }; - if (config is null) - { - ctx.Set<GuildConfig>() - .Add(config = new() - { - GuildId = guildId, - Permissions = Permissionv2.GetDefaultPermlist, - WarningsInitialized = true, - }); - ctx.SaveChanges(); - } + ctx.Set<StreamRoleSettings>().Add(srs); - if (!config.WarningsInitialized) - { - config.WarningsInitialized = true; - } - - return config; - - // ctx.GuildConfigs - // .ToLinqToDBTable() - // .InsertOrUpdate(() => new() - // { - // GuildId = guildId, - // Permissions = Permissionv2.GetDefaultPermlist, - // WarningsInitialized = true, - // WarnPunishments = DefaultWarnPunishments - // }, - // _ => new(), - // () => new() - // { - // GuildId = guildId - // }); - // - // if(includes is null) - // return ctx.GuildConfigs - // .ToLinqToDBTable() - // .First(x => x.GuildId == guildId); + return srs; } public static LogSetting LogSettingsFor(this DbContext ctx, ulong guildId) @@ -148,6 +70,8 @@ public static class GuildConfigExtensions return logSetting; } + + public static IEnumerable<GuildConfig> PermissionsForAll(this DbSet<GuildConfig> configs, List<ulong> include) { var query = configs.AsQueryable().Where(x => include.Contains(x.GuildId)).Include(gc => gc.Permissions); @@ -182,45 +106,24 @@ public static class GuildConfigExtensions return config; } - public static IEnumerable<FollowedStream> GetFollowedStreams(this DbSet<GuildConfig> configs) - => configs.AsQueryable().Include(x => x.FollowedStreams).SelectMany(gc => gc.FollowedStreams).ToArray(); - - public static IEnumerable<FollowedStream> GetFollowedStreams(this DbSet<GuildConfig> configs, List<ulong> included) - => configs.AsQueryable() - .Where(gc => included.Contains(gc.GuildId)) - .Include(gc => gc.FollowedStreams) - .SelectMany(gc => gc.FollowedStreams) - .ToList(); - - - public static XpSettings XpSettingsFor(this DbContext ctx, ulong guildId) + public static async Task<XpSettings> XpSettingsFor(this DbContext ctx, ulong guildId) { - var gc = ctx.GuildConfigsForId(guildId, - set => set.Include(x => x.XpSettings) - .ThenInclude(x => x.RoleRewards) - .Include(x => x.XpSettings) - .ThenInclude(x => x.CurrencyRewards) - .Include(x => x.XpSettings) - .ThenInclude(x => x.ExclusionList)); + var srs = await ctx.GetTable<XpSettings>() + .Where(x => x.GuildId == guildId) + .FirstOrDefaultAsyncLinqToDB(); - if (gc.XpSettings is null) - gc.XpSettings = new(); + if (srs is not null) + return srs; - return gc.XpSettings; + srs = await ctx.GetTable<XpSettings>() + .InsertWithOutputAsync(() => new() + { + GuildId = guildId, + }); + + return srs; } - public static IEnumerable<GeneratingChannel> GetGeneratingChannels(this DbSet<GuildConfig> configs) - => configs.AsQueryable() - .Include(x => x.GenerateCurrencyChannelIds) - .Where(x => x.GenerateCurrencyChannelIds.Any()) - .SelectMany(x => x.GenerateCurrencyChannelIds) - .Select(x => new GeneratingChannel - { - ChannelId = x.ChannelId, - GuildId = x.GuildConfig.GuildId - }) - .ToArray(); - public class GeneratingChannel { public ulong GuildId { get; set; } diff --git a/src/EllieBot/Db/Extensions/UserXpExtensions.cs b/src/EllieBot/Db/Extensions/UserXpExtensions.cs index 05f7c41..980350a 100644 --- a/src/EllieBot/Db/Extensions/UserXpExtensions.cs +++ b/src/EllieBot/Db/Extensions/UserXpExtensions.cs @@ -9,7 +9,7 @@ public static class UserXpExtensions { public static async Task<UserXpStats?> GetGuildUserXp(this ITable<UserXpStats> table, ulong guildId, ulong userId) => await table.FirstOrDefaultAsyncLinqToDB(x => x.GuildId == guildId && x.UserId == userId); - + public static UserXpStats GetOrCreateUserXpStats(this DbContext ctx, ulong guildId, ulong userId) { var usr = ctx.Set<UserXpStats>().FirstOrDefault(x => x.UserId == userId && x.GuildId == guildId); diff --git a/src/EllieBot/Db/Models/CommandAlias.cs b/src/EllieBot/Db/Models/CommandAlias.cs index 28f614a..2ad0d7c 100644 --- a/src/EllieBot/Db/Models/CommandAlias.cs +++ b/src/EllieBot/Db/Models/CommandAlias.cs @@ -1,8 +1,21 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; public class CommandAlias : DbEntity { + public ulong GuildId { get; set; } public string Trigger { get; set; } public string Mapping { get; set; } +} + +public class CommandAliasEntityConfiguration : IEntityTypeConfiguration<CommandAlias> +{ + public void Configure(EntityTypeBuilder<CommandAlias> builder) + { + builder.HasIndex(x => x.GuildId); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/CommandCooldown.cs b/src/EllieBot/Db/Models/CommandCooldown.cs index e12ef9c..5e6c439 100644 --- a/src/EllieBot/Db/Models/CommandCooldown.cs +++ b/src/EllieBot/Db/Models/CommandCooldown.cs @@ -1,8 +1,25 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + namespace EllieBot.Db.Models; public class CommandCooldown : DbEntity -{ +{ + public ulong GuildId { get; set; } public int Seconds { get; set; } public string CommandName { get; set; } +} + +public class CommandCooldownEntityConfiguration : IEntityTypeConfiguration<CommandCooldown> +{ + public void Configure(EntityTypeBuilder<CommandCooldown> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.CommandName + }) + .IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/DelMsgOnCmdChannel.cs b/src/EllieBot/Db/Models/DelMsgOnCmdChannel.cs index dd70ed6..1df6817 100644 --- a/src/EllieBot/Db/Models/DelMsgOnCmdChannel.cs +++ b/src/EllieBot/Db/Models/DelMsgOnCmdChannel.cs @@ -1,16 +1,25 @@ -#nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + namespace EllieBot.Db.Models; public class DelMsgOnCmdChannel : DbEntity { - public int GuildConfigId { get; set; } - + public ulong GuildId { get; set; } public ulong ChannelId { get; set; } public bool State { get; set; } +} - public override int GetHashCode() - => ChannelId.GetHashCode(); - - public override bool Equals(object obj) - => obj is DelMsgOnCmdChannel x && x.ChannelId == ChannelId; -} \ No newline at end of file +public class DelMsgOnCmdChannelEntityConfiguration : IEntityTypeConfiguration<DelMsgOnCmdChannel> +{ + public void Configure(EntityTypeBuilder<DelMsgOnCmdChannel> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.ChannelId + }).IsUnique(); + } +} diff --git a/src/EllieBot/Db/Models/DiscordUser.cs b/src/EllieBot/Db/Models/DiscordUser.cs index 3ac3f5c..0c51df4 100644 --- a/src/EllieBot/Db/Models/DiscordUser.cs +++ b/src/EllieBot/Db/Models/DiscordUser.cs @@ -1,6 +1,7 @@ #nullable disable namespace EllieBot.Db.Models; + // FUTURE remove LastLevelUp from here and UserXpStats public class DiscordUser : DbEntity { diff --git a/src/EllieBot/Db/Models/FeedSub.cs b/src/EllieBot/Db/Models/FeedSub.cs index f257f96..eb9d703 100644 --- a/src/EllieBot/Db/Models/FeedSub.cs +++ b/src/EllieBot/Db/Models/FeedSub.cs @@ -1,19 +1,29 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + namespace EllieBot.Db.Models; public class FeedSub : DbEntity { - public int GuildConfigId { get; set; } - public GuildConfig GuildConfig { get; set; } + public ulong GuildId { get; set; } public ulong ChannelId { get; set; } public string Url { get; set; } - + public string Message { get; set; } +} - public override int GetHashCode() - => Url.GetHashCode(StringComparison.InvariantCulture) ^ GuildConfigId.GetHashCode(); - - public override bool Equals(object obj) - => obj is FeedSub s && s.Url.ToLower() == Url.ToLower() && s.GuildConfigId == GuildConfigId; +public sealed class FeedSubEntityConfiguration : IEntityTypeConfiguration<FeedSub> +{ + public void Configure(EntityTypeBuilder<FeedSub> builder) + { + builder + .HasIndex(x => new + { + x.GuildId, + x.Url + }) + .IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/FlagTranslateChannel.cs b/src/EllieBot/Db/Models/FlagTranslateChannel.cs index 1fe04d7..94508ff 100644 --- a/src/EllieBot/Db/Models/FlagTranslateChannel.cs +++ b/src/EllieBot/Db/Models/FlagTranslateChannel.cs @@ -1,4 +1,4 @@ -#nullable disable +#nullable disable namespace EllieBot.Db.Models; public class FlagTranslateChannel : DbEntity diff --git a/src/EllieBot/Db/Models/FollowedStream.cs b/src/EllieBot/Db/Models/FollowedStream.cs index 0ee5949..b6a4065 100644 --- a/src/EllieBot/Db/Models/FollowedStream.cs +++ b/src/EllieBot/Db/Models/FollowedStream.cs @@ -1,7 +1,10 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + namespace EllieBot.Db.Models; -public class FollowedStream : DbEntity +public class FollowedStream { public enum FType { @@ -12,7 +15,7 @@ public class FollowedStream : DbEntity Trovo = 6, Kick = 7, } - + public int Id { get; set; } public ulong GuildId { get; set; } public ulong ChannelId { get; set; } public string Username { get; set; } @@ -29,6 +32,17 @@ public class FollowedStream : DbEntity public override bool Equals(object obj) => obj is FollowedStream fs && Equals(fs); +} - +public sealed class FollowedStreamEntityConfig : IEntityTypeConfiguration<FollowedStream> +{ + public void Configure(EntityTypeBuilder<FollowedStream> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.Username, + x.Type, + }); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/GCChannelId.cs b/src/EllieBot/Db/Models/GCChannelId.cs index c6f922b..a4dca92 100644 --- a/src/EllieBot/Db/Models/GCChannelId.cs +++ b/src/EllieBot/Db/Models/GCChannelId.cs @@ -1,14 +1,24 @@ -#nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; public class GCChannelId : DbEntity { - public GuildConfig GuildConfig { get; set; } + public ulong GuildId { get; set; } public ulong ChannelId { get; set; } +} - public override bool Equals(object obj) - => obj is GCChannelId gc && gc.ChannelId == ChannelId; - - public override int GetHashCode() - => ChannelId.GetHashCode(); +public class GCChannelIdEntityConfiguration : IEntityTypeConfiguration<GCChannelId> +{ + public void Configure(EntityTypeBuilder<GCChannelId> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.ChannelId + }) + .IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/GuildConfig.cs b/src/EllieBot/Db/Models/GuildConfig.cs index 76d98a0..3264088 100644 --- a/src/EllieBot/Db/Models/GuildConfig.cs +++ b/src/EllieBot/Db/Models/GuildConfig.cs @@ -1,85 +1,59 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; +public class GuildFilterConfig +{ + [Key] + public int Id { get; set; } + + public ulong GuildId { get; set; } + public bool FilterInvites { get; set; } + public bool FilterLinks { get; set; } + public bool FilterWords { get; set; } + public HashSet<FilterChannelId> FilterInvitesChannelIds { get; set; } = new(); + public HashSet<FilterLinksChannelId> FilterLinksChannelIds { get; set; } = new(); + + public HashSet<FilteredWord> FilteredWords { get; set; } = new(); + public HashSet<FilterWordsChannelId> FilterWordsChannelIds { get; set; } = new(); +} + +public sealed class GuildFilterConfigEntityConfiguration : IEntityTypeConfiguration<GuildFilterConfig> +{ + public void Configure(EntityTypeBuilder<GuildFilterConfig> builder) + { + builder.HasIndex(x => x.GuildId); + } +} + public class GuildConfig : DbEntity { - // public bool Keep { get; set; } public ulong GuildId { get; set; } - public string Prefix { get; set; } public bool DeleteMessageOnCommand { get; set; } - public HashSet<DelMsgOnCmdChannel> DelMsgOnCmdChannels { get; set; } = new(); public string AutoAssignRoleIds { get; set; } - //todo FUTURE: DELETE, UNUSED - public bool ExclusiveSelfAssignedRoles { get; set; } - public bool AutoDeleteSelfAssignedRoleMessages { get; set; } - - - //stream notifications - public HashSet<FollowedStream> FollowedStreams { get; set; } = new(); - - //currencyGeneration - public HashSet<GCChannelId> GenerateCurrencyChannelIds { get; set; } = new(); - - public List<Permissionv2> Permissions { get; set; } public bool VerbosePermissions { get; set; } = true; public string PermissionRole { get; set; } - public HashSet<CommandCooldown> CommandCooldowns { get; set; } = new(); - //filtering - public bool FilterInvites { get; set; } - public bool FilterLinks { get; set; } - public HashSet<FilterChannelId> FilterInvitesChannelIds { get; set; } = new(); - public HashSet<FilterLinksChannelId> FilterLinksChannelIds { get; set; } = new(); - - public bool FilterWords { get; set; } - public HashSet<FilteredWord> FilteredWords { get; set; } = new(); - public HashSet<FilterWordsChannelId> FilterWordsChannelIds { get; set; } = new(); - - // mute - public HashSet<MutedUserId> MutedUsers { get; set; } = new(); - public string MuteRoleName { get; set; } // chatterbot public bool CleverbotEnabled { get; set; } - // protection - public AntiRaidSetting AntiRaidSetting { get; set; } - public AntiSpamSetting AntiSpamSetting { get; set; } - public AntiAltSetting AntiAltSetting { get; set; } - - // time - public string Locale { get; set; } - public string TimeZoneId { get; set; } - - - // timers - public HashSet<UnmuteTimer> UnmuteTimers { get; set; } = new(); - public HashSet<UnbanTimer> UnbanTimer { get; set; } = new(); - public HashSet<UnroleTimer> UnroleTimer { get; set; } = new(); - - // vcrole - public HashSet<VcRoleInfo> VcRoleInfos { get; set; } - // aliases - public HashSet<CommandAlias> CommandAliases { get; set; } = new(); public bool WarningsInitialized { get; set; } - public HashSet<SlowmodeIgnoredUser> SlowmodeIgnoredUsers { get; set; } - public HashSet<SlowmodeIgnoredRole> SlowmodeIgnoredRoles { get; set; } - public List<ShopEntry> ShopEntries { get; set; } public ulong? GameVoiceChannel { get; set; } public bool VerboseErrors { get; set; } = true; - public StreamRoleSettings StreamRole { get; set; } - public XpSettings XpSettings { get; set; } - public List<FeedSub> FeedSubs { get; set; } = new(); public bool NotifyStreamOffline { get; set; } public bool DeleteStreamOnlineMessage { get; set; } public int WarnExpireHours { get; set; } @@ -88,4 +62,9 @@ public class GuildConfig : DbEntity public bool DisableGlobalExpressions { get; set; } = false; public bool StickyRoles { get; set; } + + public string TimeZoneId { get; set; } + public string Locale { get; set; } + + public List<Permissionv2> Permissions { get; set; } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/NCanvas/NCanvas.cs b/src/EllieBot/Db/Models/NCanvas/NCanvas.cs index 8de17cb..0d62920 100644 --- a/src/EllieBot/Db/Models/NCanvas/NCanvas.cs +++ b/src/EllieBot/Db/Models/NCanvas/NCanvas.cs @@ -1,4 +1,4 @@ -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; namespace EllieBot.Db.Models; @@ -6,14 +6,14 @@ public class NCPixel { [Key] public int Id { get; set; } - + public required int Position { get; init; } - + public required long Price { get; init; } - + public required ulong OwnerId { get; init; } public required uint Color { get; init; } - + [MaxLength(256)] public required string Text { get; init; } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/Permission.cs b/src/EllieBot/Db/Models/Permission.cs index b926f92..2cef364 100644 --- a/src/EllieBot/Db/Models/Permission.cs +++ b/src/EllieBot/Db/Models/Permission.cs @@ -1,4 +1,6 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics; @@ -7,7 +9,8 @@ namespace EllieBot.Db.Models; [DebuggerDisplay("{PrimaryTarget}{SecondaryTarget} {SecondaryTargetName} {State} {PrimaryTargetId}")] public class Permissionv2 : DbEntity, IIndexed { - public int? GuildConfigId { get; set; } + public ulong GuildId { get; set; } + public int Index { get; set; } public PrimaryPermissionType PrimaryTarget { get; set; } @@ -49,4 +52,12 @@ public enum SecondaryPermissionType Module, Command, AllModules -} \ No newline at end of file +} + +public sealed class Permissionv2EntityConfiguration : IEntityTypeConfiguration<Permissionv2> +{ + public void Configure(EntityTypeBuilder<Permissionv2> builder) + { + builder.HasIndex(x => x.GuildId); + } +} diff --git a/src/EllieBot/Db/Models/SarGroup.cs b/src/EllieBot/Db/Models/SarGroup.cs index df7c074..66eceea 100644 --- a/src/EllieBot/Db/Models/SarGroup.cs +++ b/src/EllieBot/Db/Models/SarGroup.cs @@ -12,7 +12,7 @@ public sealed class SarGroup public ulong? RoleReq { get; set; } public ICollection<Sar> Roles { get; set; } = []; public bool IsExclusive { get; set; } - + [MaxLength(100)] public string? Name { get; set; } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/ShopEntry.cs b/src/EllieBot/Db/Models/ShopEntry.cs index a21c7e6..c2d5cbe 100644 --- a/src/EllieBot/Db/Models/ShopEntry.cs +++ b/src/EllieBot/Db/Models/ShopEntry.cs @@ -1,16 +1,21 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; public enum ShopEntryType { Role, - List, Command } public class ShopEntry : DbEntity, IIndexed { + public ulong GuildId { get; set; } + public int Index { get; set; } public int Price { get; set; } public string Name { get; set; } @@ -25,7 +30,7 @@ public class ShopEntry : DbEntity, IIndexed //list public HashSet<ShopEntryItem> Items { get; set; } = new(); public ulong? RoleRequirement { get; set; } - + // command public string Command { get; set; } } @@ -43,4 +48,22 @@ public class ShopEntryItem : DbEntity public override int GetHashCode() => Text.GetHashCode(StringComparison.InvariantCulture); +} + +public class ShopEntryEntityConfiguration : IEntityTypeConfiguration<ShopEntry> +{ + public void Configure(EntityTypeBuilder<ShopEntry> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.Index + }) + .IsUnique(); + + builder + .HasMany(x => x.Items) + .WithOne() + .OnDelete(DeleteBehavior.Cascade); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/StreamRoleSettings.cs b/src/EllieBot/Db/Models/StreamRoleSettings.cs index bd36b4c..ccae7c1 100644 --- a/src/EllieBot/Db/Models/StreamRoleSettings.cs +++ b/src/EllieBot/Db/Models/StreamRoleSettings.cs @@ -1,10 +1,16 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + namespace EllieBot.Db.Models; public class StreamRoleSettings : DbEntity { public int GuildConfigId { get; set; } - public GuildConfig GuildConfig { get; set; } + + public ulong GuildId { get; set; } /// <summary> /// Whether the feature is enabled in the guild. @@ -42,7 +48,7 @@ public class StreamRoleBlacklistedUser : DbEntity { public int StreamRoleSettingsId { get; set; } public StreamRoleSettings StreamRoleSettings { get; set; } - + public ulong UserId { get; set; } public string Username { get; set; } @@ -62,7 +68,7 @@ public class StreamRoleWhitelistedUser : DbEntity { public int StreamRoleSettingsId { get; set; } public StreamRoleSettings StreamRoleSettings { get; set; } - + public ulong UserId { get; set; } public string Username { get; set; } @@ -71,4 +77,25 @@ public class StreamRoleWhitelistedUser : DbEntity public override int GetHashCode() => UserId.GetHashCode(); +} + +public class StreamRoleSettingsEntityConfiguration : IEntityTypeConfiguration<StreamRoleSettings> +{ + public void Configure(EntityTypeBuilder<StreamRoleSettings> builder) + { + builder.HasIndex(x => x.GuildId) + .IsUnique(); + + builder + .HasMany(x => x.Whitelist) + .WithOne(x => x.StreamRoleSettings) + .HasForeignKey(x => x.StreamRoleSettingsId) + .OnDelete(DeleteBehavior.Cascade); + + builder + .HasMany(x => x.Blacklist) + .WithOne(x => x.StreamRoleSettings) + .HasForeignKey(x => x.StreamRoleSettingsId) + .OnDelete(DeleteBehavior.Cascade); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/VcRoleInfo.cs b/src/EllieBot/Db/Models/VcRoleInfo.cs index bb28450..4ab644a 100644 --- a/src/EllieBot/Db/Models/VcRoleInfo.cs +++ b/src/EllieBot/Db/Models/VcRoleInfo.cs @@ -1,8 +1,26 @@ -#nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; public class VcRoleInfo : DbEntity { + public ulong GuildId { get; set; } public ulong VoiceChannelId { get; set; } + public ulong RoleId { get; set; } +} + +public class VcRoleInfoEntityConfiguration : IEntityTypeConfiguration<VcRoleInfo> +{ + public void Configure(EntityTypeBuilder<VcRoleInfo> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.VoiceChannelId + }) + .IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/Waifu.cs b/src/EllieBot/Db/Models/Waifu.cs index 2583afb..939f5de 100644 --- a/src/EllieBot/Db/Models/Waifu.cs +++ b/src/EllieBot/Db/Models/Waifu.cs @@ -1,7 +1,7 @@ #nullable disable using EllieBot.Db.Models; -namespace EllieBot.Services.Database.Models; +namespace Ellieices.Database.Models; public class WaifuInfo : DbEntity { diff --git a/src/EllieBot/Db/Models/anti/AntiAltSetting.cs b/src/EllieBot/Db/Models/anti/AntiAltSetting.cs index cb0da3c..f258245 100644 --- a/src/EllieBot/Db/Models/anti/AntiAltSetting.cs +++ b/src/EllieBot/Db/Models/anti/AntiAltSetting.cs @@ -1,12 +1,30 @@ -namespace EllieBot.Db.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EllieBot.Db.Models; public class AntiAltSetting { - public int GuildConfigId { get; set; } - + [Key] public int Id { get; set; } + + public int GuildConfigId { get; set; } + + public ulong GuildId { get; set; } + public TimeSpan MinAge { get; set; } public PunishmentAction Action { get; set; } public int ActionDurationMinutes { get; set; } public ulong? RoleId { get; set; } +} + +public class AntiAltSettingEntityConfiguration : IEntityTypeConfiguration<AntiAltSetting> +{ + public void Configure(EntityTypeBuilder<AntiAltSetting> builder) + { + builder.HasIndex(x => x.GuildId) + .IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs b/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs index 1e219eb..e62d3cf 100644 --- a/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs +++ b/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs @@ -1,11 +1,13 @@ #nullable disable -namespace EllieBot.Db.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations.Schema; +namespace EllieBot.Db.Models; public class AntiRaidSetting : DbEntity { - public int GuildConfigId { get; set; } - + public ulong GuildId { get; set; } public int UserThreshold { get; set; } public int Seconds { get; set; } public PunishmentAction Action { get; set; } @@ -15,4 +17,13 @@ public class AntiRaidSetting : DbEntity /// Mute, Chatmute, Voicemute, etc... /// </summary> public int PunishDuration { get; set; } +} + +public class AntiRaidSettingEntityConfiguration : IEntityTypeConfiguration<AntiRaidSetting> +{ + public void Configure(EntityTypeBuilder<AntiRaidSetting> builder) + { + builder.HasIndex(x => x.GuildId) + .IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/anti/AntiSpamIgnore.cs b/src/EllieBot/Db/Models/anti/AntiSpamIgnore.cs index a3cd623..da6c329 100644 --- a/src/EllieBot/Db/Models/anti/AntiSpamIgnore.cs +++ b/src/EllieBot/Db/Models/anti/AntiSpamIgnore.cs @@ -3,10 +3,4 @@ public class AntiSpamIgnore : DbEntity { public ulong ChannelId { get; set; } - - public override int GetHashCode() - => ChannelId.GetHashCode(); - - public override bool Equals(object? obj) - => obj is AntiSpamIgnore inst && inst.ChannelId == ChannelId; } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/anti/AntiSpamSetting.cs b/src/EllieBot/Db/Models/anti/AntiSpamSetting.cs index 7e19253..6f335f0 100644 --- a/src/EllieBot/Db/Models/anti/AntiSpamSetting.cs +++ b/src/EllieBot/Db/Models/anti/AntiSpamSetting.cs @@ -1,13 +1,34 @@ -namespace EllieBot.Db.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EllieBot.Db.Models; #nullable disable public class AntiSpamSetting : DbEntity { public int GuildConfigId { get; set; } - + + public ulong GuildId { get; set; } + public PunishmentAction Action { get; set; } public int MessageThreshold { get; set; } = 3; public int MuteTime { get; set; } public ulong? RoleId { get; set; } - public HashSet<AntiSpamIgnore> IgnoredChannels { get; set; } = new(); + public List<AntiSpamIgnore> IgnoredChannels { get; set; } = new(); +} + +// setup model +public class AntiSpamEntityConfiguration : IEntityTypeConfiguration<AntiSpamSetting> +{ + public void Configure(EntityTypeBuilder<AntiSpamSetting> builder) + { + builder.HasIndex(x => x.GuildId) + .IsUnique(); + + builder.HasMany(x => x.IgnoredChannels) + .WithOne() + .OnDelete(DeleteBehavior.Cascade); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/btnrole/ButtonRole.cs b/src/EllieBot/Db/Models/btnrole/ButtonRole.cs index 053ea2d..1a1a848 100644 --- a/src/EllieBot/Db/Models/btnrole/ButtonRole.cs +++ b/src/EllieBot/Db/Models/btnrole/ButtonRole.cs @@ -1,4 +1,4 @@ -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; namespace EllieBot.Db.Models; @@ -24,4 +24,4 @@ public sealed class ButtonRole public string Label { get; set; } = string.Empty; public bool Exclusive { get; set; } -} +} \ No newline at end of file diff --git a/src/EllieBot/Db/Models/filter/FilterChannelId.cs b/src/EllieBot/Db/Models/filter/FilterChannelId.cs index eb1d965..e470473 100644 --- a/src/EllieBot/Db/Models/filter/FilterChannelId.cs +++ b/src/EllieBot/Db/Models/filter/FilterChannelId.cs @@ -1,16 +1,21 @@ -#nullable disable +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + namespace EllieBot.Db.Models; -public class FilterChannelId : DbEntity +public class FilterChannelId { + [Key] + public int Id { get; set; } + public ulong ChannelId { get; set; } - public bool Equals(FilterChannelId other) + protected bool Equals(FilterChannelId other) => ChannelId == other.ChannelId; - public override bool Equals(object obj) - => obj is FilterChannelId fci && Equals(fci); + public override bool Equals(object? obj) + => obj is FilterChannelId fci && fci.Equals(this); public override int GetHashCode() => ChannelId.GetHashCode(); -} +} \ No newline at end of file diff --git a/src/EllieBot/Db/Models/filter/FilterLinksChannelId.cs b/src/EllieBot/Db/Models/filter/FilterLinksChannelId.cs index 50aca96..e8be32d 100644 --- a/src/EllieBot/Db/Models/filter/FilterLinksChannelId.cs +++ b/src/EllieBot/Db/Models/filter/FilterLinksChannelId.cs @@ -1,12 +1,16 @@ -#nullable disable +using System.ComponentModel.DataAnnotations.Schema; + namespace EllieBot.Db.Models; public class FilterLinksChannelId : DbEntity { public ulong ChannelId { get; set; } - public override bool Equals(object obj) - => obj is FilterLinksChannelId f && f.ChannelId == ChannelId; + protected bool Equals(FilterLinksChannelId other) + => ChannelId == other.ChannelId; + + public override bool Equals(object? obj) + => obj is FilterLinksChannelId other && Equals(other); public override int GetHashCode() => ChannelId.GetHashCode(); diff --git a/src/EllieBot/Db/Models/filter/FilterWordsChannelId.cs b/src/EllieBot/Db/Models/filter/FilterWordsChannelId.cs index 6921032..71552ae 100644 --- a/src/EllieBot/Db/Models/filter/FilterWordsChannelId.cs +++ b/src/EllieBot/Db/Models/filter/FilterWordsChannelId.cs @@ -1,16 +1,17 @@ #nullable disable +using System.ComponentModel.DataAnnotations.Schema; + namespace EllieBot.Db.Models; public class FilterWordsChannelId : DbEntity { - public int? GuildConfigId { get; set; } public ulong ChannelId { get; set; } - public bool Equals(FilterWordsChannelId other) + protected bool Equals(FilterWordsChannelId other) => ChannelId == other.ChannelId; public override bool Equals(object obj) - => obj is FilterWordsChannelId fci && Equals(fci); + => obj is FilterWordsChannelId other && Equals(other); public override int GetHashCode() => ChannelId.GetHashCode(); diff --git a/src/EllieBot/Db/Models/filter/FilteredWord.cs b/src/EllieBot/Db/Models/filter/FilteredWord.cs index de66d7a..c06179e 100644 --- a/src/EllieBot/Db/Models/filter/FilteredWord.cs +++ b/src/EllieBot/Db/Models/filter/FilteredWord.cs @@ -1,7 +1,10 @@ -#nullable disable namespace EllieBot.Db.Models; public class FilteredWord : DbEntity { - public string Word { get; set; } + public string Word { get; set; } = string.Empty; + + public override bool Equals(object? obj) => obj is FilteredWord fw && fw.Word == Word; + + public override int GetHashCode() => Word.GetHashCode(); } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/punish/MutedUserId.cs b/src/EllieBot/Db/Models/punish/MutedUserId.cs index f067e77..a0c4b08 100644 --- a/src/EllieBot/Db/Models/punish/MutedUserId.cs +++ b/src/EllieBot/Db/Models/punish/MutedUserId.cs @@ -1,13 +1,24 @@ -#nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; public class MutedUserId : DbEntity { + public ulong GuildId { get; set; } public ulong UserId { get; set; } +} - public override int GetHashCode() - => UserId.GetHashCode(); - - public override bool Equals(object obj) - => obj is MutedUserId mui ? mui.UserId == UserId : false; +public class MutedUserIdEntityConfiguration : IEntityTypeConfiguration<MutedUserId> +{ + public void Configure(EntityTypeBuilder<MutedUserId> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.UserId + }) + .IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/roles/TempRole.cs b/src/EllieBot/Db/Models/roles/TempRole.cs index 5af1d80..88db685 100644 --- a/src/EllieBot/Db/Models/roles/TempRole.cs +++ b/src/EllieBot/Db/Models/roles/TempRole.cs @@ -7,6 +7,6 @@ public class TempRole public bool Remove { get; set; } public ulong RoleId { get; set; } public ulong UserId { get; set; } - + public DateTime ExpiresAt { get; set; } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/slowmode/SlowmodeIgnoredRole.cs b/src/EllieBot/Db/Models/slowmode/SlowmodeIgnoredRole.cs index e41c2e7..6d72c19 100644 --- a/src/EllieBot/Db/Models/slowmode/SlowmodeIgnoredRole.cs +++ b/src/EllieBot/Db/Models/slowmode/SlowmodeIgnoredRole.cs @@ -1,20 +1,24 @@ -#nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; public class SlowmodeIgnoredRole : DbEntity { + public ulong GuildId { get; set; } public ulong RoleId { get; set; } +} - // override object.Equals - public override bool Equals(object obj) +public class SlowmodeIgnoredRoleEntityConfiguration : IEntityTypeConfiguration<SlowmodeIgnoredRole> +{ + public void Configure(EntityTypeBuilder<SlowmodeIgnoredRole> builder) { - if (obj is null || GetType() != obj.GetType()) - return false; - - return ((SlowmodeIgnoredRole)obj).RoleId == RoleId; + builder.HasIndex(x => new + { + x.GuildId, + x.RoleId + }) + .IsUnique(); } - - // override object.GetHashCode - public override int GetHashCode() - => RoleId.GetHashCode(); } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/slowmode/SlowmodeIgnoredUser.cs b/src/EllieBot/Db/Models/slowmode/SlowmodeIgnoredUser.cs index 7ae0a05..a873339 100644 --- a/src/EllieBot/Db/Models/slowmode/SlowmodeIgnoredUser.cs +++ b/src/EllieBot/Db/Models/slowmode/SlowmodeIgnoredUser.cs @@ -1,20 +1,24 @@ -#nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; public class SlowmodeIgnoredUser : DbEntity { + public ulong GuildId { get; set; } public ulong UserId { get; set; } +} - // override object.Equals - public override bool Equals(object obj) +public class SlowmodeIgnoredUserEntityConfiguration : IEntityTypeConfiguration<SlowmodeIgnoredUser> +{ + public void Configure(EntityTypeBuilder<SlowmodeIgnoredUser> builder) { - if (obj is null || GetType() != obj.GetType()) - return false; - - return ((SlowmodeIgnoredUser)obj).UserId == UserId; + builder.HasIndex(x => new + { + x.GuildId, + x.UserId + }) + .IsUnique(); } - - // override object.GetHashCode - public override int GetHashCode() - => UserId.GetHashCode(); } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/untimer/UnbanTimer.cs b/src/EllieBot/Db/Models/untimer/UnbanTimer.cs index 2f61402..75d7cea 100644 --- a/src/EllieBot/Db/Models/untimer/UnbanTimer.cs +++ b/src/EllieBot/Db/Models/untimer/UnbanTimer.cs @@ -1,14 +1,26 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; public class UnbanTimer : DbEntity { + public ulong GuildId { get; set; } public ulong UserId { get; set; } public DateTime UnbanAt { get; set; } +} - public override int GetHashCode() - => UserId.GetHashCode(); - - public override bool Equals(object obj) - => obj is UnbanTimer ut ? ut.UserId == UserId : false; +public class UnbanTimerEntityConfiguration : IEntityTypeConfiguration<UnbanTimer> +{ + public void Configure(EntityTypeBuilder<UnbanTimer> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.UserId + }) + .IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/untimer/UnmuteTimer.cs b/src/EllieBot/Db/Models/untimer/UnmuteTimer.cs index 18b2903..1619dcd 100644 --- a/src/EllieBot/Db/Models/untimer/UnmuteTimer.cs +++ b/src/EllieBot/Db/Models/untimer/UnmuteTimer.cs @@ -1,14 +1,25 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.ComponentModel.DataAnnotations; + namespace EllieBot.Db.Models; public class UnmuteTimer : DbEntity { + public ulong GuildId { get; set; } public ulong UserId { get; set; } public DateTime UnmuteAt { get; set; } +} - public override int GetHashCode() - => UserId.GetHashCode(); - - public override bool Equals(object obj) - => obj is UnmuteTimer ut ? ut.UserId == UserId : false; +public class UnmuteTimerEntityConfiguration : IEntityTypeConfiguration<UnmuteTimer> +{ + public void Configure(EntityTypeBuilder<UnmuteTimer> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.UserId + }).IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/untimer/UnroleTimer.cs b/src/EllieBot/Db/Models/untimer/UnroleTimer.cs index 27193c2..312e465 100644 --- a/src/EllieBot/Db/Models/untimer/UnroleTimer.cs +++ b/src/EllieBot/Db/Models/untimer/UnroleTimer.cs @@ -1,15 +1,27 @@ #nullable disable +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + namespace EllieBot.Db.Models; +// todo UN* remove unroletimer in favor of temprole public class UnroleTimer : DbEntity { + public ulong GuildId { get; set; } public ulong UserId { get; set; } public ulong RoleId { get; set; } public DateTime UnbanAt { get; set; } +} - public override int GetHashCode() - => UserId.GetHashCode() ^ RoleId.GetHashCode(); - - public override bool Equals(object obj) - => obj is UnroleTimer ut ? ut.UserId == UserId && ut.RoleId == RoleId : false; +public class UnroleTimerEntityConfiguration : IEntityTypeConfiguration<UnroleTimer> +{ + public void Configure(EntityTypeBuilder<UnroleTimer> builder) + { + builder.HasIndex(x => new + { + x.GuildId, + x.UserId + }) + .IsUnique(); + } } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/xp/ExcludedItem.cs b/src/EllieBot/Db/Models/xp/ExcludedItem.cs new file mode 100644 index 0000000..de2c409 --- /dev/null +++ b/src/EllieBot/Db/Models/xp/ExcludedItem.cs @@ -0,0 +1,13 @@ +namespace EllieBot.Db.Models; + +public class ExcludedItem : DbEntity +{ + public ulong ItemId { get; set; } + public ExcludedItemType ItemType { get; set; } + + public override int GetHashCode() + => ItemId.GetHashCode() ^ ItemType.GetHashCode(); + + public override bool Equals(object? obj) + => obj is ExcludedItem ei && ei.ItemId == ItemId && ei.ItemType == ItemType; +} \ No newline at end of file diff --git a/src/EllieBot/Db/Models/xp/ExcludedItemType.cs b/src/EllieBot/Db/Models/xp/ExcludedItemType.cs new file mode 100644 index 0000000..e6b1e6a --- /dev/null +++ b/src/EllieBot/Db/Models/xp/ExcludedItemType.cs @@ -0,0 +1,3 @@ +namespace EllieBot.Db.Models; + +public enum ExcludedItemType { Channel, Role } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/xp/XpCurrencyReward.cs b/src/EllieBot/Db/Models/xp/XpCurrencyReward.cs new file mode 100644 index 0000000..c8ef038 --- /dev/null +++ b/src/EllieBot/Db/Models/xp/XpCurrencyReward.cs @@ -0,0 +1,8 @@ +namespace EllieBot.Db.Models; + +public class XpCurrencyReward : DbEntity +{ + public int XpSettingsId { get; set; } + public int Level { get; set; } + public int Amount { get; set; } +} \ No newline at end of file diff --git a/src/EllieBot/Db/Models/xp/XpCurrencyRewardEntityConfiguration.cs b/src/EllieBot/Db/Models/xp/XpCurrencyRewardEntityConfiguration.cs new file mode 100644 index 0000000..eccc348 --- /dev/null +++ b/src/EllieBot/Db/Models/xp/XpCurrencyRewardEntityConfiguration.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace EllieBot.Db.Models; + +public class XpCurrencyRewardEntityConfiguration : IEntityTypeConfiguration<XpCurrencyReward> +{ + public void Configure(EntityTypeBuilder<XpCurrencyReward> builder) + { + builder.HasIndex(x => new + { + x.Level, + x.XpSettingsId + }) + .IsUnique(); + } +} \ No newline at end of file diff --git a/src/EllieBot/Db/Models/xp/XpNotificationLocation.cs b/src/EllieBot/Db/Models/xp/XpNotificationLocation.cs index b410fcd..e5c24c7 100644 --- a/src/EllieBot/Db/Models/xp/XpNotificationLocation.cs +++ b/src/EllieBot/Db/Models/xp/XpNotificationLocation.cs @@ -1,4 +1,4 @@ -namespace EllieBot.Db.Models; +namespace EllieBot.Db.Models; public enum XpNotificationLocation { diff --git a/src/EllieBot/Db/Models/xp/XpRoleReward.cs b/src/EllieBot/Db/Models/xp/XpRoleReward.cs new file mode 100644 index 0000000..53b2bce --- /dev/null +++ b/src/EllieBot/Db/Models/xp/XpRoleReward.cs @@ -0,0 +1,13 @@ +namespace EllieBot.Db.Models; + +public class XpRoleReward : DbEntity +{ + public int XpSettingsId { get; set; } + public int Level { get; set; } + public ulong RoleId { get; set; } + + /// <summary> + /// Whether the role should be removed (true) or added (false) + /// </summary> + public bool Remove { get; set; } +} \ No newline at end of file diff --git a/src/EllieBot/Db/Models/xp/XpRoleRewardEntityConfiguration.cs b/src/EllieBot/Db/Models/xp/XpRoleRewardEntityConfiguration.cs new file mode 100644 index 0000000..70e9334 --- /dev/null +++ b/src/EllieBot/Db/Models/xp/XpRoleRewardEntityConfiguration.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace EllieBot.Db.Models; + +public class XpRoleRewardEntityConfiguration : IEntityTypeConfiguration<XpRoleReward> +{ + public void Configure(EntityTypeBuilder<XpRoleReward> builder) + { + builder.HasIndex(x => new + { + x.XpSettingsId, + x.Level + }) + .IsUnique(); + } +} \ No newline at end of file diff --git a/src/EllieBot/Db/Models/xp/XpSettings.cs b/src/EllieBot/Db/Models/xp/XpSettings.cs index 50fd5be..f5af7e9 100644 --- a/src/EllieBot/Db/Models/xp/XpSettings.cs +++ b/src/EllieBot/Db/Models/xp/XpSettings.cs @@ -1,64 +1,15 @@ #nullable disable +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + namespace EllieBot.Db.Models; public class XpSettings : DbEntity { - public int GuildConfigId { get; set; } - public GuildConfig GuildConfig { get; set; } + public ulong GuildId { get; set; } + public bool ServerExcluded { get; set; } + public HashSet<ExcludedItem> ExclusionList { get; set; } = new(); public HashSet<XpRoleReward> RoleRewards { get; set; } = new(); public HashSet<XpCurrencyReward> CurrencyRewards { get; set; } = new(); - public HashSet<ExcludedItem> ExclusionList { get; set; } = new(); - public bool ServerExcluded { get; set; } -} - -public enum ExcludedItemType { Channel, Role } - -public class XpRoleReward : DbEntity -{ - public int XpSettingsId { get; set; } - public XpSettings XpSettings { get; set; } - - public int Level { get; set; } - public ulong RoleId { get; set; } - - /// <summary> - /// Whether the role should be removed (true) or added (false) - /// </summary> - public bool Remove { get; set; } - - public override int GetHashCode() - => Level.GetHashCode() ^ XpSettingsId.GetHashCode(); - - public override bool Equals(object obj) - => obj is XpRoleReward xrr && xrr.Level == Level && xrr.XpSettingsId == XpSettingsId; -} - -public class XpCurrencyReward : DbEntity -{ - public int XpSettingsId { get; set; } - public XpSettings XpSettings { get; set; } - - public int Level { get; set; } - public int Amount { get; set; } - - public override int GetHashCode() - => Level.GetHashCode() ^ XpSettingsId.GetHashCode(); - - public override bool Equals(object obj) - => obj is XpCurrencyReward xrr && xrr.Level == Level && xrr.XpSettingsId == XpSettingsId; -} - -public class ExcludedItem : DbEntity -{ - public XpSettings XpSettings { get; set; } - - public ulong ItemId { get; set; } - public ExcludedItemType ItemType { get; set; } - - public override int GetHashCode() - => ItemId.GetHashCode() ^ ItemType.GetHashCode(); - - public override bool Equals(object obj) - => obj is ExcludedItem ei && ei.ItemId == ItemId && ei.ItemType == ItemType; } \ No newline at end of file diff --git a/src/EllieBot/Db/Models/xp/XpSettingsEntityConfiguration.cs b/src/EllieBot/Db/Models/xp/XpSettingsEntityConfiguration.cs new file mode 100644 index 0000000..a5fd6b8 --- /dev/null +++ b/src/EllieBot/Db/Models/xp/XpSettingsEntityConfiguration.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace EllieBot.Db.Models; + +public class XpSettingsEntityConfiguration : IEntityTypeConfiguration<XpSettings> +{ + public void Configure(EntityTypeBuilder<XpSettings> builder) + { + builder.HasIndex(x => x.GuildId) + .IsUnique(); + + builder.HasMany(x => x.CurrencyRewards) + .WithOne(); + + builder.HasMany(x => x.RoleRewards) + .WithOne(); + + builder.HasMany(x => x.ExclusionList) + .WithOne(); + } +} \ No newline at end of file diff --git a/src/EllieBot/Migrations/MigrationQueries.cs b/src/EllieBot/Migrations/MigrationQueries.cs deleted file mode 100644 index 397b061..0000000 --- a/src/EllieBot/Migrations/MigrationQueries.cs +++ /dev/null @@ -1,133 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace EllieBot.Migrations; - -public static class MigrationQueries -{ - public static void MergeAwardedXp(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql(""" - UPDATE UserXpStats - SET Xp = AwardedXp + Xp, - AwardedXp = 0 - WHERE AwardedXp > 0; - """); - } - - public static void MigrateSar(MigrationBuilder migrationBuilder) - { - if (migrationBuilder.IsNpgsql()) - return; - - migrationBuilder.Sql(""" - INSERT INTO GroupName (Number, GuildConfigId) - SELECT DISTINCT "Group", GC.Id - FROM SelfAssignableRoles as SAR - INNER JOIN GuildConfigs as GC - ON SAR.GuildId = GC.GuildId - WHERE SAR.GuildId not in (SELECT GuildConfigs.GuildId from GroupName LEFT JOIN GuildConfigs ON GroupName.GuildConfigId = GuildConfigs.Id); - - INSERT INTO SarGroup (Id, GroupNumber, Name, IsExclusive, GuildId) - SELECT GN.Id, GN.Number, GN.Name, GC.ExclusiveSelfAssignedRoles, GC.GuildId - FROM GroupName as GN - INNER JOIN GuildConfigs as GC ON GN.GuildConfigId = GC.Id; - - INSERT INTO Sar (GuildId, RoleId, SarGroupId, LevelReq) - SELECT SAR.GuildId, SAR.RoleId, (SELECT Id FROM SarGroup WHERE SG.Number = SarGroup.GroupNumber AND SG.GuildId = SarGroup.GuildId), MIN(SAR.LevelRequirement) - FROM SelfAssignableRoles as SAR - INNER JOIN (SELECT GuildId, gn.Number FROM GroupName as gn - INNER JOIN GuildConfigs as gc ON gn.GuildConfigId =gc.Id - ) as SG - ON SG.GuildId = SAR.GuildId - WHERE SG.Number IN (SELECT GroupNumber FROM SarGroup WHERE Sar.GuildId = SarGroup.GuildId) - GROUP BY SAR.GuildId, SAR.RoleId; - - INSERT INTO SarAutoDelete (GuildId, IsEnabled) - SELECT GuildId, AutoDeleteSelfAssignedRoleMessages FROM GuildConfigs WHERE AutoDeleteSelfAssignedRoleMessages = TRUE; - """); - } - - public static void UpdateUsernames(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("UPDATE DiscordUser SET Username = '??' || Username WHERE Discriminator = '????';"); - } - - public static void MigrateRero(MigrationBuilder migrationBuilder) - { - if (migrationBuilder.IsSqlite()) - { - migrationBuilder.Sql( - @"insert or ignore into reactionroles(guildid, channelid, messageid, emote, roleid, 'group', levelreq, dateadded) -select guildid, channelid, messageid, emotename, roleid, exclusive, 0, reactionrolemessage.dateadded -from reactionrole -left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid -left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;"); - } - else if (migrationBuilder.IsNpgsql()) - { - migrationBuilder.Sql( - @"insert into reactionroles(guildid, channelid, messageid, emote, roleid, ""group"", levelreq, dateadded) - select guildid, channelid, messageid, emotename, roleid, exclusive::int, 0, reactionrolemessage.dateadded - from reactionrole - left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid - left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id - ON CONFLICT DO NOTHING;"); - } - else - { - throw new NotSupportedException("This database provider doesn't have an implementation for MigrateRero"); - } - } - - public static void GuildConfigCleanup(MigrationBuilder builder) - { - builder.Sql($""" - DELETE FROM "DelMsgOnCmdChannel" WHERE "GuildConfigId" is NULL; - DELETE FROM "WarningPunishment" WHERE "GuildConfigId" NOT IN (SELECT "Id" from "GuildConfigs"); - DELETE FROM "StreamRoleBlacklistedUser" WHERE "StreamRoleSettingsId" is NULL; - DELETE FROM "Permissions" WHERE "GuildConfigId" NOT IN (SELECT "Id" from "GuildConfigs"); - """); - } - - public static void GreetSettingsCopy(MigrationBuilder builder) - { - builder.Sql(""" - INSERT INTO GreetSettings (GuildId, GreetType, MessageText, IsEnabled, ChannelId, AutoDeleteTimer) - SELECT GuildId, 0, ChannelGreetMessageText, SendChannelGreetMessage, GreetMessageChannelId, AutoDeleteGreetMessagesTimer - FROM GuildConfigs - WHERE SendChannelGreetMessage = TRUE; - - INSERT INTO GreetSettings (GuildId, GreetType, MessageText, IsEnabled, ChannelId, AutoDeleteTimer) - SELECT GuildId, 1, DmGreetMessageText, SendDmGreetMessage, GreetMessageChannelId, 0 - FROM GuildConfigs - WHERE SendDmGreetMessage = TRUE; - - INSERT INTO GreetSettings (GuildId, GreetType, MessageText, IsEnabled, ChannelId, AutoDeleteTimer) - SELECT GuildId, 2, ChannelByeMessageText, SendChannelByeMessage, ByeMessageChannelId, AutoDeleteByeMessagesTimer - FROM GuildConfigs - WHERE SendChannelByeMessage = TRUE; - - INSERT INTO GreetSettings (GuildId, GreetType, MessageText, IsEnabled, ChannelId, AutoDeleteTimer) - SELECT GuildId, 3, BoostMessage, SendBoostMessage, BoostMessageChannelId, BoostMessageDeleteAfter - FROM GuildConfigs - WHERE SendBoostMessage = TRUE; - """); - } - - public static void AddGuildIdsToWarningPunishment(MigrationBuilder builder) - { - builder.Sql(""" - DELETE FROM WarningPunishment WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); - UPDATE WarningPunishment - SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE Id = GuildConfigId); - - DELETE FROM WarningPunishment as wp - WHERE (wp.Count, wp.GuildConfigId) in ( - SELECT wp2.Count, wp2.GuildConfigId FROM WarningPunishment as wp2 - GROUP BY wp2.Count, wp2.GuildConfigId - HAVING COUNT(id) > 1 - ); - """); - } -} diff --git a/src/EllieBot/Migrations/PostgreSql/20250126062816_cleanup.sql b/src/EllieBot/Migrations/PostgreSql/20250126062816_cleanup.sql new file mode 100644 index 0000000..2030f3a --- /dev/null +++ b/src/EllieBot/Migrations/PostgreSql/20250126062816_cleanup.sql @@ -0,0 +1,333 @@ +START TRANSACTION; + +ALTER TABLE antialtsetting DROP CONSTRAINT fk_antialtsetting_guildconfigs_guildconfigid; + +ALTER TABLE antiraidsetting DROP CONSTRAINT fk_antiraidsetting_guildconfigs_guildconfigid; + +ALTER TABLE antispamsetting DROP CONSTRAINT fk_antispamsetting_guildconfigs_guildconfigid; + +ALTER TABLE commandalias DROP CONSTRAINT fk_commandalias_guildconfigs_guildconfigid; + +ALTER TABLE commandcooldown DROP CONSTRAINT fk_commandcooldown_guildconfigs_guildconfigid; + +ALTER TABLE delmsgoncmdchannel DROP CONSTRAINT fk_delmsgoncmdchannel_guildconfigs_guildconfigid; + +ALTER TABLE excludeditem DROP CONSTRAINT fk_excludeditem_xpsettings_xpsettingsid; + +ALTER TABLE feedsub DROP CONSTRAINT fk_feedsub_guildconfigs_guildconfigid; + +ALTER TABLE filterchannelid DROP CONSTRAINT fk_filterchannelid_guildconfigs_guildconfigid; + +ALTER TABLE filteredword DROP CONSTRAINT fk_filteredword_guildconfigs_guildconfigid; + +ALTER TABLE filterlinkschannelid DROP CONSTRAINT fk_filterlinkschannelid_guildconfigs_guildconfigid; + +ALTER TABLE filterwordschannelid DROP CONSTRAINT fk_filterwordschannelid_guildconfigs_guildconfigid; + +ALTER TABLE followedstream DROP CONSTRAINT fk_followedstream_guildconfigs_guildconfigid; + +ALTER TABLE gcchannelid DROP CONSTRAINT fk_gcchannelid_guildconfigs_guildconfigid; + +ALTER TABLE muteduserid DROP CONSTRAINT fk_muteduserid_guildconfigs_guildconfigid; + +ALTER TABLE permissions DROP CONSTRAINT fk_permissions_guildconfigs_guildconfigid; + +ALTER TABLE shopentry DROP CONSTRAINT fk_shopentry_guildconfigs_guildconfigid; + +ALTER TABLE slowmodeignoredrole DROP CONSTRAINT fk_slowmodeignoredrole_guildconfigs_guildconfigid; + +ALTER TABLE slowmodeignoreduser DROP CONSTRAINT fk_slowmodeignoreduser_guildconfigs_guildconfigid; + +ALTER TABLE streamrolesettings DROP CONSTRAINT fk_streamrolesettings_guildconfigs_guildconfigid; + +ALTER TABLE unbantimer DROP CONSTRAINT fk_unbantimer_guildconfigs_guildconfigid; + +ALTER TABLE unmutetimer DROP CONSTRAINT fk_unmutetimer_guildconfigs_guildconfigid; + +ALTER TABLE unroletimer DROP CONSTRAINT fk_unroletimer_guildconfigs_guildconfigid; + +ALTER TABLE vcroleinfo DROP CONSTRAINT fk_vcroleinfo_guildconfigs_guildconfigid; + +ALTER TABLE xpsettings DROP CONSTRAINT fk_xpsettings_guildconfigs_guildconfigid; + +DROP INDEX ix_xpsettings_guildconfigid; + +DROP INDEX ix_vcroleinfo_guildconfigid; + +DROP INDEX ix_unroletimer_guildconfigid; + +DROP INDEX ix_unmutetimer_guildconfigid; + +DROP INDEX ix_unbantimer_guildconfigid; + +DROP INDEX ix_streamrolesettings_guildconfigid; + +DROP INDEX ix_slowmodeignoreduser_guildconfigid; + +DROP INDEX ix_slowmodeignoredrole_guildconfigid; + +DROP INDEX ix_shopentry_guildconfigid; + +DROP INDEX ix_muteduserid_guildconfigid; + +DROP INDEX ix_gcchannelid_guildconfigid; + +DROP INDEX ix_followedstream_guildconfigid; + +ALTER TABLE feedsub DROP CONSTRAINT ak_feedsub_guildconfigid_url; + +DROP INDEX ix_delmsgoncmdchannel_guildconfigid; + +DROP INDEX ix_commandcooldown_guildconfigid; + +DROP INDEX ix_commandalias_guildconfigid; + +DROP INDEX ix_antispamsetting_guildconfigid; + +DROP INDEX ix_antiraidsetting_guildconfigid; + +DROP INDEX ix_antialtsetting_guildconfigid; + +ALTER TABLE filterwordschannelid RENAME COLUMN guildconfigid TO guildfilterconfigid; + +ALTER INDEX ix_filterwordschannelid_guildconfigid RENAME TO ix_filterwordschannelid_guildfilterconfigid; + +ALTER TABLE filterlinkschannelid RENAME COLUMN guildconfigid TO guildfilterconfigid; + +ALTER INDEX ix_filterlinkschannelid_guildconfigid RENAME TO ix_filterlinkschannelid_guildfilterconfigid; + +ALTER TABLE filteredword RENAME COLUMN guildconfigid TO guildfilterconfigid; + +ALTER INDEX ix_filteredword_guildconfigid RENAME TO ix_filteredword_guildfilterconfigid; + +ALTER TABLE filterchannelid RENAME COLUMN guildconfigid TO guildfilterconfigid; + +ALTER INDEX ix_filterchannelid_guildconfigid RENAME TO ix_filterchannelid_guildfilterconfigid; + +ALTER TABLE xpsettings ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE vcroleinfo ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE unroletimer ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE unmutetimer ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE unbantimer ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE streamrolesettings ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE slowmodeignoreduser ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE slowmodeignoredrole ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE shopentry ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE permissions ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE muteduserid ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE gcchannelid ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE feedsub ALTER COLUMN url DROP NOT NULL; + +ALTER TABLE feedsub ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE delmsgoncmdchannel ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE commandcooldown ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE commandalias ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE antispamsetting ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE antiraidsetting ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +ALTER TABLE antialtsetting ADD guildid numeric(20,0) NOT NULL DEFAULT 0.0; + +CREATE TABLE guildfilterconfig ( + id integer GENERATED BY DEFAULT AS IDENTITY, + guildid numeric(20,0) NOT NULL, + filterinvites boolean NOT NULL, + filterlinks boolean NOT NULL, + filterwords boolean NOT NULL, + CONSTRAINT pk_guildfilterconfig PRIMARY KEY (id) +); + +insert into guildfilterconfig (Id, GuildId, FilterLinks, FilterInvites, FilterWords) +select Id, GuildId, FilterLinks, FilterInvites, FilterWords +from guildconfigs; + +DELETE FROM XPSettings WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE XpSettings +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = XpSettings.GuildConfigId); + +DELETE FROM StreamRoleSettings WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE StreamRoleSettings +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = StreamRoleSettings.GuildConfigId); + +DELETE FROM FeedSub WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE FeedSub +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = FeedSub.GuildConfigId); + +DELETE FROM DelMsgOnCmdChannel WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE DelMsgOnCmdChannel +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = DelMsgOnCmdChannel.GuildConfigId); + +DELETE FROM AntiSpamSetting WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE AntiSpamSetting +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = AntiSpamSetting.GuildConfigId); + +DELETE FROM AntiRaidSetting WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE AntiRaidSetting +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = AntiRaidSetting.GuildConfigId); + +DELETE FROM AntiAltSetting WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE AntiAltSetting +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = AntiAltSetting.GuildConfigId); + +DELETE FROM VcRoleInfo WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE VcRoleInfo +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = VcRoleInfo.GuildConfigId); + +DELETE FROM UnroleTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE UnroleTimer +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = UnroleTimer.GuildConfigId); + +DELETE FROM UnmuteTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE UnmuteTimer +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = UnmuteTimer.GuildConfigId); + +DELETE FROM UnbanTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE UnbanTimer +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = UnbanTimer.GuildConfigId); + +DELETE FROM SlowmodeIgnoredUser WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE SlowmodeIgnoredUser +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = SlowmodeIgnoredUser.GuildConfigId); + +DELETE FROM SlowmodeIgnoredRole WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE SlowmodeIgnoredRole +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = SlowmodeIgnoredRole.GuildConfigId); + +DELETE FROM ShopEntry WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE ShopEntry +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = ShopEntry.GuildConfigId); + +DELETE FROM Permissions WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE Permissions +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = Permissions.GuildConfigId); + +DELETE FROM MutedUserId WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE MutedUserId +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = MutedUserId.GuildConfigId); + +DELETE FROM GcChannelId WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE GcChannelId +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = GcChannelId.GuildConfigId); + +DELETE FROM CommandCooldown WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE CommandCooldown +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = CommandCooldown.GuildConfigId); + +DELETE FROM CommandAlias WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE CommandAlias +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = CommandAlias.GuildConfigId); + +ALTER TABLE vcroleinfo DROP COLUMN guildconfigid; + +ALTER TABLE unroletimer DROP COLUMN guildconfigid; + +ALTER TABLE unmutetimer DROP COLUMN guildconfigid; + +ALTER TABLE unbantimer DROP COLUMN guildconfigid; + +ALTER TABLE slowmodeignoreduser DROP COLUMN guildconfigid; + +ALTER TABLE slowmodeignoredrole DROP COLUMN guildconfigid; + +ALTER TABLE shopentry DROP COLUMN guildconfigid; + +ALTER TABLE muteduserid DROP COLUMN guildconfigid; + +ALTER TABLE guildconfigs DROP COLUMN autodeleteselfassignedrolemessages; + +ALTER TABLE guildconfigs DROP COLUMN exclusiveselfassignedroles; + +ALTER TABLE guildconfigs DROP COLUMN filterinvites; + +ALTER TABLE guildconfigs DROP COLUMN filterlinks; + +ALTER TABLE guildconfigs DROP COLUMN filterwords; + +ALTER TABLE gcchannelid DROP COLUMN guildconfigid; + +ALTER TABLE followedstream DROP COLUMN dateadded; + +ALTER TABLE followedstream DROP COLUMN guildconfigid; + +ALTER TABLE filterchannelid DROP COLUMN dateadded; + +ALTER TABLE commandcooldown DROP COLUMN guildconfigid; + +ALTER TABLE commandalias DROP COLUMN guildconfigid; + +CREATE UNIQUE INDEX ix_xpsettings_guildid ON xpsettings (guildid); + +CREATE UNIQUE INDEX ix_xpcurrencyreward_level_xpsettingsid ON xpcurrencyreward (level, xpsettingsid); + +CREATE UNIQUE INDEX ix_vcroleinfo_guildid_voicechannelid ON vcroleinfo (guildid, voicechannelid); + +CREATE UNIQUE INDEX ix_unroletimer_guildid_userid ON unroletimer (guildid, userid); + +CREATE UNIQUE INDEX ix_unmutetimer_guildid_userid ON unmutetimer (guildid, userid); + +CREATE UNIQUE INDEX ix_unbantimer_guildid_userid ON unbantimer (guildid, userid); + +CREATE UNIQUE INDEX ix_streamrolesettings_guildid ON streamrolesettings (guildid); + +CREATE UNIQUE INDEX ix_slowmodeignoreduser_guildid_userid ON slowmodeignoreduser (guildid, userid); + +CREATE UNIQUE INDEX ix_slowmodeignoredrole_guildid_roleid ON slowmodeignoredrole (guildid, roleid); + +CREATE UNIQUE INDEX ix_shopentry_guildid_index ON shopentry (guildid, index); + +CREATE INDEX ix_permissions_guildid ON permissions (guildid); + +CREATE UNIQUE INDEX ix_muteduserid_guildid_userid ON muteduserid (guildid, userid); + +CREATE UNIQUE INDEX ix_gcchannelid_guildid_channelid ON gcchannelid (guildid, channelid); + +CREATE INDEX ix_followedstream_guildid_username_type ON followedstream (guildid, username, type); + +CREATE UNIQUE INDEX ix_feedsub_guildid_url ON feedsub (guildid, url); + +CREATE UNIQUE INDEX ix_delmsgoncmdchannel_guildid_channelid ON delmsgoncmdchannel (guildid, channelid); + +CREATE UNIQUE INDEX ix_commandcooldown_guildid_commandname ON commandcooldown (guildid, commandname); + +CREATE INDEX ix_commandalias_guildid ON commandalias (guildid); + +CREATE UNIQUE INDEX ix_antispamsetting_guildid ON antispamsetting (guildid); + +CREATE UNIQUE INDEX ix_antiraidsetting_guildid ON antiraidsetting (guildid); + +CREATE UNIQUE INDEX ix_antialtsetting_guildid ON antialtsetting (guildid); + +CREATE INDEX ix_guildfilterconfig_guildid ON guildfilterconfig (guildid); + +ALTER TABLE excludeditem ADD CONSTRAINT fk_excludeditem_xpsettings_xpsettingsid FOREIGN KEY (xpsettingsid) REFERENCES xpsettings (id); + +ALTER TABLE filterchannelid ADD CONSTRAINT fk_filterchannelid_guildfilterconfig_guildfilterconfigid FOREIGN KEY (guildfilterconfigid) REFERENCES guildfilterconfig (id); + +ALTER TABLE filteredword ADD CONSTRAINT fk_filteredword_guildfilterconfig_guildfilterconfigid FOREIGN KEY (guildfilterconfigid) REFERENCES guildfilterconfig (id); + +ALTER TABLE filterlinkschannelid ADD CONSTRAINT fk_filterlinkschannelid_guildfilterconfig_guildfilterconfigid FOREIGN KEY (guildfilterconfigid) REFERENCES guildfilterconfig (id); + +ALTER TABLE filterwordschannelid ADD CONSTRAINT fk_filterwordschannelid_guildfilterconfig_guildfilterconfigid FOREIGN KEY (guildfilterconfigid) REFERENCES guildfilterconfig (id); + +ALTER TABLE permissions ADD CONSTRAINT fk_permissions_guildconfigs_guildconfigid FOREIGN KEY (guildconfigid) REFERENCES guildconfigs (id); + +INSERT INTO "__EFMigrationsHistory" (migrationid, productversion) +VALUES ('20250126062816_cleanup', '8.0.8'); + +COMMIT; \ No newline at end of file diff --git a/src/EllieBot/Migrations/PostgreSql/20250124023345_init.Designer.cs b/src/EllieBot/Migrations/PostgreSql/20250127062816_init.Designer.cs similarity index 89% rename from src/EllieBot/Migrations/PostgreSql/20250124023345_init.Designer.cs rename to src/EllieBot/Migrations/PostgreSql/20250127062816_init.Designer.cs index 9c315f6..afb4add 100644 --- a/src/EllieBot/Migrations/PostgreSql/20250124023345_init.Designer.cs +++ b/src/EllieBot/Migrations/PostgreSql/20250127062816_init.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace EllieBot.Migrations.PostgreSql { [DbContext(typeof(PostgreSqlContext))] - [Migration("20250124023345_init")] + [Migration("20250127062816_init")] partial class init { /// <inheritdoc /> @@ -46,6 +46,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("integer") .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + b.Property<TimeSpan>("MinAge") .HasColumnType("interval") .HasColumnName("minage"); @@ -57,9 +61,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_antialtsetting"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique() - .HasDatabaseName("ix_antialtsetting_guildconfigid"); + .HasDatabaseName("ix_antialtsetting_guildid"); b.ToTable("antialtsetting", (string)null); }); @@ -85,6 +89,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("integer") .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + b.Property<int>("PunishDuration") .HasColumnType("integer") .HasColumnName("punishduration"); @@ -100,9 +108,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_antiraidsetting"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique() - .HasDatabaseName("ix_antiraidsetting_guildconfigid"); + .HasDatabaseName("ix_antiraidsetting_guildid"); b.ToTable("antiraidsetting", (string)null); }); @@ -158,6 +166,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("integer") .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + b.Property<int>("MessageThreshold") .HasColumnType("integer") .HasColumnName("messagethreshold"); @@ -173,9 +185,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_antispamsetting"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique() - .HasDatabaseName("ix_antispamsetting_guildconfigid"); + .HasDatabaseName("ix_antispamsetting_guildid"); b.ToTable("antispamsetting", (string)null); }); @@ -616,9 +628,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<string>("Mapping") .HasColumnType("text") @@ -631,8 +643,8 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_commandalias"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_commandalias_guildconfigid"); + b.HasIndex("GuildId") + .HasDatabaseName("ix_commandalias_guildid"); b.ToTable("commandalias", (string)null); }); @@ -654,9 +666,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<int>("Seconds") .HasColumnType("integer") @@ -665,8 +677,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_commandcooldown"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_commandcooldown_guildconfigid"); + b.HasIndex("GuildId", "CommandName") + .IsUnique() + .HasDatabaseName("ix_commandcooldown_guildid_commandname"); b.ToTable("commandcooldown", (string)null); }); @@ -742,6 +755,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("integer") .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + b.Property<bool>("State") .HasColumnType("boolean") .HasColumnName("state"); @@ -749,8 +766,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_delmsgoncmdchannel"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_delmsgoncmdchannel_guildconfigid"); + b.HasIndex("GuildId", "ChannelId") + .IsUnique() + .HasDatabaseName("ix_delmsgoncmdchannel_guildid_channelid"); b.ToTable("delmsgoncmdchannel", (string)null); }); @@ -922,20 +940,24 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("integer") .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + b.Property<string>("Message") .HasColumnType("text") .HasColumnName("message"); b.Property<string>("Url") - .IsRequired() .HasColumnType("text") .HasColumnName("url"); b.HasKey("Id") .HasName("pk_feedsub"); - b.HasAlternateKey("GuildConfigId", "Url") - .HasName("ak_feedsub_guildconfigid_url"); + b.HasIndex("GuildId", "Url") + .IsUnique() + .HasDatabaseName("ix_feedsub_guildid_url"); b.ToTable("feedsub", (string)null); }); @@ -953,19 +975,15 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("numeric(20,0)") .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); - - b.Property<int?>("GuildConfigId") + b.Property<int?>("GuildFilterConfigId") .HasColumnType("integer") - .HasColumnName("guildconfigid"); + .HasColumnName("guildfilterconfigid"); b.HasKey("Id") .HasName("pk_filterchannelid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_filterchannelid_guildconfigid"); + b.HasIndex("GuildFilterConfigId") + .HasDatabaseName("ix_filterchannelid_guildfilterconfigid"); b.ToTable("filterchannelid", (string)null); }); @@ -987,15 +1005,15 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") + b.Property<int?>("GuildFilterConfigId") .HasColumnType("integer") - .HasColumnName("guildconfigid"); + .HasColumnName("guildfilterconfigid"); b.HasKey("Id") .HasName("pk_filterlinkschannelid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_filterlinkschannelid_guildconfigid"); + b.HasIndex("GuildFilterConfigId") + .HasDatabaseName("ix_filterlinkschannelid_guildfilterconfigid"); b.ToTable("filterlinkschannelid", (string)null); }); @@ -1017,15 +1035,15 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") + b.Property<int?>("GuildFilterConfigId") .HasColumnType("integer") - .HasColumnName("guildconfigid"); + .HasColumnName("guildfilterconfigid"); b.HasKey("Id") .HasName("pk_filterwordschannelid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_filterwordschannelid_guildconfigid"); + b.HasIndex("GuildFilterConfigId") + .HasDatabaseName("ix_filterwordschannelid_guildfilterconfigid"); b.ToTable("filterwordschannelid", (string)null); }); @@ -1043,9 +1061,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") + b.Property<int?>("GuildFilterConfigId") .HasColumnType("integer") - .HasColumnName("guildconfigid"); + .HasColumnName("guildfilterconfigid"); b.Property<string>("Word") .HasColumnType("text") @@ -1054,8 +1072,8 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_filteredword"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_filteredword_guildconfigid"); + b.HasIndex("GuildFilterConfigId") + .HasDatabaseName("ix_filteredword_guildfilterconfigid"); b.ToTable("filteredword", (string)null); }); @@ -1104,14 +1122,6 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("numeric(20,0)") .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); - - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); - b.Property<decimal>("GuildId") .HasColumnType("numeric(20,0)") .HasColumnName("guildid"); @@ -1131,8 +1141,8 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_followedstream"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_followedstream_guildconfigid"); + b.HasIndex("GuildId", "Username", "Type") + .HasDatabaseName("ix_followedstream_guildid_username_type"); b.ToTable("followedstream", (string)null); }); @@ -1154,15 +1164,16 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.HasKey("Id") .HasName("pk_gcchannelid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_gcchannelid_guildconfigid"); + b.HasIndex("GuildId", "ChannelId") + .IsUnique() + .HasDatabaseName("ix_gcchannelid_guildid_channelid"); b.ToTable("gcchannelid", (string)null); }); @@ -1319,10 +1330,6 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("text") .HasColumnName("autoassignroleids"); - b.Property<bool>("AutoDeleteSelfAssignedRoleMessages") - .HasColumnType("boolean") - .HasColumnName("autodeleteselfassignedrolemessages"); - b.Property<bool>("CleverbotEnabled") .HasColumnType("boolean") .HasColumnName("cleverbotenabled"); @@ -1343,22 +1350,6 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("boolean") .HasColumnName("disableglobalexpressions"); - b.Property<bool>("ExclusiveSelfAssignedRoles") - .HasColumnType("boolean") - .HasColumnName("exclusiveselfassignedroles"); - - b.Property<bool>("FilterInvites") - .HasColumnType("boolean") - .HasColumnName("filterinvites"); - - b.Property<bool>("FilterLinks") - .HasColumnType("boolean") - .HasColumnName("filterlinks"); - - b.Property<bool>("FilterWords") - .HasColumnType("boolean") - .HasColumnName("filterwords"); - b.Property<decimal?>("GameVoiceChannel") .HasColumnType("numeric(20,0)") .HasColumnName("gamevoicechannel"); @@ -1430,6 +1421,40 @@ namespace EllieBot.Migrations.PostgreSql b.ToTable("guildconfigs", (string)null); }); + modelBuilder.Entity("EllieBot.Db.Models.GuildFilterConfig", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + + b.Property<bool>("FilterInvites") + .HasColumnType("boolean") + .HasColumnName("filterinvites"); + + b.Property<bool>("FilterLinks") + .HasColumnType("boolean") + .HasColumnName("filterlinks"); + + b.Property<bool>("FilterWords") + .HasColumnType("boolean") + .HasColumnName("filterwords"); + + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + + b.HasKey("Id") + .HasName("pk_guildfilterconfig"); + + b.HasIndex("GuildId") + .HasDatabaseName("ix_guildfilterconfig_guildid"); + + b.ToTable("guildfilterconfig", (string)null); + }); + modelBuilder.Entity("EllieBot.Db.Models.HoneypotChannel", b => { b.Property<decimal>("GuildId") @@ -1709,9 +1734,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<decimal>("UserId") .HasColumnType("numeric(20,0)") @@ -1720,8 +1745,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_muteduserid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_muteduserid_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_muteduserid_guildid_userid"); b.ToTable("muteduserid", (string)null); }); @@ -1906,6 +1932,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("integer") .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + b.Property<int>("Index") .HasColumnType("integer") .HasColumnName("index"); @@ -1940,6 +1970,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasIndex("GuildConfigId") .HasDatabaseName("ix_permissions_guildconfigid"); + b.HasIndex("GuildId") + .HasDatabaseName("ix_permissions_guildid"); + b.ToTable("permissions", (string)null); }); @@ -2429,9 +2462,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<int>("Index") .HasColumnType("integer") @@ -2464,8 +2497,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_shopentry"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_shopentry_guildconfigid"); + b.HasIndex("GuildId", "Index") + .IsUnique() + .HasDatabaseName("ix_shopentry_guildid_index"); b.ToTable("shopentry", (string)null); }); @@ -2513,9 +2547,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<decimal>("RoleId") .HasColumnType("numeric(20,0)") @@ -2524,8 +2558,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_slowmodeignoredrole"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_slowmodeignoredrole_guildconfigid"); + b.HasIndex("GuildId", "RoleId") + .IsUnique() + .HasDatabaseName("ix_slowmodeignoredrole_guildid_roleid"); b.ToTable("slowmodeignoredrole", (string)null); }); @@ -2543,9 +2578,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<decimal>("UserId") .HasColumnType("numeric(20,0)") @@ -2554,8 +2589,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_slowmodeignoreduser"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_slowmodeignoreduser_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_slowmodeignoreduser_guildid_userid"); b.ToTable("slowmodeignoreduser", (string)null); }); @@ -2693,6 +2729,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("integer") .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + b.Property<string>("Keyword") .HasColumnType("text") .HasColumnName("keyword"); @@ -2700,9 +2740,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_streamrolesettings"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique() - .HasDatabaseName("ix_streamrolesettings_guildconfigid"); + .HasDatabaseName("ix_streamrolesettings_guildid"); b.ToTable("streamrolesettings", (string)null); }); @@ -2836,9 +2876,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<DateTime>("UnbanAt") .HasColumnType("timestamp without time zone") @@ -2851,8 +2891,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_unbantimer"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_unbantimer_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_unbantimer_guildid_userid"); b.ToTable("unbantimer", (string)null); }); @@ -2870,9 +2911,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<DateTime>("UnmuteAt") .HasColumnType("timestamp without time zone") @@ -2885,8 +2926,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_unmutetimer"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_unmutetimer_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_unmutetimer_guildid_userid"); b.ToTable("unmutetimer", (string)null); }); @@ -2904,9 +2946,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<decimal>("RoleId") .HasColumnType("numeric(20,0)") @@ -2923,8 +2965,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_unroletimer"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_unroletimer_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_unroletimer_guildid_userid"); b.ToTable("unroletimer", (string)null); }); @@ -2986,9 +3029,9 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); b.Property<decimal>("RoleId") .HasColumnType("numeric(20,0)") @@ -3001,8 +3044,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_vcroleinfo"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_vcroleinfo_guildconfigid"); + b.HasIndex("GuildId", "VoiceChannelId") + .IsUnique() + .HasDatabaseName("ix_vcroleinfo_guildid_voicechannelid"); b.ToTable("vcroleinfo", (string)null); }); @@ -3264,6 +3308,10 @@ namespace EllieBot.Migrations.PostgreSql b.HasIndex("XpSettingsId") .HasDatabaseName("ix_xpcurrencyreward_xpsettingsid"); + b.HasIndex("Level", "XpSettingsId") + .IsUnique() + .HasDatabaseName("ix_xpcurrencyreward_level_xpsettingsid"); + b.ToTable("xpcurrencyreward", (string)null); }); @@ -3323,6 +3371,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("integer") .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + b.Property<bool>("ServerExcluded") .HasColumnType("boolean") .HasColumnName("serverexcluded"); @@ -3330,9 +3382,9 @@ namespace EllieBot.Migrations.PostgreSql b.HasKey("Id") .HasName("pk_xpsettings"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique() - .HasDatabaseName("ix_xpsettings_guildconfigid"); + .HasDatabaseName("ix_xpsettings_guildid"); b.ToTable("xpsettings", (string)null); }); @@ -3556,26 +3608,6 @@ namespace EllieBot.Migrations.PostgreSql b.ToTable("userbetstats", (string)null); }); - modelBuilder.Entity("EllieBot.Db.Models.AntiAltSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiAltSetting") - .HasForeignKey("EllieBot.Db.Models.AntiAltSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_antialtsetting_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.AntiRaidSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiRaidSetting") - .HasForeignKey("EllieBot.Db.Models.AntiRaidSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_antiraidsetting_guildconfigs_guildconfigid"); - }); - modelBuilder.Entity("EllieBot.Db.Models.AntiSpamIgnore", b => { b.HasOne("EllieBot.Db.Models.AntiSpamSetting", null) @@ -3585,16 +3617,6 @@ namespace EllieBot.Migrations.PostgreSql .HasConstraintName("fk_antispamignore_antispamsetting_antispamsettingid"); }); - modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiSpamSetting") - .HasForeignKey("EllieBot.Db.Models.AntiSpamSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_antispamsetting_guildconfigs_guildconfigid"); - }); - modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateUser", b => { b.HasOne("EllieBot.Db.Models.AutoTranslateChannel", "Channel") @@ -3660,34 +3682,6 @@ namespace EllieBot.Migrations.PostgreSql b.Navigation("Owner"); }); - modelBuilder.Entity("EllieBot.Db.Models.CommandAlias", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("CommandAliases") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_commandalias_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.CommandCooldown", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("CommandCooldowns") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_commandcooldown_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.DelMsgOnCmdChannel", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("DelMsgOnCmdChannels") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_delmsgoncmdchannel_guildconfigs_guildconfigid"); - }); - modelBuilder.Entity("EllieBot.Db.Models.DiscordUser", b => { b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") @@ -3701,81 +3695,42 @@ namespace EllieBot.Migrations.PostgreSql modelBuilder.Entity("EllieBot.Db.Models.ExcludedItem", b => { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") + b.HasOne("EllieBot.Db.Models.XpSettings", null) .WithMany("ExclusionList") .HasForeignKey("XpSettingsId") - .OnDelete(DeleteBehavior.Cascade) .HasConstraintName("fk_excludeditem_xpsettings_xpsettingsid"); - - b.Navigation("XpSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.FeedSub", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithMany("FeedSubs") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_feedsub_guildconfigs_guildconfigid"); - - b.Navigation("GuildConfig"); }); modelBuilder.Entity("EllieBot.Db.Models.FilterChannelId", b => { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) .WithMany("FilterInvitesChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_filterchannelid_guildconfigs_guildconfigid"); + .HasForeignKey("GuildFilterConfigId") + .HasConstraintName("fk_filterchannelid_guildfilterconfig_guildfilterconfigid"); }); modelBuilder.Entity("EllieBot.Db.Models.FilterLinksChannelId", b => { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) .WithMany("FilterLinksChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_filterlinkschannelid_guildconfigs_guildconfigid"); + .HasForeignKey("GuildFilterConfigId") + .HasConstraintName("fk_filterlinkschannelid_guildfilterconfig_guildfilterconfigid"); }); modelBuilder.Entity("EllieBot.Db.Models.FilterWordsChannelId", b => { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) .WithMany("FilterWordsChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_filterwordschannelid_guildconfigs_guildconfigid"); + .HasForeignKey("GuildFilterConfigId") + .HasConstraintName("fk_filterwordschannelid_guildfilterconfig_guildfilterconfigid"); }); modelBuilder.Entity("EllieBot.Db.Models.FilteredWord", b => { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) .WithMany("FilteredWords") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_filteredword_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.FollowedStream", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FollowedStreams") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_followedstream_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.GCChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithMany("GenerateCurrencyChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_gcchannelid_guildconfigs_guildconfigid"); - - b.Navigation("GuildConfig"); + .HasForeignKey("GuildFilterConfigId") + .HasConstraintName("fk_filteredword_guildfilterconfig_guildfilterconfigid"); }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayUser", b => @@ -3800,21 +3755,11 @@ namespace EllieBot.Migrations.PostgreSql b.Navigation("LogSetting"); }); - modelBuilder.Entity("EllieBot.Db.Models.MutedUserId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("MutedUsers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_muteduserid_guildconfigs_guildconfigid"); - }); - modelBuilder.Entity("EllieBot.Db.Models.Permissionv2", b => { b.HasOne("EllieBot.Db.Models.GuildConfig", null) .WithMany("Permissions") .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) .HasConstraintName("fk_permissions_guildconfigs_guildconfigid"); }); @@ -3837,15 +3782,6 @@ namespace EllieBot.Migrations.PostgreSql .HasConstraintName("fk_sar_sargroup_sargroupid"); }); - modelBuilder.Entity("EllieBot.Db.Models.ShopEntry", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("ShopEntries") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_shopentry_guildconfigs_guildconfigid"); - }); - modelBuilder.Entity("EllieBot.Db.Models.ShopEntryItem", b => { b.HasOne("EllieBot.Db.Models.ShopEntry", null) @@ -3855,24 +3791,6 @@ namespace EllieBot.Migrations.PostgreSql .HasConstraintName("fk_shopentryitem_shopentry_shopentryid"); }); - modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredRole", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("SlowmodeIgnoredRoles") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_slowmodeignoredrole_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredUser", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("SlowmodeIgnoredUsers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_slowmodeignoreduser_guildconfigs_guildconfigid"); - }); - modelBuilder.Entity("EllieBot.Db.Models.StreamRoleBlacklistedUser", b => { b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") @@ -3885,18 +3803,6 @@ namespace EllieBot.Migrations.PostgreSql b.Navigation("StreamRoleSettings"); }); - modelBuilder.Entity("EllieBot.Db.Models.StreamRoleSettings", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithOne("StreamRole") - .HasForeignKey("EllieBot.Db.Models.StreamRoleSettings", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_streamrolesettings_guildconfigs_guildconfigid"); - - b.Navigation("GuildConfig"); - }); - modelBuilder.Entity("EllieBot.Db.Models.StreamRoleWhitelistedUser", b => { b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") @@ -3918,42 +3824,6 @@ namespace EllieBot.Migrations.PostgreSql .HasConstraintName("fk_todos_todosarchive_archiveid"); }); - modelBuilder.Entity("EllieBot.Db.Models.UnbanTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnbanTimer") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_unbantimer_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnmuteTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnmuteTimers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_unmutetimer_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnroleTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnroleTimer") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_unroletimer_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.VcRoleInfo", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("VcRoleInfos") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_vcroleinfo_guildconfigs_guildconfigid"); - }); - modelBuilder.Entity("EllieBot.Db.Models.WaifuInfo", b => { b.HasOne("EllieBot.Db.Models.DiscordUser", "Affinity") @@ -4018,38 +3888,22 @@ namespace EllieBot.Migrations.PostgreSql modelBuilder.Entity("EllieBot.Db.Models.XpCurrencyReward", b => { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") + b.HasOne("EllieBot.Db.Models.XpSettings", null) .WithMany("CurrencyRewards") .HasForeignKey("XpSettingsId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("fk_xpcurrencyreward_xpsettings_xpsettingsid"); - - b.Navigation("XpSettings"); }); modelBuilder.Entity("EllieBot.Db.Models.XpRoleReward", b => { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") + b.HasOne("EllieBot.Db.Models.XpSettings", null) .WithMany("RoleRewards") .HasForeignKey("XpSettingsId") .OnDelete(DeleteBehavior.Cascade) .IsRequired() .HasConstraintName("fk_xprolereward_xpsettings_xpsettingsid"); - - b.Navigation("XpSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.XpSettings", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithOne("XpSettings") - .HasForeignKey("EllieBot.Db.Models.XpSettings", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_xpsettings_guildconfigs_guildconfigid"); - - b.Navigation("GuildConfig"); }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => @@ -4083,20 +3937,11 @@ namespace EllieBot.Migrations.PostgreSql modelBuilder.Entity("EllieBot.Db.Models.GuildConfig", b => { - b.Navigation("AntiAltSetting"); - - b.Navigation("AntiRaidSetting"); - - b.Navigation("AntiSpamSetting"); - - b.Navigation("CommandAliases"); - - b.Navigation("CommandCooldowns"); - - b.Navigation("DelMsgOnCmdChannels"); - - b.Navigation("FeedSubs"); + b.Navigation("Permissions"); + }); + modelBuilder.Entity("EllieBot.Db.Models.GuildFilterConfig", b => + { b.Navigation("FilterInvitesChannelIds"); b.Navigation("FilterLinksChannelIds"); @@ -4104,32 +3949,6 @@ namespace EllieBot.Migrations.PostgreSql b.Navigation("FilterWordsChannelIds"); b.Navigation("FilteredWords"); - - b.Navigation("FollowedStreams"); - - b.Navigation("GenerateCurrencyChannelIds"); - - b.Navigation("MutedUsers"); - - b.Navigation("Permissions"); - - b.Navigation("ShopEntries"); - - b.Navigation("SlowmodeIgnoredRoles"); - - b.Navigation("SlowmodeIgnoredUsers"); - - b.Navigation("StreamRole"); - - b.Navigation("UnbanTimer"); - - b.Navigation("UnmuteTimers"); - - b.Navigation("UnroleTimer"); - - b.Navigation("VcRoleInfos"); - - b.Navigation("XpSettings"); }); modelBuilder.Entity("EllieBot.Db.Models.LogSetting", b => diff --git a/src/EllieBot/Migrations/PostgreSql/20250124023345_init.cs b/src/EllieBot/Migrations/PostgreSql/20250127062816_init.cs similarity index 90% rename from src/EllieBot/Migrations/PostgreSql/20250124023345_init.cs rename to src/EllieBot/Migrations/PostgreSql/20250127062816_init.cs index 2001dfe..0ad8347 100644 --- a/src/EllieBot/Migrations/PostgreSql/20250124023345_init.cs +++ b/src/EllieBot/Migrations/PostgreSql/20250127062816_init.cs @@ -12,6 +12,62 @@ namespace EllieBot.Migrations.PostgreSql /// <inheritdoc /> protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "antialtsetting", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + minage = table.Column<TimeSpan>(type: "interval", nullable: false), + action = table.Column<int>(type: "integer", nullable: false), + actiondurationminutes = table.Column<int>(type: "integer", nullable: false), + roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_antialtsetting", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "antiraidsetting", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + userthreshold = table.Column<int>(type: "integer", nullable: false), + seconds = table.Column<int>(type: "integer", nullable: false), + action = table.Column<int>(type: "integer", nullable: false), + punishduration = table.Column<int>(type: "integer", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_antiraidsetting", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "antispamsetting", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + action = table.Column<int>(type: "integer", nullable: false), + messagethreshold = table.Column<int>(type: "integer", nullable: false), + mutetime = table.Column<int>(type: "integer", nullable: false), + roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: true), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_antispamsetting", x => x.id); + }); + migrationBuilder.CreateTable( name: "autocommands", columns: table => new @@ -132,6 +188,38 @@ namespace EllieBot.Migrations.PostgreSql table.UniqueConstraint("ak_buttonrole_roleid_messageid", x => new { x.roleid, x.messageid }); }); + migrationBuilder.CreateTable( + name: "commandalias", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + trigger = table.Column<string>(type: "text", nullable: true), + mapping = table.Column<string>(type: "text", nullable: true), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_commandalias", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "commandcooldown", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + seconds = table.Column<int>(type: "integer", nullable: false), + commandname = table.Column<string>(type: "text", nullable: true), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_commandcooldown", x => x.id); + }); + migrationBuilder.CreateTable( name: "currencytransactions", columns: table => new @@ -151,6 +239,23 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_currencytransactions", x => x.id); }); + migrationBuilder.CreateTable( + name: "delmsgoncmdchannel", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + state = table.Column<bool>(type: "boolean", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_delmsgoncmdchannel", x => x.id); + }); + migrationBuilder.CreateTable( name: "discordpermoverrides", columns: table => new @@ -188,6 +293,24 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_expressions", x => x.id); }); + migrationBuilder.CreateTable( + name: "feedsub", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + url = table.Column<string>(type: "text", nullable: true), + message = table.Column<string>(type: "text", nullable: true), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_feedsub", x => x.id); + }); + migrationBuilder.CreateTable( name: "fishcatch", columns: table => new @@ -220,6 +343,23 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_flagtranslatechannel", x => x.id); }); + migrationBuilder.CreateTable( + name: "followedstream", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + username = table.Column<string>(type: "text", nullable: true), + type = table.Column<int>(type: "integer", nullable: false), + message = table.Column<string>(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_followedstream", x => x.id); + }); + migrationBuilder.CreateTable( name: "gamblingstats", columns: table => new @@ -236,6 +376,21 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_gamblingstats", x => x.id); }); + migrationBuilder.CreateTable( + name: "gcchannelid", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_gcchannelid", x => x.id); + }); + migrationBuilder.CreateTable( name: "giveawaymodel", columns: table => new @@ -297,17 +452,10 @@ namespace EllieBot.Migrations.PostgreSql prefix = table.Column<string>(type: "text", nullable: true), deletemessageoncommand = table.Column<bool>(type: "boolean", nullable: false), autoassignroleids = table.Column<string>(type: "text", nullable: true), - exclusiveselfassignedroles = table.Column<bool>(type: "boolean", nullable: false), - autodeleteselfassignedrolemessages = table.Column<bool>(type: "boolean", nullable: false), verbosepermissions = table.Column<bool>(type: "boolean", nullable: false), permissionrole = table.Column<string>(type: "text", nullable: true), - filterinvites = table.Column<bool>(type: "boolean", nullable: false), - filterlinks = table.Column<bool>(type: "boolean", nullable: false), - filterwords = table.Column<bool>(type: "boolean", nullable: false), muterolename = table.Column<string>(type: "text", nullable: true), cleverbotenabled = table.Column<bool>(type: "boolean", nullable: false), - locale = table.Column<string>(type: "text", nullable: true), - timezoneid = table.Column<string>(type: "text", nullable: true), warningsinitialized = table.Column<bool>(type: "boolean", nullable: false), gamevoicechannel = table.Column<decimal>(type: "numeric(20,0)", nullable: true), verboseerrors = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true), @@ -317,6 +465,8 @@ namespace EllieBot.Migrations.PostgreSql warnexpireaction = table.Column<int>(type: "integer", nullable: false), disableglobalexpressions = table.Column<bool>(type: "boolean", nullable: false), stickyroles = table.Column<bool>(type: "boolean", nullable: false), + timezoneid = table.Column<string>(type: "text", nullable: true), + locale = table.Column<string>(type: "text", nullable: true), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, constraints: table => @@ -324,6 +474,22 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_guildconfigs", x => x.id); }); + migrationBuilder.CreateTable( + name: "guildfilterconfig", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + filterinvites = table.Column<bool>(type: "boolean", nullable: false), + filterlinks = table.Column<bool>(type: "boolean", nullable: false), + filterwords = table.Column<bool>(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_guildfilterconfig", x => x.id); + }); + migrationBuilder.CreateTable( name: "honeypotchannels", columns: table => new @@ -419,6 +585,21 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_musicplaylists", x => x.id); }); + migrationBuilder.CreateTable( + name: "muteduserid", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_muteduserid", x => x.id); + }); + migrationBuilder.CreateTable( name: "ncpixel", columns: table => new @@ -642,6 +823,59 @@ namespace EllieBot.Migrations.PostgreSql table.UniqueConstraint("ak_sargroup_guildid_groupnumber", x => new { x.guildid, x.groupnumber }); }); + migrationBuilder.CreateTable( + name: "shopentry", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + index = table.Column<int>(type: "integer", nullable: false), + price = table.Column<int>(type: "integer", nullable: false), + name = table.Column<string>(type: "text", nullable: true), + authorid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + type = table.Column<int>(type: "integer", nullable: false), + rolename = table.Column<string>(type: "text", nullable: true), + roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + rolerequirement = table.Column<decimal>(type: "numeric(20,0)", nullable: true), + command = table.Column<string>(type: "text", nullable: true), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_shopentry", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "slowmodeignoredrole", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_slowmodeignoredrole", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "slowmodeignoreduser", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_slowmodeignoreduser", x => x.id); + }); + migrationBuilder.CreateTable( name: "stickyroles", columns: table => new @@ -675,6 +909,25 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_streamonlinemessages", x => x.id); }); + migrationBuilder.CreateTable( + name: "streamrolesettings", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + enabled = table.Column<bool>(type: "boolean", nullable: false), + addroleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + fromroleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + keyword = table.Column<string>(type: "text", nullable: true), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_streamrolesettings", x => x.id); + }); + migrationBuilder.CreateTable( name: "temprole", columns: table => new @@ -707,6 +960,55 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_todosarchive", x => x.id); }); + migrationBuilder.CreateTable( + name: "unbantimer", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + unbanat = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_unbantimer", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "unmutetimer", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + unmuteat = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_unmutetimer", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "unroletimer", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + unbanat = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_unroletimer", x => x.id); + }); + migrationBuilder.CreateTable( name: "userbetstats", columns: table => new @@ -757,6 +1059,22 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_userxpstats", x => x.id); }); + migrationBuilder.CreateTable( + name: "vcroleinfo", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + voicechannelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_vcroleinfo", x => x.id); + }); + migrationBuilder.CreateTable( name: "warningpunishment", columns: table => new @@ -796,6 +1114,22 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_warnings", x => x.id); }); + migrationBuilder.CreateTable( + name: "xpsettings", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + serverexcluded = table.Column<bool>(type: "boolean", nullable: false), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_xpsettings", x => x.id); + }); + migrationBuilder.CreateTable( name: "xpshopowneditem", columns: table => new @@ -813,6 +1147,27 @@ namespace EllieBot.Migrations.PostgreSql table.PrimaryKey("pk_xpshopowneditem", x => x.id); }); + migrationBuilder.CreateTable( + name: "antispamignore", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + antispamsettingid = table.Column<int>(type: "integer", nullable: true), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_antispamignore", x => x.id); + table.ForeignKey( + name: "fk_antispamignore_antispamsetting_antispamsettingid", + column: x => x.antispamsettingid, + principalTable: "antispamsetting", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "autotranslateusers", columns: table => new @@ -858,325 +1213,13 @@ namespace EllieBot.Migrations.PostgreSql onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "antialtsetting", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: false), - minage = table.Column<TimeSpan>(type: "interval", nullable: false), - action = table.Column<int>(type: "integer", nullable: false), - actiondurationminutes = table.Column<int>(type: "integer", nullable: false), - roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_antialtsetting", x => x.id); - table.ForeignKey( - name: "fk_antialtsetting_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "antiraidsetting", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: false), - userthreshold = table.Column<int>(type: "integer", nullable: false), - seconds = table.Column<int>(type: "integer", nullable: false), - action = table.Column<int>(type: "integer", nullable: false), - punishduration = table.Column<int>(type: "integer", nullable: false), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_antiraidsetting", x => x.id); - table.ForeignKey( - name: "fk_antiraidsetting_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "antispamsetting", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: false), - action = table.Column<int>(type: "integer", nullable: false), - messagethreshold = table.Column<int>(type: "integer", nullable: false), - mutetime = table.Column<int>(type: "integer", nullable: false), - roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_antispamsetting", x => x.id); - table.ForeignKey( - name: "fk_antispamsetting_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "commandalias", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - trigger = table.Column<string>(type: "text", nullable: true), - mapping = table.Column<string>(type: "text", nullable: true), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_commandalias", x => x.id); - table.ForeignKey( - name: "fk_commandalias_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "commandcooldown", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - seconds = table.Column<int>(type: "integer", nullable: false), - commandname = table.Column<string>(type: "text", nullable: true), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_commandcooldown", x => x.id); - table.ForeignKey( - name: "fk_commandcooldown_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "delmsgoncmdchannel", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: false), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - state = table.Column<bool>(type: "boolean", nullable: false), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_delmsgoncmdchannel", x => x.id); - table.ForeignKey( - name: "fk_delmsgoncmdchannel_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "feedsub", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: false), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - url = table.Column<string>(type: "text", nullable: false), - message = table.Column<string>(type: "text", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_feedsub", x => x.id); - table.UniqueConstraint("ak_feedsub_guildconfigid_url", x => new { x.guildconfigid, x.url }); - table.ForeignKey( - name: "fk_feedsub_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "filterchannelid", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_filterchannelid", x => x.id); - table.ForeignKey( - name: "fk_filterchannelid_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "filteredword", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - word = table.Column<string>(type: "text", nullable: true), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_filteredword", x => x.id); - table.ForeignKey( - name: "fk_filteredword_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "filterlinkschannelid", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_filterlinkschannelid", x => x.id); - table.ForeignKey( - name: "fk_filterlinkschannelid_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "filterwordschannelid", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_filterwordschannelid", x => x.id); - table.ForeignKey( - name: "fk_filterwordschannelid_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "followedstream", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - username = table.Column<string>(type: "text", nullable: true), - type = table.Column<int>(type: "integer", nullable: false), - message = table.Column<string>(type: "text", nullable: true), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_followedstream", x => x.id); - table.ForeignKey( - name: "fk_followedstream_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "gcchannelid", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_gcchannelid", x => x.id); - table.ForeignKey( - name: "fk_gcchannelid_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "muteduserid", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_muteduserid", x => x.id); - table.ForeignKey( - name: "fk_muteduserid_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "permissions", columns: table => new { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: true), + guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), index = table.Column<int>(type: "integer", nullable: false), primarytarget = table.Column<int>(type: "integer", nullable: false), primarytargetid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), @@ -1184,6 +1227,7 @@ namespace EllieBot.Migrations.PostgreSql secondarytargetname = table.Column<string>(type: "text", nullable: true), iscustomcommand = table.Column<bool>(type: "boolean", nullable: false), state = table.Column<bool>(type: "boolean", nullable: false), + guildconfigid = table.Column<int>(type: "integer", nullable: true), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, constraints: table => @@ -1193,213 +1237,86 @@ namespace EllieBot.Migrations.PostgreSql name: "fk_permissions_guildconfigs_guildconfigid", column: x => x.guildconfigid, principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); + principalColumn: "id"); }); migrationBuilder.CreateTable( - name: "shopentry", + name: "filterchannelid", columns: table => new { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - index = table.Column<int>(type: "integer", nullable: false), - price = table.Column<int>(type: "integer", nullable: false), - name = table.Column<string>(type: "text", nullable: true), - authorid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - type = table.Column<int>(type: "integer", nullable: false), - rolename = table.Column<string>(type: "text", nullable: true), - roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - rolerequirement = table.Column<decimal>(type: "numeric(20,0)", nullable: true), - command = table.Column<string>(type: "text", nullable: true), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + guildfilterconfigid = table.Column<int>(type: "integer", nullable: true) }, constraints: table => { - table.PrimaryKey("pk_shopentry", x => x.id); + table.PrimaryKey("pk_filterchannelid", x => x.id); table.ForeignKey( - name: "fk_shopentry_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); + name: "fk_filterchannelid_guildfilterconfig_guildfilterconfigid", + column: x => x.guildfilterconfigid, + principalTable: "guildfilterconfig", + principalColumn: "id"); }); migrationBuilder.CreateTable( - name: "slowmodeignoredrole", + name: "filteredword", columns: table => new { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - guildconfigid = table.Column<int>(type: "integer", nullable: true), + word = table.Column<string>(type: "text", nullable: true), + guildfilterconfigid = table.Column<int>(type: "integer", nullable: true), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, constraints: table => { - table.PrimaryKey("pk_slowmodeignoredrole", x => x.id); + table.PrimaryKey("pk_filteredword", x => x.id); table.ForeignKey( - name: "fk_slowmodeignoredrole_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); + name: "fk_filteredword_guildfilterconfig_guildfilterconfigid", + column: x => x.guildfilterconfigid, + principalTable: "guildfilterconfig", + principalColumn: "id"); }); migrationBuilder.CreateTable( - name: "slowmodeignoreduser", + name: "filterlinkschannelid", columns: table => new { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - guildconfigid = table.Column<int>(type: "integer", nullable: true), + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + guildfilterconfigid = table.Column<int>(type: "integer", nullable: true), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, constraints: table => { - table.PrimaryKey("pk_slowmodeignoreduser", x => x.id); + table.PrimaryKey("pk_filterlinkschannelid", x => x.id); table.ForeignKey( - name: "fk_slowmodeignoreduser_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); + name: "fk_filterlinkschannelid_guildfilterconfig_guildfilterconfigid", + column: x => x.guildfilterconfigid, + principalTable: "guildfilterconfig", + principalColumn: "id"); }); migrationBuilder.CreateTable( - name: "streamrolesettings", + name: "filterwordschannelid", columns: table => new { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: false), - enabled = table.Column<bool>(type: "boolean", nullable: false), - addroleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - fromroleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - keyword = table.Column<string>(type: "text", nullable: true), + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + guildfilterconfigid = table.Column<int>(type: "integer", nullable: true), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, constraints: table => { - table.PrimaryKey("pk_streamrolesettings", x => x.id); + table.PrimaryKey("pk_filterwordschannelid", x => x.id); table.ForeignKey( - name: "fk_streamrolesettings_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "unbantimer", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - unbanat = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_unbantimer", x => x.id); - table.ForeignKey( - name: "fk_unbantimer_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "unmutetimer", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - unmuteat = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_unmutetimer", x => x.id); - table.ForeignKey( - name: "fk_unmutetimer_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "unroletimer", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - unbanat = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_unroletimer", x => x.id); - table.ForeignKey( - name: "fk_unroletimer_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "vcroleinfo", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - voicechannelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - guildconfigid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_vcroleinfo", x => x.id); - table.ForeignKey( - name: "fk_vcroleinfo_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "xpsettings", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - guildconfigid = table.Column<int>(type: "integer", nullable: false), - serverexcluded = table.Column<bool>(type: "boolean", nullable: false), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_xpsettings", x => x.id); - table.ForeignKey( - name: "fk_xpsettings_guildconfigs_guildconfigid", - column: x => x.guildconfigid, - principalTable: "guildconfigs", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); + name: "fk_filterwordschannelid_guildfilterconfig_guildfilterconfigid", + column: x => x.guildfilterconfigid, + principalTable: "guildfilterconfig", + principalColumn: "id"); }); migrationBuilder.CreateTable( @@ -1472,50 +1389,6 @@ namespace EllieBot.Migrations.PostgreSql onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "todos", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - todo = table.Column<string>(type: "text", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), - isdone = table.Column<bool>(type: "boolean", nullable: false), - archiveid = table.Column<int>(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_todos", x => x.id); - table.ForeignKey( - name: "fk_todos_todosarchive_archiveid", - column: x => x.archiveid, - principalTable: "todosarchive", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "antispamignore", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - antispamsettingid = table.Column<int>(type: "integer", nullable: true), - dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_antispamignore", x => x.id); - table.ForeignKey( - name: "fk_antispamignore_antispamsetting_antispamsettingid", - column: x => x.antispamsettingid, - principalTable: "antispamsetting", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "shopentryitem", columns: table => new @@ -1581,15 +1454,38 @@ namespace EllieBot.Migrations.PostgreSql onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "todos", + columns: table => new + { + id = table.Column<int>(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), + todo = table.Column<string>(type: "text", nullable: true), + dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), + isdone = table.Column<bool>(type: "boolean", nullable: false), + archiveid = table.Column<int>(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_todos", x => x.id); + table.ForeignKey( + name: "fk_todos_todosarchive_archiveid", + column: x => x.archiveid, + principalTable: "todosarchive", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "excludeditem", columns: table => new { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - xpsettingsid = table.Column<int>(type: "integer", nullable: true), itemid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), itemtype = table.Column<int>(type: "integer", nullable: false), + xpsettingsid = table.Column<int>(type: "integer", nullable: true), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, constraints: table => @@ -1599,8 +1495,7 @@ namespace EllieBot.Migrations.PostgreSql name: "fk_excludeditem_xpsettings_xpsettingsid", column: x => x.xpsettingsid, principalTable: "xpsettings", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); + principalColumn: "id"); }); migrationBuilder.CreateTable( @@ -1805,15 +1700,15 @@ namespace EllieBot.Migrations.PostgreSql }); migrationBuilder.CreateIndex( - name: "ix_antialtsetting_guildconfigid", + name: "ix_antialtsetting_guildid", table: "antialtsetting", - column: "guildconfigid", + column: "guildid", unique: true); migrationBuilder.CreateIndex( - name: "ix_antiraidsetting_guildconfigid", + name: "ix_antiraidsetting_guildid", table: "antiraidsetting", - column: "guildconfigid", + column: "guildid", unique: true); migrationBuilder.CreateIndex( @@ -1822,9 +1717,9 @@ namespace EllieBot.Migrations.PostgreSql column: "antispamsettingid"); migrationBuilder.CreateIndex( - name: "ix_antispamsetting_guildconfigid", + name: "ix_antispamsetting_guildid", table: "antispamsetting", - column: "guildconfigid", + column: "guildid", unique: true); migrationBuilder.CreateIndex( @@ -1884,14 +1779,15 @@ namespace EllieBot.Migrations.PostgreSql unique: true); migrationBuilder.CreateIndex( - name: "ix_commandalias_guildconfigid", + name: "ix_commandalias_guildid", table: "commandalias", - column: "guildconfigid"); + column: "guildid"); migrationBuilder.CreateIndex( - name: "ix_commandcooldown_guildconfigid", + name: "ix_commandcooldown_guildid_commandname", table: "commandcooldown", - column: "guildconfigid"); + columns: new[] { "guildid", "commandname" }, + unique: true); migrationBuilder.CreateIndex( name: "ix_currencytransactions_userid", @@ -1899,9 +1795,10 @@ namespace EllieBot.Migrations.PostgreSql column: "userid"); migrationBuilder.CreateIndex( - name: "ix_delmsgoncmdchannel_guildconfigid", + name: "ix_delmsgoncmdchannel_guildid_channelid", table: "delmsgoncmdchannel", - column: "guildconfigid"); + columns: new[] { "guildid", "channelid" }, + unique: true); migrationBuilder.CreateIndex( name: "ix_discordpermoverrides_guildid_command", @@ -1940,24 +1837,30 @@ namespace EllieBot.Migrations.PostgreSql column: "xpsettingsid"); migrationBuilder.CreateIndex( - name: "ix_filterchannelid_guildconfigid", + name: "ix_feedsub_guildid_url", + table: "feedsub", + columns: new[] { "guildid", "url" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "ix_filterchannelid_guildfilterconfigid", table: "filterchannelid", - column: "guildconfigid"); + column: "guildfilterconfigid"); migrationBuilder.CreateIndex( - name: "ix_filteredword_guildconfigid", + name: "ix_filteredword_guildfilterconfigid", table: "filteredword", - column: "guildconfigid"); + column: "guildfilterconfigid"); migrationBuilder.CreateIndex( - name: "ix_filterlinkschannelid_guildconfigid", + name: "ix_filterlinkschannelid_guildfilterconfigid", table: "filterlinkschannelid", - column: "guildconfigid"); + column: "guildfilterconfigid"); migrationBuilder.CreateIndex( - name: "ix_filterwordschannelid_guildconfigid", + name: "ix_filterwordschannelid_guildfilterconfigid", table: "filterwordschannelid", - column: "guildconfigid"); + column: "guildfilterconfigid"); migrationBuilder.CreateIndex( name: "ix_flagtranslatechannel_guildid_channelid", @@ -1966,9 +1869,9 @@ namespace EllieBot.Migrations.PostgreSql unique: true); migrationBuilder.CreateIndex( - name: "ix_followedstream_guildconfigid", + name: "ix_followedstream_guildid_username_type", table: "followedstream", - column: "guildconfigid"); + columns: new[] { "guildid", "username", "type" }); migrationBuilder.CreateIndex( name: "ix_gamblingstats_feature", @@ -1977,9 +1880,10 @@ namespace EllieBot.Migrations.PostgreSql unique: true); migrationBuilder.CreateIndex( - name: "ix_gcchannelid_guildconfigid", + name: "ix_gcchannelid_guildid_channelid", table: "gcchannelid", - column: "guildconfigid"); + columns: new[] { "guildid", "channelid" }, + unique: true); migrationBuilder.CreateIndex( name: "ix_giveawayuser_giveawayid_userid", @@ -2010,6 +1914,11 @@ namespace EllieBot.Migrations.PostgreSql table: "guildconfigs", column: "warnexpirehours"); + migrationBuilder.CreateIndex( + name: "ix_guildfilterconfig_guildid", + table: "guildfilterconfig", + column: "guildid"); + migrationBuilder.CreateIndex( name: "ix_ignoredlogchannels_logsettingid_logitemid_itemtype", table: "ignoredlogchannels", @@ -2035,9 +1944,10 @@ namespace EllieBot.Migrations.PostgreSql unique: true); migrationBuilder.CreateIndex( - name: "ix_muteduserid_guildconfigid", + name: "ix_muteduserid_guildid_userid", table: "muteduserid", - column: "guildconfigid"); + columns: new[] { "guildid", "userid" }, + unique: true); migrationBuilder.CreateIndex( name: "ix_ncpixel_ownerid", @@ -2055,6 +1965,11 @@ namespace EllieBot.Migrations.PostgreSql table: "permissions", column: "guildconfigid"); + migrationBuilder.CreateIndex( + name: "ix_permissions_guildid", + table: "permissions", + column: "guildid"); + migrationBuilder.CreateIndex( name: "ix_plantedcurrency_channelid", table: "plantedcurrency", @@ -2115,9 +2030,10 @@ namespace EllieBot.Migrations.PostgreSql unique: true); migrationBuilder.CreateIndex( - name: "ix_shopentry_guildconfigid", + name: "ix_shopentry_guildid_index", table: "shopentry", - column: "guildconfigid"); + columns: new[] { "guildid", "index" }, + unique: true); migrationBuilder.CreateIndex( name: "ix_shopentryitem_shopentryid", @@ -2125,14 +2041,16 @@ namespace EllieBot.Migrations.PostgreSql column: "shopentryid"); migrationBuilder.CreateIndex( - name: "ix_slowmodeignoredrole_guildconfigid", + name: "ix_slowmodeignoredrole_guildid_roleid", table: "slowmodeignoredrole", - column: "guildconfigid"); + columns: new[] { "guildid", "roleid" }, + unique: true); migrationBuilder.CreateIndex( - name: "ix_slowmodeignoreduser_guildconfigid", + name: "ix_slowmodeignoreduser_guildid_userid", table: "slowmodeignoreduser", - column: "guildconfigid"); + columns: new[] { "guildid", "userid" }, + unique: true); migrationBuilder.CreateIndex( name: "ix_stickyroles_guildid_userid", @@ -2146,9 +2064,9 @@ namespace EllieBot.Migrations.PostgreSql column: "streamrolesettingsid"); migrationBuilder.CreateIndex( - name: "ix_streamrolesettings_guildconfigid", + name: "ix_streamrolesettings_guildid", table: "streamrolesettings", - column: "guildconfigid", + column: "guildid", unique: true); migrationBuilder.CreateIndex( @@ -2172,19 +2090,22 @@ namespace EllieBot.Migrations.PostgreSql column: "userid"); migrationBuilder.CreateIndex( - name: "ix_unbantimer_guildconfigid", + name: "ix_unbantimer_guildid_userid", table: "unbantimer", - column: "guildconfigid"); + columns: new[] { "guildid", "userid" }, + unique: true); migrationBuilder.CreateIndex( - name: "ix_unmutetimer_guildconfigid", + name: "ix_unmutetimer_guildid_userid", table: "unmutetimer", - column: "guildconfigid"); + columns: new[] { "guildid", "userid" }, + unique: true); migrationBuilder.CreateIndex( - name: "ix_unroletimer_guildconfigid", + name: "ix_unroletimer_guildid_userid", table: "unroletimer", - column: "guildconfigid"); + columns: new[] { "guildid", "userid" }, + unique: true); migrationBuilder.CreateIndex( name: "ix_userbetstats_maxwin", @@ -2225,9 +2146,10 @@ namespace EllieBot.Migrations.PostgreSql column: "xp"); migrationBuilder.CreateIndex( - name: "ix_vcroleinfo_guildconfigid", + name: "ix_vcroleinfo_guildid_voicechannelid", table: "vcroleinfo", - column: "guildconfigid"); + columns: new[] { "guildid", "voicechannelid" }, + unique: true); migrationBuilder.CreateIndex( name: "ix_waifuinfo_affinityid", @@ -2285,6 +2207,12 @@ namespace EllieBot.Migrations.PostgreSql table: "warnings", column: "userid"); + migrationBuilder.CreateIndex( + name: "ix_xpcurrencyreward_level_xpsettingsid", + table: "xpcurrencyreward", + columns: new[] { "level", "xpsettingsid" }, + unique: true); + migrationBuilder.CreateIndex( name: "ix_xpcurrencyreward_xpsettingsid", table: "xpcurrencyreward", @@ -2297,9 +2225,9 @@ namespace EllieBot.Migrations.PostgreSql unique: true); migrationBuilder.CreateIndex( - name: "ix_xpsettings_guildconfigid", + name: "ix_xpsettings_guildid", table: "xpsettings", - column: "guildconfigid", + column: "guildid", unique: true); migrationBuilder.CreateIndex( @@ -2587,12 +2515,18 @@ namespace EllieBot.Migrations.PostgreSql migrationBuilder.DropTable( name: "autotranslatechannels"); + migrationBuilder.DropTable( + name: "guildfilterconfig"); + migrationBuilder.DropTable( name: "giveawaymodel"); migrationBuilder.DropTable( name: "logsettings"); + migrationBuilder.DropTable( + name: "guildconfigs"); + migrationBuilder.DropTable( name: "musicplaylists"); @@ -2614,9 +2548,6 @@ namespace EllieBot.Migrations.PostgreSql migrationBuilder.DropTable( name: "xpsettings"); - migrationBuilder.DropTable( - name: "guildconfigs"); - migrationBuilder.DropTable( name: "clubs"); diff --git a/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs b/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs index 84bf2ee..ad0ebcd 100644 --- a/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs +++ b/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs @@ -23,4152 +23,3971 @@ namespace EllieBot.Migrations.PostgreSql NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("EllieBot.Db.Models.AntiAltSetting", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("Action") - .HasColumnType("integer") - .HasColumnName("action"); + b.Property<int>("Action") + .HasColumnType("integer") + .HasColumnName("action"); - b.Property<int>("ActionDurationMinutes") - .HasColumnType("integer") - .HasColumnName("actiondurationminutes"); + b.Property<int>("ActionDurationMinutes") + .HasColumnType("integer") + .HasColumnName("actiondurationminutes"); - b.Property<int>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); - b.Property<TimeSpan>("MinAge") - .HasColumnType("interval") - .HasColumnName("minage"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal?>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<TimeSpan>("MinAge") + .HasColumnType("interval") + .HasColumnName("minage"); - b.HasKey("Id") - .HasName("pk_antialtsetting"); + b.Property<decimal?>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.HasIndex("GuildConfigId") - .IsUnique() - .HasDatabaseName("ix_antialtsetting_guildconfigid"); + b.HasKey("Id") + .HasName("pk_antialtsetting"); - b.ToTable("antialtsetting", (string)null); - }); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_antialtsetting_guildid"); + + b.ToTable("antialtsetting", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiRaidSetting", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("Action") - .HasColumnType("integer") - .HasColumnName("action"); + b.Property<int>("Action") + .HasColumnType("integer") + .HasColumnName("action"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); - b.Property<int>("PunishDuration") - .HasColumnType("integer") - .HasColumnName("punishduration"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int>("Seconds") - .HasColumnType("integer") - .HasColumnName("seconds"); + b.Property<int>("PunishDuration") + .HasColumnType("integer") + .HasColumnName("punishduration"); - b.Property<int>("UserThreshold") - .HasColumnType("integer") - .HasColumnName("userthreshold"); + b.Property<int>("Seconds") + .HasColumnType("integer") + .HasColumnName("seconds"); - b.HasKey("Id") - .HasName("pk_antiraidsetting"); + b.Property<int>("UserThreshold") + .HasColumnType("integer") + .HasColumnName("userthreshold"); - b.HasIndex("GuildConfigId") - .IsUnique() - .HasDatabaseName("ix_antiraidsetting_guildconfigid"); + b.HasKey("Id") + .HasName("pk_antiraidsetting"); - b.ToTable("antiraidsetting", (string)null); - }); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_antiraidsetting_guildid"); + + b.ToTable("antiraidsetting", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamIgnore", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int?>("AntiSpamSettingId") - .HasColumnType("integer") - .HasColumnName("antispamsettingid"); + b.Property<int?>("AntiSpamSettingId") + .HasColumnType("integer") + .HasColumnName("antispamsettingid"); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.HasKey("Id") - .HasName("pk_antispamignore"); + b.HasKey("Id") + .HasName("pk_antispamignore"); - b.HasIndex("AntiSpamSettingId") - .HasDatabaseName("ix_antispamignore_antispamsettingid"); + b.HasIndex("AntiSpamSettingId") + .HasDatabaseName("ix_antispamignore_antispamsettingid"); - b.ToTable("antispamignore", (string)null); - }); + b.ToTable("antispamignore", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("Action") - .HasColumnType("integer") - .HasColumnName("action"); + b.Property<int>("Action") + .HasColumnType("integer") + .HasColumnName("action"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); - b.Property<int>("MessageThreshold") - .HasColumnType("integer") - .HasColumnName("messagethreshold"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int>("MuteTime") - .HasColumnType("integer") - .HasColumnName("mutetime"); + b.Property<int>("MessageThreshold") + .HasColumnType("integer") + .HasColumnName("messagethreshold"); - b.Property<decimal?>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<int>("MuteTime") + .HasColumnType("integer") + .HasColumnName("mutetime"); - b.HasKey("Id") - .HasName("pk_antispamsetting"); + b.Property<decimal?>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.HasIndex("GuildConfigId") - .IsUnique() - .HasDatabaseName("ix_antispamsetting_guildconfigid"); + b.HasKey("Id") + .HasName("pk_antispamsetting"); - b.ToTable("antispamsetting", (string)null); - }); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_antispamsetting_guildid"); + + b.ToTable("antispamsetting", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ArchivedTodoListModel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); + b.Property<string>("Name") + .HasColumnType("text") + .HasColumnName("name"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_todosarchive"); + b.HasKey("Id") + .HasName("pk_todosarchive"); - b.ToTable("todosarchive", (string)null); - }); + b.ToTable("todosarchive", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoCommand", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<string>("ChannelName") - .HasColumnType("text") - .HasColumnName("channelname"); + b.Property<string>("ChannelName") + .HasColumnType("text") + .HasColumnName("channelname"); - b.Property<string>("CommandText") - .HasColumnType("text") - .HasColumnName("commandtext"); + b.Property<string>("CommandText") + .HasColumnType("text") + .HasColumnName("commandtext"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal?>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal?>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("GuildName") - .HasColumnType("text") - .HasColumnName("guildname"); + b.Property<string>("GuildName") + .HasColumnType("text") + .HasColumnName("guildname"); - b.Property<int>("Interval") - .HasColumnType("integer") - .HasColumnName("interval"); + b.Property<int>("Interval") + .HasColumnType("integer") + .HasColumnName("interval"); - b.Property<decimal?>("VoiceChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("voicechannelid"); + b.Property<decimal?>("VoiceChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("voicechannelid"); - b.Property<string>("VoiceChannelName") - .HasColumnType("text") - .HasColumnName("voicechannelname"); + b.Property<string>("VoiceChannelName") + .HasColumnType("text") + .HasColumnName("voicechannelname"); - b.HasKey("Id") - .HasName("pk_autocommands"); + b.HasKey("Id") + .HasName("pk_autocommands"); - b.ToTable("autocommands", (string)null); - }); + b.ToTable("autocommands", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoPublishChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.HasKey("Id") - .HasName("pk_autopublishchannel"); + b.HasKey("Id") + .HasName("pk_autopublishchannel"); - b.HasIndex("GuildId") - .IsUnique() - .HasDatabaseName("ix_autopublishchannel_guildid"); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_autopublishchannel_guildid"); - b.ToTable("autopublishchannel", (string)null); - }); + b.ToTable("autopublishchannel", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<bool>("AutoDelete") - .HasColumnType("boolean") - .HasColumnName("autodelete"); + b.Property<bool>("AutoDelete") + .HasColumnType("boolean") + .HasColumnName("autodelete"); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.HasKey("Id") - .HasName("pk_autotranslatechannels"); + b.HasKey("Id") + .HasName("pk_autotranslatechannels"); - b.HasIndex("ChannelId") - .IsUnique() - .HasDatabaseName("ix_autotranslatechannels_channelid"); + b.HasIndex("ChannelId") + .IsUnique() + .HasDatabaseName("ix_autotranslatechannels_channelid"); - b.HasIndex("GuildId") - .HasDatabaseName("ix_autotranslatechannels_guildid"); + b.HasIndex("GuildId") + .HasDatabaseName("ix_autotranslatechannels_guildid"); - b.ToTable("autotranslatechannels", (string)null); - }); + b.ToTable("autotranslatechannels", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("ChannelId") - .HasColumnType("integer") - .HasColumnName("channelid"); + b.Property<int>("ChannelId") + .HasColumnType("integer") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<string>("Source") - .HasColumnType("text") - .HasColumnName("source"); + b.Property<string>("Source") + .HasColumnType("text") + .HasColumnName("source"); - b.Property<string>("Target") - .HasColumnType("text") - .HasColumnName("target"); + b.Property<string>("Target") + .HasColumnType("text") + .HasColumnName("target"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_autotranslateusers"); + b.HasKey("Id") + .HasName("pk_autotranslateusers"); - b.HasAlternateKey("ChannelId", "UserId") - .HasName("ak_autotranslateusers_channelid_userid"); + b.HasAlternateKey("ChannelId", "UserId") + .HasName("ak_autotranslateusers_channelid_userid"); - b.ToTable("autotranslateusers", (string)null); - }); + b.ToTable("autotranslateusers", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.BanTemplate", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int?>("PruneDays") - .HasColumnType("integer") - .HasColumnName("prunedays"); + b.Property<int?>("PruneDays") + .HasColumnType("integer") + .HasColumnName("prunedays"); - b.Property<string>("Text") - .HasColumnType("text") - .HasColumnName("text"); + b.Property<string>("Text") + .HasColumnType("text") + .HasColumnName("text"); - b.HasKey("Id") - .HasName("pk_bantemplates"); + b.HasKey("Id") + .HasName("pk_bantemplates"); - b.HasIndex("GuildId") - .IsUnique() - .HasDatabaseName("ix_bantemplates_guildid"); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_bantemplates_guildid"); - b.ToTable("bantemplates", (string)null); - }); + b.ToTable("bantemplates", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.BankUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<long>("Balance") - .HasColumnType("bigint") - .HasColumnName("balance"); + b.Property<long>("Balance") + .HasColumnType("bigint") + .HasColumnName("balance"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_bankusers"); + b.HasKey("Id") + .HasName("pk_bankusers"); - b.HasIndex("UserId") - .IsUnique() - .HasDatabaseName("ix_bankusers_userid"); + b.HasIndex("UserId") + .IsUnique() + .HasDatabaseName("ix_bankusers_userid"); - b.ToTable("bankusers", (string)null); - }); + b.ToTable("bankusers", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.BlacklistEntry", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("ItemId") - .HasColumnType("numeric(20,0)") - .HasColumnName("itemid"); + b.Property<decimal>("ItemId") + .HasColumnType("numeric(20,0)") + .HasColumnName("itemid"); - b.Property<int>("Type") - .HasColumnType("integer") - .HasColumnName("type"); + b.Property<int>("Type") + .HasColumnType("integer") + .HasColumnName("type"); - b.HasKey("Id") - .HasName("pk_blacklist"); + b.HasKey("Id") + .HasName("pk_blacklist"); - b.ToTable("blacklist", (string)null); - }); + b.ToTable("blacklist", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ButtonRole", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<string>("ButtonId") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)") - .HasColumnName("buttonid"); + b.Property<string>("ButtonId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)") + .HasColumnName("buttonid"); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<string>("Emote") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("character varying(100)") - .HasColumnName("emote"); + b.Property<string>("Emote") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("emote"); - b.Property<bool>("Exclusive") - .HasColumnType("boolean") - .HasColumnName("exclusive"); + b.Property<bool>("Exclusive") + .HasColumnType("boolean") + .HasColumnName("exclusive"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("Label") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("label"); + b.Property<string>("Label") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("label"); - b.Property<decimal>("MessageId") - .HasColumnType("numeric(20,0)") - .HasColumnName("messageid"); + b.Property<decimal>("MessageId") + .HasColumnType("numeric(20,0)") + .HasColumnName("messageid"); - b.Property<int>("Position") - .HasColumnType("integer") - .HasColumnName("position"); + b.Property<int>("Position") + .HasColumnType("integer") + .HasColumnName("position"); - b.Property<decimal>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.HasKey("Id") - .HasName("pk_buttonrole"); + b.HasKey("Id") + .HasName("pk_buttonrole"); - b.HasAlternateKey("RoleId", "MessageId") - .HasName("ak_buttonrole_roleid_messageid"); + b.HasAlternateKey("RoleId", "MessageId") + .HasName("ak_buttonrole_roleid_messageid"); - b.HasIndex("GuildId") - .HasDatabaseName("ix_buttonrole_guildid"); + b.HasIndex("GuildId") + .HasDatabaseName("ix_buttonrole_guildid"); - b.ToTable("buttonrole", (string)null); - }); + b.ToTable("buttonrole", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubApplicants", b => - { - b.Property<int>("ClubId") - .HasColumnType("integer") - .HasColumnName("clubid"); + { + b.Property<int>("ClubId") + .HasColumnType("integer") + .HasColumnName("clubid"); - b.Property<int>("UserId") - .HasColumnType("integer") - .HasColumnName("userid"); + b.Property<int>("UserId") + .HasColumnType("integer") + .HasColumnName("userid"); - b.HasKey("ClubId", "UserId") - .HasName("pk_clubapplicants"); + b.HasKey("ClubId", "UserId") + .HasName("pk_clubapplicants"); - b.HasIndex("UserId") - .HasDatabaseName("ix_clubapplicants_userid"); + b.HasIndex("UserId") + .HasDatabaseName("ix_clubapplicants_userid"); - b.ToTable("clubapplicants", (string)null); - }); + b.ToTable("clubapplicants", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubBans", b => - { - b.Property<int>("ClubId") - .HasColumnType("integer") - .HasColumnName("clubid"); + { + b.Property<int>("ClubId") + .HasColumnType("integer") + .HasColumnName("clubid"); - b.Property<int>("UserId") - .HasColumnType("integer") - .HasColumnName("userid"); + b.Property<int>("UserId") + .HasColumnType("integer") + .HasColumnName("userid"); - b.HasKey("ClubId", "UserId") - .HasName("pk_clubbans"); + b.HasKey("ClubId", "UserId") + .HasName("pk_clubbans"); - b.HasIndex("UserId") - .HasDatabaseName("ix_clubbans_userid"); + b.HasIndex("UserId") + .HasDatabaseName("ix_clubbans_userid"); - b.ToTable("clubbans", (string)null); - }); + b.ToTable("clubbans", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubInfo", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); + b.Property<string>("Description") + .HasColumnType("text") + .HasColumnName("description"); - b.Property<string>("ImageUrl") - .HasColumnType("text") - .HasColumnName("imageurl"); + b.Property<string>("ImageUrl") + .HasColumnType("text") + .HasColumnName("imageurl"); - b.Property<string>("Name") - .HasMaxLength(20) - .HasColumnType("character varying(20)") - .HasColumnName("name"); + b.Property<string>("Name") + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasColumnName("name"); - b.Property<int?>("OwnerId") - .HasColumnType("integer") - .HasColumnName("ownerid"); + b.Property<int?>("OwnerId") + .HasColumnType("integer") + .HasColumnName("ownerid"); - b.Property<int>("Xp") - .HasColumnType("integer") - .HasColumnName("xp"); + b.Property<int>("Xp") + .HasColumnType("integer") + .HasColumnName("xp"); - b.HasKey("Id") - .HasName("pk_clubs"); + b.HasKey("Id") + .HasName("pk_clubs"); - b.HasIndex("Name") - .IsUnique() - .HasDatabaseName("ix_clubs_name"); + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("ix_clubs_name"); - b.HasIndex("OwnerId") - .IsUnique() - .HasDatabaseName("ix_clubs_ownerid"); + b.HasIndex("OwnerId") + .IsUnique() + .HasDatabaseName("ix_clubs_ownerid"); - b.ToTable("clubs", (string)null); - }); + b.ToTable("clubs", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.CommandAlias", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("Mapping") - .HasColumnType("text") - .HasColumnName("mapping"); + b.Property<string>("Mapping") + .HasColumnType("text") + .HasColumnName("mapping"); - b.Property<string>("Trigger") - .HasColumnType("text") - .HasColumnName("trigger"); + b.Property<string>("Trigger") + .HasColumnType("text") + .HasColumnName("trigger"); - b.HasKey("Id") - .HasName("pk_commandalias"); + b.HasKey("Id") + .HasName("pk_commandalias"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_commandalias_guildconfigid"); + b.HasIndex("GuildId") + .HasDatabaseName("ix_commandalias_guildid"); - b.ToTable("commandalias", (string)null); - }); + b.ToTable("commandalias", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.CommandCooldown", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<string>("CommandName") - .HasColumnType("text") - .HasColumnName("commandname"); + b.Property<string>("CommandName") + .HasColumnType("text") + .HasColumnName("commandname"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int>("Seconds") - .HasColumnType("integer") - .HasColumnName("seconds"); + b.Property<int>("Seconds") + .HasColumnType("integer") + .HasColumnName("seconds"); - b.HasKey("Id") - .HasName("pk_commandcooldown"); + b.HasKey("Id") + .HasName("pk_commandcooldown"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_commandcooldown_guildconfigid"); + b.HasIndex("GuildId", "CommandName") + .IsUnique() + .HasDatabaseName("ix_commandcooldown_guildid_commandname"); - b.ToTable("commandcooldown", (string)null); - }); + b.ToTable("commandcooldown", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.CurrencyTransaction", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<long>("Amount") - .HasColumnType("bigint") - .HasColumnName("amount"); + b.Property<long>("Amount") + .HasColumnType("bigint") + .HasColumnName("amount"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<string>("Extra") - .IsRequired() - .HasColumnType("text") - .HasColumnName("extra"); + b.Property<string>("Extra") + .IsRequired() + .HasColumnType("text") + .HasColumnName("extra"); - b.Property<string>("Note") - .HasColumnType("text") - .HasColumnName("note"); + b.Property<string>("Note") + .HasColumnType("text") + .HasColumnName("note"); - b.Property<decimal?>("OtherId") - .ValueGeneratedOnAdd() - .HasColumnType("numeric(20,0)") - .HasColumnName("otherid") - .HasDefaultValueSql("NULL"); + b.Property<decimal?>("OtherId") + .ValueGeneratedOnAdd() + .HasColumnType("numeric(20,0)") + .HasColumnName("otherid") + .HasDefaultValueSql("NULL"); - b.Property<string>("Type") - .IsRequired() - .HasColumnType("text") - .HasColumnName("type"); + b.Property<string>("Type") + .IsRequired() + .HasColumnType("text") + .HasColumnName("type"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_currencytransactions"); + b.HasKey("Id") + .HasName("pk_currencytransactions"); - b.HasIndex("UserId") - .HasDatabaseName("ix_currencytransactions_userid"); + b.HasIndex("UserId") + .HasDatabaseName("ix_currencytransactions_userid"); - b.ToTable("currencytransactions", (string)null); - }); + b.ToTable("currencytransactions", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.DelMsgOnCmdChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); - b.Property<bool>("State") - .HasColumnType("boolean") - .HasColumnName("state"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.HasKey("Id") - .HasName("pk_delmsgoncmdchannel"); + b.Property<bool>("State") + .HasColumnType("boolean") + .HasColumnName("state"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_delmsgoncmdchannel_guildconfigid"); + b.HasKey("Id") + .HasName("pk_delmsgoncmdchannel"); - b.ToTable("delmsgoncmdchannel", (string)null); - }); + b.HasIndex("GuildId", "ChannelId") + .IsUnique() + .HasDatabaseName("ix_delmsgoncmdchannel_guildid_channelid"); + + b.ToTable("delmsgoncmdchannel", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.DiscordPermOverride", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<string>("Command") - .HasColumnType("text") - .HasColumnName("command"); + b.Property<string>("Command") + .HasColumnType("text") + .HasColumnName("command"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal?>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal?>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal>("Perm") - .HasColumnType("numeric(20,0)") - .HasColumnName("perm"); + b.Property<decimal>("Perm") + .HasColumnType("numeric(20,0)") + .HasColumnName("perm"); - b.HasKey("Id") - .HasName("pk_discordpermoverrides"); + b.HasKey("Id") + .HasName("pk_discordpermoverrides"); - b.HasIndex("GuildId", "Command") - .IsUnique() - .HasDatabaseName("ix_discordpermoverrides_guildid_command"); + b.HasIndex("GuildId", "Command") + .IsUnique() + .HasDatabaseName("ix_discordpermoverrides_guildid_command"); - b.ToTable("discordpermoverrides", (string)null); - }); + b.ToTable("discordpermoverrides", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.DiscordUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<string>("AvatarId") - .HasColumnType("text") - .HasColumnName("avatarid"); + b.Property<string>("AvatarId") + .HasColumnType("text") + .HasColumnName("avatarid"); - b.Property<int?>("ClubId") - .HasColumnType("integer") - .HasColumnName("clubid"); + b.Property<int?>("ClubId") + .HasColumnType("integer") + .HasColumnName("clubid"); - b.Property<long>("CurrencyAmount") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasDefaultValue(0L) - .HasColumnName("currencyamount"); + b.Property<long>("CurrencyAmount") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(0L) + .HasColumnName("currencyamount"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<bool>("IsClubAdmin") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(false) - .HasColumnName("isclubadmin"); + b.Property<bool>("IsClubAdmin") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("isclubadmin"); - b.Property<int>("NotifyOnLevelUp") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasDefaultValue(0) - .HasColumnName("notifyonlevelup"); + b.Property<int>("NotifyOnLevelUp") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("notifyonlevelup"); - b.Property<long>("TotalXp") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasDefaultValue(0L) - .HasColumnName("totalxp"); + b.Property<long>("TotalXp") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(0L) + .HasColumnName("totalxp"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); + b.Property<string>("Username") + .HasColumnType("text") + .HasColumnName("username"); - b.HasKey("Id") - .HasName("pk_discorduser"); + b.HasKey("Id") + .HasName("pk_discorduser"); - b.HasAlternateKey("UserId") - .HasName("ak_discorduser_userid"); + b.HasAlternateKey("UserId") + .HasName("ak_discorduser_userid"); - b.HasIndex("ClubId") - .HasDatabaseName("ix_discorduser_clubid"); + b.HasIndex("ClubId") + .HasDatabaseName("ix_discorduser_clubid"); - b.HasIndex("CurrencyAmount") - .HasDatabaseName("ix_discorduser_currencyamount"); + b.HasIndex("CurrencyAmount") + .HasDatabaseName("ix_discorduser_currencyamount"); - b.HasIndex("TotalXp") - .HasDatabaseName("ix_discorduser_totalxp"); + b.HasIndex("TotalXp") + .HasDatabaseName("ix_discorduser_totalxp"); - b.HasIndex("UserId") - .HasDatabaseName("ix_discorduser_userid"); + b.HasIndex("UserId") + .HasDatabaseName("ix_discorduser_userid"); - b.HasIndex("Username") - .HasDatabaseName("ix_discorduser_username"); + b.HasIndex("Username") + .HasDatabaseName("ix_discorduser_username"); - b.ToTable("discorduser", (string)null); - }); - - modelBuilder.Entity("EllieBot.Db.Models.EllieExpression", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - - b.Property<bool>("AllowTarget") - .HasColumnType("boolean") - .HasColumnName("allowtarget"); - - b.Property<bool>("AutoDeleteTrigger") - .HasColumnType("boolean") - .HasColumnName("autodeletetrigger"); - - b.Property<bool>("ContainsAnywhere") - .HasColumnType("boolean") - .HasColumnName("containsanywhere"); - - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); - - b.Property<bool>("DmResponse") - .HasColumnType("boolean") - .HasColumnName("dmresponse"); - - b.Property<decimal?>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); - - b.Property<string>("Reactions") - .HasColumnType("text") - .HasColumnName("reactions"); - - b.Property<string>("Response") - .HasColumnType("text") - .HasColumnName("response"); - - b.Property<string>("Trigger") - .HasColumnType("text") - .HasColumnName("trigger"); - - b.HasKey("Id") - .HasName("pk_expressions"); - - b.ToTable("expressions", (string)null); - }); + b.ToTable("discorduser", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ExcludedItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("ItemId") - .HasColumnType("numeric(20,0)") - .HasColumnName("itemid"); + b.Property<decimal>("ItemId") + .HasColumnType("numeric(20,0)") + .HasColumnName("itemid"); - b.Property<int>("ItemType") - .HasColumnType("integer") - .HasColumnName("itemtype"); + b.Property<int>("ItemType") + .HasColumnType("integer") + .HasColumnName("itemtype"); - b.Property<int?>("XpSettingsId") - .HasColumnType("integer") - .HasColumnName("xpsettingsid"); + b.Property<int?>("XpSettingsId") + .HasColumnType("integer") + .HasColumnName("xpsettingsid"); - b.HasKey("Id") - .HasName("pk_excludeditem"); + b.HasKey("Id") + .HasName("pk_excludeditem"); - b.HasIndex("XpSettingsId") - .HasDatabaseName("ix_excludeditem_xpsettingsid"); + b.HasIndex("XpSettingsId") + .HasDatabaseName("ix_excludeditem_xpsettingsid"); - b.ToTable("excludeditem", (string)null); - }); + b.ToTable("excludeditem", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.FeedSub", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); - b.Property<string>("Message") - .HasColumnType("text") - .HasColumnName("message"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("Url") - .IsRequired() - .HasColumnType("text") - .HasColumnName("url"); + b.Property<string>("Message") + .HasColumnType("text") + .HasColumnName("message"); - b.HasKey("Id") - .HasName("pk_feedsub"); + b.Property<string>("Url") + .HasColumnType("text") + .HasColumnName("url"); - b.HasAlternateKey("GuildConfigId", "Url") - .HasName("ak_feedsub_guildconfigid_url"); + b.HasKey("Id") + .HasName("pk_feedsub"); - b.ToTable("feedsub", (string)null); - }); + b.HasIndex("GuildId", "Url") + .IsUnique() + .HasDatabaseName("ix_feedsub_guildid_url"); + + b.ToTable("feedsub", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterChannelId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<int?>("GuildFilterConfigId") + .HasColumnType("integer") + .HasColumnName("guildfilterconfigid"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.HasKey("Id") + .HasName("pk_filterchannelid"); - b.HasKey("Id") - .HasName("pk_filterchannelid"); + b.HasIndex("GuildFilterConfigId") + .HasDatabaseName("ix_filterchannelid_guildfilterconfigid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_filterchannelid_guildconfigid"); - - b.ToTable("filterchannelid", (string)null); - }); + b.ToTable("filterchannelid", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterLinksChannelId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int?>("GuildFilterConfigId") + .HasColumnType("integer") + .HasColumnName("guildfilterconfigid"); - b.HasKey("Id") - .HasName("pk_filterlinkschannelid"); + b.HasKey("Id") + .HasName("pk_filterlinkschannelid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_filterlinkschannelid_guildconfigid"); + b.HasIndex("GuildFilterConfigId") + .HasDatabaseName("ix_filterlinkschannelid_guildfilterconfigid"); - b.ToTable("filterlinkschannelid", (string)null); - }); + b.ToTable("filterlinkschannelid", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterWordsChannelId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int?>("GuildFilterConfigId") + .HasColumnType("integer") + .HasColumnName("guildfilterconfigid"); - b.HasKey("Id") - .HasName("pk_filterwordschannelid"); + b.HasKey("Id") + .HasName("pk_filterwordschannelid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_filterwordschannelid_guildconfigid"); + b.HasIndex("GuildFilterConfigId") + .HasDatabaseName("ix_filterwordschannelid_guildfilterconfigid"); - b.ToTable("filterwordschannelid", (string)null); - }); + b.ToTable("filterwordschannelid", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.FilteredWord", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int?>("GuildFilterConfigId") + .HasColumnType("integer") + .HasColumnName("guildfilterconfigid"); - b.Property<string>("Word") - .HasColumnType("text") - .HasColumnName("word"); + b.Property<string>("Word") + .HasColumnType("text") + .HasColumnName("word"); - b.HasKey("Id") - .HasName("pk_filteredword"); + b.HasKey("Id") + .HasName("pk_filteredword"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_filteredword_guildconfigid"); + b.HasIndex("GuildFilterConfigId") + .HasDatabaseName("ix_filteredword_guildfilterconfigid"); - b.ToTable("filteredword", (string)null); - }); + b.ToTable("filteredword", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.FlagTranslateChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.HasKey("Id") - .HasName("pk_flagtranslatechannel"); + b.HasKey("Id") + .HasName("pk_flagtranslatechannel"); - b.HasIndex("GuildId", "ChannelId") - .IsUnique() - .HasDatabaseName("ix_flagtranslatechannel_guildid_channelid"); + b.HasIndex("GuildId", "ChannelId") + .IsUnique() + .HasDatabaseName("ix_flagtranslatechannel_guildid_channelid"); - b.ToTable("flagtranslatechannel", (string)null); - }); + b.ToTable("flagtranslatechannel", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.FollowedStream", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<string>("Message") + .HasColumnType("text") + .HasColumnName("message"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<int>("Type") + .HasColumnType("integer") + .HasColumnName("type"); - b.Property<string>("Message") - .HasColumnType("text") - .HasColumnName("message"); + b.Property<string>("Username") + .HasColumnType("text") + .HasColumnName("username"); - b.Property<int>("Type") - .HasColumnType("integer") - .HasColumnName("type"); + b.HasKey("Id") + .HasName("pk_followedstream"); - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); + b.HasIndex("GuildId", "Username", "Type") + .HasDatabaseName("ix_followedstream_guildid_username_type"); - b.HasKey("Id") - .HasName("pk_followedstream"); - - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_followedstream_guildconfigid"); - - b.ToTable("followedstream", (string)null); - }); + b.ToTable("followedstream", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.GCChannelId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.HasKey("Id") - .HasName("pk_gcchannelid"); + b.HasKey("Id") + .HasName("pk_gcchannelid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_gcchannelid_guildconfigid"); + b.HasIndex("GuildId", "ChannelId") + .IsUnique() + .HasDatabaseName("ix_gcchannelid_guildid_channelid"); - b.ToTable("gcchannelid", (string)null); - }); + b.ToTable("gcchannelid", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.GamblingStats", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("Bet") - .HasColumnType("numeric") - .HasColumnName("bet"); + b.Property<decimal>("Bet") + .HasColumnType("numeric") + .HasColumnName("bet"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<string>("Feature") - .HasColumnType("text") - .HasColumnName("feature"); + b.Property<string>("Feature") + .HasColumnType("text") + .HasColumnName("feature"); - b.Property<decimal>("PaidOut") - .HasColumnType("numeric") - .HasColumnName("paidout"); + b.Property<decimal>("PaidOut") + .HasColumnType("numeric") + .HasColumnName("paidout"); - b.HasKey("Id") - .HasName("pk_gamblingstats"); + b.HasKey("Id") + .HasName("pk_gamblingstats"); - b.HasIndex("Feature") - .IsUnique() - .HasDatabaseName("ix_gamblingstats_feature"); + b.HasIndex("Feature") + .IsUnique() + .HasDatabaseName("ix_gamblingstats_feature"); - b.ToTable("gamblingstats", (string)null); - }); + b.ToTable("gamblingstats", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayModel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime>("EndsAt") - .HasColumnType("timestamp without time zone") - .HasColumnName("endsat"); + b.Property<DateTime>("EndsAt") + .HasColumnType("timestamp without time zone") + .HasColumnName("endsat"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("Message") - .HasColumnType("text") - .HasColumnName("message"); + b.Property<string>("Message") + .HasColumnType("text") + .HasColumnName("message"); - b.Property<decimal>("MessageId") - .HasColumnType("numeric(20,0)") - .HasColumnName("messageid"); + b.Property<decimal>("MessageId") + .HasColumnType("numeric(20,0)") + .HasColumnName("messageid"); - b.HasKey("Id") - .HasName("pk_giveawaymodel"); + b.HasKey("Id") + .HasName("pk_giveawaymodel"); - b.ToTable("giveawaymodel", (string)null); - }); + b.ToTable("giveawaymodel", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("GiveawayId") - .HasColumnType("integer") - .HasColumnName("giveawayid"); + b.Property<int>("GiveawayId") + .HasColumnType("integer") + .HasColumnName("giveawayid"); - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); + b.Property<string>("Name") + .HasColumnType("text") + .HasColumnName("name"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_giveawayuser"); + b.HasKey("Id") + .HasName("pk_giveawayuser"); - b.HasIndex("GiveawayId", "UserId") - .IsUnique() - .HasDatabaseName("ix_giveawayuser_giveawayid_userid"); + b.HasIndex("GiveawayId", "UserId") + .IsUnique() + .HasDatabaseName("ix_giveawayuser_giveawayid_userid"); - b.ToTable("giveawayuser", (string)null); - }); + b.ToTable("giveawayuser", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.GuildColors", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<string>("ErrorColor") - .HasMaxLength(9) - .HasColumnType("character varying(9)") - .HasColumnName("errorcolor"); + b.Property<string>("ErrorColor") + .HasMaxLength(9) + .HasColumnType("character varying(9)") + .HasColumnName("errorcolor"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("OkColor") - .HasMaxLength(9) - .HasColumnType("character varying(9)") - .HasColumnName("okcolor"); + b.Property<string>("OkColor") + .HasMaxLength(9) + .HasColumnType("character varying(9)") + .HasColumnName("okcolor"); - b.Property<string>("PendingColor") - .HasMaxLength(9) - .HasColumnType("character varying(9)") - .HasColumnName("pendingcolor"); + b.Property<string>("PendingColor") + .HasMaxLength(9) + .HasColumnType("character varying(9)") + .HasColumnName("pendingcolor"); - b.HasKey("Id") - .HasName("pk_guildcolors"); + b.HasKey("Id") + .HasName("pk_guildcolors"); - b.HasIndex("GuildId") - .IsUnique() - .HasDatabaseName("ix_guildcolors_guildid"); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_guildcolors_guildid"); - b.ToTable("guildcolors", (string)null); - }); + b.ToTable("guildcolors", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.GuildConfig", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<string>("AutoAssignRoleIds") - .HasColumnType("text") - .HasColumnName("autoassignroleids"); + b.Property<string>("AutoAssignRoleIds") + .HasColumnType("text") + .HasColumnName("autoassignroleids"); - b.Property<bool>("AutoDeleteSelfAssignedRoleMessages") - .HasColumnType("boolean") - .HasColumnName("autodeleteselfassignedrolemessages"); + b.Property<bool>("CleverbotEnabled") + .HasColumnType("boolean") + .HasColumnName("cleverbotenabled"); - b.Property<bool>("CleverbotEnabled") - .HasColumnType("boolean") - .HasColumnName("cleverbotenabled"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<bool>("DeleteMessageOnCommand") + .HasColumnType("boolean") + .HasColumnName("deletemessageoncommand"); - b.Property<bool>("DeleteMessageOnCommand") - .HasColumnType("boolean") - .HasColumnName("deletemessageoncommand"); + b.Property<bool>("DeleteStreamOnlineMessage") + .HasColumnType("boolean") + .HasColumnName("deletestreamonlinemessage"); - b.Property<bool>("DeleteStreamOnlineMessage") - .HasColumnType("boolean") - .HasColumnName("deletestreamonlinemessage"); + b.Property<bool>("DisableGlobalExpressions") + .HasColumnType("boolean") + .HasColumnName("disableglobalexpressions"); - b.Property<bool>("DisableGlobalExpressions") - .HasColumnType("boolean") - .HasColumnName("disableglobalexpressions"); + b.Property<decimal?>("GameVoiceChannel") + .HasColumnType("numeric(20,0)") + .HasColumnName("gamevoicechannel"); - b.Property<bool>("ExclusiveSelfAssignedRoles") - .HasColumnType("boolean") - .HasColumnName("exclusiveselfassignedroles"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<bool>("FilterInvites") - .HasColumnType("boolean") - .HasColumnName("filterinvites"); + b.Property<string>("Locale") + .HasColumnType("text") + .HasColumnName("locale"); - b.Property<bool>("FilterLinks") - .HasColumnType("boolean") - .HasColumnName("filterlinks"); + b.Property<string>("MuteRoleName") + .HasColumnType("text") + .HasColumnName("muterolename"); - b.Property<bool>("FilterWords") - .HasColumnType("boolean") - .HasColumnName("filterwords"); + b.Property<bool>("NotifyStreamOffline") + .HasColumnType("boolean") + .HasColumnName("notifystreamoffline"); - b.Property<decimal?>("GameVoiceChannel") - .HasColumnType("numeric(20,0)") - .HasColumnName("gamevoicechannel"); + b.Property<string>("PermissionRole") + .HasColumnType("text") + .HasColumnName("permissionrole"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<string>("Prefix") + .HasColumnType("text") + .HasColumnName("prefix"); - b.Property<string>("Locale") - .HasColumnType("text") - .HasColumnName("locale"); + b.Property<bool>("StickyRoles") + .HasColumnType("boolean") + .HasColumnName("stickyroles"); - b.Property<string>("MuteRoleName") - .HasColumnType("text") - .HasColumnName("muterolename"); + b.Property<string>("TimeZoneId") + .HasColumnType("text") + .HasColumnName("timezoneid"); - b.Property<bool>("NotifyStreamOffline") - .HasColumnType("boolean") - .HasColumnName("notifystreamoffline"); + b.Property<bool>("VerboseErrors") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true) + .HasColumnName("verboseerrors"); - b.Property<string>("PermissionRole") - .HasColumnType("text") - .HasColumnName("permissionrole"); + b.Property<bool>("VerbosePermissions") + .HasColumnType("boolean") + .HasColumnName("verbosepermissions"); - b.Property<string>("Prefix") - .HasColumnType("text") - .HasColumnName("prefix"); + b.Property<int>("WarnExpireAction") + .HasColumnType("integer") + .HasColumnName("warnexpireaction"); - b.Property<bool>("StickyRoles") - .HasColumnType("boolean") - .HasColumnName("stickyroles"); + b.Property<int>("WarnExpireHours") + .HasColumnType("integer") + .HasColumnName("warnexpirehours"); - b.Property<string>("TimeZoneId") - .HasColumnType("text") - .HasColumnName("timezoneid"); + b.Property<bool>("WarningsInitialized") + .HasColumnType("boolean") + .HasColumnName("warningsinitialized"); - b.Property<bool>("VerboseErrors") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(true) - .HasColumnName("verboseerrors"); + b.HasKey("Id") + .HasName("pk_guildconfigs"); - b.Property<bool>("VerbosePermissions") - .HasColumnType("boolean") - .HasColumnName("verbosepermissions"); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_guildconfigs_guildid"); - b.Property<int>("WarnExpireAction") - .HasColumnType("integer") - .HasColumnName("warnexpireaction"); + b.HasIndex("WarnExpireHours") + .HasDatabaseName("ix_guildconfigs_warnexpirehours"); - b.Property<int>("WarnExpireHours") - .HasColumnType("integer") - .HasColumnName("warnexpirehours"); + b.ToTable("guildconfigs", (string)null); + }); - b.Property<bool>("WarningsInitialized") - .HasColumnType("boolean") - .HasColumnName("warningsinitialized"); + modelBuilder.Entity("EllieBot.Db.Models.GuildFilterConfig", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - b.HasKey("Id") - .HasName("pk_guildconfigs"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.HasIndex("GuildId") - .IsUnique() - .HasDatabaseName("ix_guildconfigs_guildid"); + b.Property<bool>("FilterInvites") + .HasColumnType("boolean") + .HasColumnName("filterinvites"); - b.HasIndex("WarnExpireHours") - .HasDatabaseName("ix_guildconfigs_warnexpirehours"); + b.Property<bool>("FilterLinks") + .HasColumnType("boolean") + .HasColumnName("filterlinks"); - b.ToTable("guildconfigs", (string)null); - }); + b.Property<bool>("FilterWords") + .HasColumnType("boolean") + .HasColumnName("filterwords"); + + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + + b.HasKey("Id") + .HasName("pk_guildfilterconfig"); + + b.HasIndex("GuildId") + .HasDatabaseName("ix_guildfilterconfig_guildid"); + + b.ToTable("guildfilterconfig", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.HoneypotChannel", b => - { - b.Property<decimal>("GuildId") - .ValueGeneratedOnAdd() - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + { + b.Property<decimal>("GuildId") + .ValueGeneratedOnAdd() + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.HasKey("GuildId") - .HasName("pk_honeypotchannels"); + b.HasKey("GuildId") + .HasName("pk_honeypotchannels"); - b.ToTable("honeypotchannels", (string)null); - }); + b.ToTable("honeypotchannels", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.IgnoredLogItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("ItemType") - .HasColumnType("integer") - .HasColumnName("itemtype"); + b.Property<int>("ItemType") + .HasColumnType("integer") + .HasColumnName("itemtype"); - b.Property<decimal>("LogItemId") - .HasColumnType("numeric(20,0)") - .HasColumnName("logitemid"); + b.Property<decimal>("LogItemId") + .HasColumnType("numeric(20,0)") + .HasColumnName("logitemid"); - b.Property<int>("LogSettingId") - .HasColumnType("integer") - .HasColumnName("logsettingid"); + b.Property<int>("LogSettingId") + .HasColumnType("integer") + .HasColumnName("logsettingid"); - b.HasKey("Id") - .HasName("pk_ignoredlogchannels"); + b.HasKey("Id") + .HasName("pk_ignoredlogchannels"); - b.HasIndex("LogSettingId", "LogItemId", "ItemType") - .IsUnique() - .HasDatabaseName("ix_ignoredlogchannels_logsettingid_logitemid_itemtype"); + b.HasIndex("LogSettingId", "LogItemId", "ItemType") + .IsUnique() + .HasDatabaseName("ix_ignoredlogchannels_logsettingid_logitemid_itemtype"); - b.ToTable("ignoredlogchannels", (string)null); - }); + b.ToTable("ignoredlogchannels", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ImageOnlyChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int>("Type") - .HasColumnType("integer") - .HasColumnName("type"); + b.Property<int>("Type") + .HasColumnType("integer") + .HasColumnName("type"); - b.HasKey("Id") - .HasName("pk_imageonlychannels"); + b.HasKey("Id") + .HasName("pk_imageonlychannels"); - b.HasIndex("ChannelId") - .IsUnique() - .HasDatabaseName("ix_imageonlychannels_channelid"); + b.HasIndex("ChannelId") + .IsUnique() + .HasDatabaseName("ix_imageonlychannels_channelid"); - b.ToTable("imageonlychannels", (string)null); - }); + b.ToTable("imageonlychannels", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.LogSetting", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal?>("ChannelCreatedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelcreatedid"); + b.Property<decimal?>("ChannelCreatedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelcreatedid"); - b.Property<decimal?>("ChannelDestroyedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channeldestroyedid"); + b.Property<decimal?>("ChannelDestroyedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channeldestroyedid"); - b.Property<decimal?>("ChannelUpdatedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelupdatedid"); + b.Property<decimal?>("ChannelUpdatedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelupdatedid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal?>("LogOtherId") - .HasColumnType("numeric(20,0)") - .HasColumnName("logotherid"); + b.Property<decimal?>("LogOtherId") + .HasColumnType("numeric(20,0)") + .HasColumnName("logotherid"); - b.Property<decimal?>("LogUserPresenceId") - .HasColumnType("numeric(20,0)") - .HasColumnName("loguserpresenceid"); + b.Property<decimal?>("LogUserPresenceId") + .HasColumnType("numeric(20,0)") + .HasColumnName("loguserpresenceid"); - b.Property<decimal?>("LogVoicePresenceId") - .HasColumnType("numeric(20,0)") - .HasColumnName("logvoicepresenceid"); + b.Property<decimal?>("LogVoicePresenceId") + .HasColumnType("numeric(20,0)") + .HasColumnName("logvoicepresenceid"); - b.Property<decimal?>("LogVoicePresenceTTSId") - .HasColumnType("numeric(20,0)") - .HasColumnName("logvoicepresencettsid"); + b.Property<decimal?>("LogVoicePresenceTTSId") + .HasColumnType("numeric(20,0)") + .HasColumnName("logvoicepresencettsid"); - b.Property<decimal?>("LogWarnsId") - .HasColumnType("numeric(20,0)") - .HasColumnName("logwarnsid"); + b.Property<decimal?>("LogWarnsId") + .HasColumnType("numeric(20,0)") + .HasColumnName("logwarnsid"); - b.Property<decimal?>("MessageDeletedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("messagedeletedid"); + b.Property<decimal?>("MessageDeletedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("messagedeletedid"); - b.Property<decimal?>("MessageUpdatedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("messageupdatedid"); + b.Property<decimal?>("MessageUpdatedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("messageupdatedid"); - b.Property<decimal?>("ThreadCreatedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("threadcreatedid"); + b.Property<decimal?>("ThreadCreatedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("threadcreatedid"); - b.Property<decimal?>("ThreadDeletedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("threaddeletedid"); + b.Property<decimal?>("ThreadDeletedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("threaddeletedid"); - b.Property<decimal?>("UserBannedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userbannedid"); + b.Property<decimal?>("UserBannedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userbannedid"); - b.Property<decimal?>("UserJoinedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userjoinedid"); + b.Property<decimal?>("UserJoinedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userjoinedid"); - b.Property<decimal?>("UserLeftId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userleftid"); + b.Property<decimal?>("UserLeftId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userleftid"); - b.Property<decimal?>("UserMutedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("usermutedid"); + b.Property<decimal?>("UserMutedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("usermutedid"); - b.Property<decimal?>("UserUnbannedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userunbannedid"); + b.Property<decimal?>("UserUnbannedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userunbannedid"); - b.Property<decimal?>("UserUpdatedId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userupdatedid"); + b.Property<decimal?>("UserUpdatedId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userupdatedid"); - b.HasKey("Id") - .HasName("pk_logsettings"); + b.HasKey("Id") + .HasName("pk_logsettings"); - b.HasIndex("GuildId") - .IsUnique() - .HasDatabaseName("ix_logsettings_guildid"); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_logsettings_guildid"); - b.ToTable("logsettings", (string)null); - }); + b.ToTable("logsettings", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.MusicPlayerSettings", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<bool>("AutoDisconnect") - .HasColumnType("boolean") - .HasColumnName("autodisconnect"); + b.Property<bool>("AutoDisconnect") + .HasColumnType("boolean") + .HasColumnName("autodisconnect"); - b.Property<bool>("AutoPlay") - .HasColumnType("boolean") - .HasColumnName("autoplay"); + b.Property<bool>("AutoPlay") + .HasColumnType("boolean") + .HasColumnName("autoplay"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal?>("MusicChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("musicchannelid"); + b.Property<decimal?>("MusicChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("musicchannelid"); - b.Property<int>("PlayerRepeat") - .HasColumnType("integer") - .HasColumnName("playerrepeat"); + b.Property<int>("PlayerRepeat") + .HasColumnType("integer") + .HasColumnName("playerrepeat"); - b.Property<int>("QualityPreset") - .HasColumnType("integer") - .HasColumnName("qualitypreset"); + b.Property<int>("QualityPreset") + .HasColumnType("integer") + .HasColumnName("qualitypreset"); - b.Property<int>("Volume") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasDefaultValue(100) - .HasColumnName("volume"); + b.Property<int>("Volume") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(100) + .HasColumnName("volume"); - b.HasKey("Id") - .HasName("pk_musicplayersettings"); + b.HasKey("Id") + .HasName("pk_musicplayersettings"); - b.HasIndex("GuildId") - .IsUnique() - .HasDatabaseName("ix_musicplayersettings_guildid"); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_musicplayersettings_guildid"); - b.ToTable("musicplayersettings", (string)null); - }); + b.ToTable("musicplayersettings", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.MusicPlaylist", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<string>("Author") - .HasColumnType("text") - .HasColumnName("author"); + b.Property<string>("Author") + .HasColumnType("text") + .HasColumnName("author"); - b.Property<decimal>("AuthorId") - .HasColumnType("numeric(20,0)") - .HasColumnName("authorid"); + b.Property<decimal>("AuthorId") + .HasColumnType("numeric(20,0)") + .HasColumnName("authorid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); + b.Property<string>("Name") + .HasColumnType("text") + .HasColumnName("name"); - b.HasKey("Id") - .HasName("pk_musicplaylists"); + b.HasKey("Id") + .HasName("pk_musicplaylists"); - b.ToTable("musicplaylists", (string)null); - }); + b.ToTable("musicplaylists", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.MutedUserId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_muteduserid"); + b.HasKey("Id") + .HasName("pk_muteduserid"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_muteduserid_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_muteduserid_guildid_userid"); - b.ToTable("muteduserid", (string)null); - }); + b.ToTable("muteduserid", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.NCPixel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<long>("Color") - .HasColumnType("bigint") - .HasColumnName("color"); + b.Property<long>("Color") + .HasColumnType("bigint") + .HasColumnName("color"); - b.Property<decimal>("OwnerId") - .HasColumnType("numeric(20,0)") - .HasColumnName("ownerid"); + b.Property<decimal>("OwnerId") + .HasColumnType("numeric(20,0)") + .HasColumnName("ownerid"); - b.Property<int>("Position") - .HasColumnType("integer") - .HasColumnName("position"); + b.Property<int>("Position") + .HasColumnType("integer") + .HasColumnName("position"); - b.Property<long>("Price") - .HasColumnType("bigint") - .HasColumnName("price"); + b.Property<long>("Price") + .HasColumnType("bigint") + .HasColumnName("price"); - b.Property<string>("Text") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("text"); + b.Property<string>("Text") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)") + .HasColumnName("text"); - b.HasKey("Id") - .HasName("pk_ncpixel"); + b.HasKey("Id") + .HasName("pk_ncpixel"); - b.HasAlternateKey("Position") - .HasName("ak_ncpixel_position"); + b.HasAlternateKey("Position") + .HasName("ak_ncpixel_position"); - b.HasIndex("OwnerId") - .HasDatabaseName("ix_ncpixel_ownerid"); + b.HasIndex("OwnerId") + .HasDatabaseName("ix_ncpixel_ownerid"); - b.ToTable("ncpixel", (string)null); - }); + b.ToTable("ncpixel", (string)null); + }); + + modelBuilder.Entity("EllieBot.Db.Models.EllieExpression", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + + b.Property<bool>("AllowTarget") + .HasColumnType("boolean") + .HasColumnName("allowtarget"); + + b.Property<bool>("AutoDeleteTrigger") + .HasColumnType("boolean") + .HasColumnName("autodeletetrigger"); + + b.Property<bool>("ContainsAnywhere") + .HasColumnType("boolean") + .HasColumnName("containsanywhere"); + + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); + + b.Property<bool>("DmResponse") + .HasColumnType("boolean") + .HasColumnName("dmresponse"); + + b.Property<decimal?>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); + + b.Property<string>("Reactions") + .HasColumnType("text") + .HasColumnName("reactions"); + + b.Property<string>("Response") + .HasColumnType("text") + .HasColumnName("response"); + + b.Property<string>("Trigger") + .HasColumnType("text") + .HasColumnName("trigger"); + + b.HasKey("Id") + .HasName("pk_expressions"); + + b.ToTable("expressions", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.Notify", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("Message") - .IsRequired() - .HasMaxLength(10000) - .HasColumnType("character varying(10000)") - .HasColumnName("message"); + b.Property<string>("Message") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("character varying(10000)") + .HasColumnName("message"); - b.Property<int>("Type") - .HasColumnType("integer") - .HasColumnName("type"); + b.Property<int>("Type") + .HasColumnType("integer") + .HasColumnName("type"); - b.HasKey("Id") - .HasName("pk_notify"); + b.HasKey("Id") + .HasName("pk_notify"); - b.HasAlternateKey("GuildId", "Type") - .HasName("ak_notify_guildid_type"); + b.HasAlternateKey("GuildId", "Type") + .HasName("ak_notify_guildid_type"); - b.ToTable("notify", (string)null); - }); + b.ToTable("notify", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.PatronUser", b => - { - b.Property<decimal>("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + { + b.Property<decimal>("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.Property<int>("AmountCents") - .HasColumnType("integer") - .HasColumnName("amountcents"); + b.Property<int>("AmountCents") + .HasColumnType("integer") + .HasColumnName("amountcents"); - b.Property<DateTime>("LastCharge") - .HasColumnType("timestamp without time zone") - .HasColumnName("lastcharge"); + b.Property<DateTime>("LastCharge") + .HasColumnType("timestamp without time zone") + .HasColumnName("lastcharge"); - b.Property<string>("UniquePlatformUserId") - .HasColumnType("text") - .HasColumnName("uniqueplatformuserid"); + b.Property<string>("UniquePlatformUserId") + .HasColumnType("text") + .HasColumnName("uniqueplatformuserid"); - b.Property<DateTime>("ValidThru") - .HasColumnType("timestamp without time zone") - .HasColumnName("validthru"); + b.Property<DateTime>("ValidThru") + .HasColumnType("timestamp without time zone") + .HasColumnName("validthru"); - b.HasKey("UserId") - .HasName("pk_patrons"); + b.HasKey("UserId") + .HasName("pk_patrons"); - b.HasIndex("UniquePlatformUserId") - .IsUnique() - .HasDatabaseName("ix_patrons_uniqueplatformuserid"); + b.HasIndex("UniquePlatformUserId") + .IsUnique() + .HasDatabaseName("ix_patrons_uniqueplatformuserid"); - b.ToTable("patrons", (string)null); - }); + b.ToTable("patrons", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.Permissionv2", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int?>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); - b.Property<int>("Index") - .HasColumnType("integer") - .HasColumnName("index"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<bool>("IsCustomCommand") - .HasColumnType("boolean") - .HasColumnName("iscustomcommand"); + b.Property<int>("Index") + .HasColumnType("integer") + .HasColumnName("index"); - b.Property<int>("PrimaryTarget") - .HasColumnType("integer") - .HasColumnName("primarytarget"); + b.Property<bool>("IsCustomCommand") + .HasColumnType("boolean") + .HasColumnName("iscustomcommand"); - b.Property<decimal>("PrimaryTargetId") - .HasColumnType("numeric(20,0)") - .HasColumnName("primarytargetid"); + b.Property<int>("PrimaryTarget") + .HasColumnType("integer") + .HasColumnName("primarytarget"); - b.Property<int>("SecondaryTarget") - .HasColumnType("integer") - .HasColumnName("secondarytarget"); + b.Property<decimal>("PrimaryTargetId") + .HasColumnType("numeric(20,0)") + .HasColumnName("primarytargetid"); - b.Property<string>("SecondaryTargetName") - .HasColumnType("text") - .HasColumnName("secondarytargetname"); + b.Property<int>("SecondaryTarget") + .HasColumnType("integer") + .HasColumnName("secondarytarget"); - b.Property<bool>("State") - .HasColumnType("boolean") - .HasColumnName("state"); + b.Property<string>("SecondaryTargetName") + .HasColumnType("text") + .HasColumnName("secondarytargetname"); - b.HasKey("Id") - .HasName("pk_permissions"); + b.Property<bool>("State") + .HasColumnType("boolean") + .HasColumnName("state"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_permissions_guildconfigid"); + b.HasKey("Id") + .HasName("pk_permissions"); - b.ToTable("permissions", (string)null); - }); + b.HasIndex("GuildConfigId") + .HasDatabaseName("ix_permissions_guildconfigid"); + + b.HasIndex("GuildId") + .HasDatabaseName("ix_permissions_guildid"); + + b.ToTable("permissions", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.PlantedCurrency", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<long>("Amount") - .HasColumnType("bigint") - .HasColumnName("amount"); + b.Property<long>("Amount") + .HasColumnType("bigint") + .HasColumnName("amount"); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal>("MessageId") - .HasColumnType("numeric(20,0)") - .HasColumnName("messageid"); + b.Property<decimal>("MessageId") + .HasColumnType("numeric(20,0)") + .HasColumnName("messageid"); - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); + b.Property<string>("Password") + .HasColumnType("text") + .HasColumnName("password"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_plantedcurrency"); + b.HasKey("Id") + .HasName("pk_plantedcurrency"); - b.HasIndex("ChannelId") - .HasDatabaseName("ix_plantedcurrency_channelid"); + b.HasIndex("ChannelId") + .HasDatabaseName("ix_plantedcurrency_channelid"); - b.HasIndex("MessageId") - .IsUnique() - .HasDatabaseName("ix_plantedcurrency_messageid"); + b.HasIndex("MessageId") + .IsUnique() + .HasDatabaseName("ix_plantedcurrency_messageid"); - b.ToTable("plantedcurrency", (string)null); - }); + b.ToTable("plantedcurrency", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.PlaylistSong", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("MusicPlaylistId") - .HasColumnType("integer") - .HasColumnName("musicplaylistid"); + b.Property<int?>("MusicPlaylistId") + .HasColumnType("integer") + .HasColumnName("musicplaylistid"); - b.Property<string>("Provider") - .HasColumnType("text") - .HasColumnName("provider"); + b.Property<string>("Provider") + .HasColumnType("text") + .HasColumnName("provider"); - b.Property<int>("ProviderType") - .HasColumnType("integer") - .HasColumnName("providertype"); + b.Property<int>("ProviderType") + .HasColumnType("integer") + .HasColumnName("providertype"); - b.Property<string>("Query") - .HasColumnType("text") - .HasColumnName("query"); + b.Property<string>("Query") + .HasColumnType("text") + .HasColumnName("query"); - b.Property<string>("Title") - .HasColumnType("text") - .HasColumnName("title"); + b.Property<string>("Title") + .HasColumnType("text") + .HasColumnName("title"); - b.Property<string>("Uri") - .HasColumnType("text") - .HasColumnName("uri"); + b.Property<string>("Uri") + .HasColumnType("text") + .HasColumnName("uri"); - b.HasKey("Id") - .HasName("pk_playlistsong"); + b.HasKey("Id") + .HasName("pk_playlistsong"); - b.HasIndex("MusicPlaylistId") - .HasDatabaseName("ix_playlistsong_musicplaylistid"); + b.HasIndex("MusicPlaylistId") + .HasDatabaseName("ix_playlistsong_musicplaylistid"); - b.ToTable("playlistsong", (string)null); - }); + b.ToTable("playlistsong", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.Quote", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("AuthorId") - .HasColumnType("numeric(20,0)") - .HasColumnName("authorid"); + b.Property<decimal>("AuthorId") + .HasColumnType("numeric(20,0)") + .HasColumnName("authorid"); - b.Property<string>("AuthorName") - .IsRequired() - .HasColumnType("text") - .HasColumnName("authorname"); + b.Property<string>("AuthorName") + .IsRequired() + .HasColumnType("text") + .HasColumnName("authorname"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("Keyword") - .IsRequired() - .HasColumnType("text") - .HasColumnName("keyword"); + b.Property<string>("Keyword") + .IsRequired() + .HasColumnType("text") + .HasColumnName("keyword"); - b.Property<string>("Text") - .IsRequired() - .HasColumnType("text") - .HasColumnName("text"); + b.Property<string>("Text") + .IsRequired() + .HasColumnType("text") + .HasColumnName("text"); - b.HasKey("Id") - .HasName("pk_quotes"); + b.HasKey("Id") + .HasName("pk_quotes"); - b.HasIndex("GuildId") - .HasDatabaseName("ix_quotes_guildid"); + b.HasIndex("GuildId") + .HasDatabaseName("ix_quotes_guildid"); - b.HasIndex("Keyword") - .HasDatabaseName("ix_quotes_keyword"); + b.HasIndex("Keyword") + .HasDatabaseName("ix_quotes_keyword"); - b.ToTable("quotes", (string)null); - }); + b.ToTable("quotes", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ReactionRoleV2", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<string>("Emote") - .HasMaxLength(100) - .HasColumnType("character varying(100)") - .HasColumnName("emote"); + b.Property<string>("Emote") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("emote"); - b.Property<int>("Group") - .HasColumnType("integer") - .HasColumnName("group"); + b.Property<int>("Group") + .HasColumnType("integer") + .HasColumnName("group"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int>("LevelReq") - .HasColumnType("integer") - .HasColumnName("levelreq"); + b.Property<int>("LevelReq") + .HasColumnType("integer") + .HasColumnName("levelreq"); - b.Property<decimal>("MessageId") - .HasColumnType("numeric(20,0)") - .HasColumnName("messageid"); + b.Property<decimal>("MessageId") + .HasColumnType("numeric(20,0)") + .HasColumnName("messageid"); - b.Property<decimal>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.HasKey("Id") - .HasName("pk_reactionroles"); + b.HasKey("Id") + .HasName("pk_reactionroles"); - b.HasIndex("GuildId") - .HasDatabaseName("ix_reactionroles_guildid"); + b.HasIndex("GuildId") + .HasDatabaseName("ix_reactionroles_guildid"); - b.HasIndex("MessageId", "Emote") - .IsUnique() - .HasDatabaseName("ix_reactionroles_messageid_emote"); + b.HasIndex("MessageId", "Emote") + .IsUnique() + .HasDatabaseName("ix_reactionroles_messageid_emote"); - b.ToTable("reactionroles", (string)null); - }); + b.ToTable("reactionroles", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.Reminder", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<bool>("IsPrivate") - .HasColumnType("boolean") - .HasColumnName("isprivate"); + b.Property<bool>("IsPrivate") + .HasColumnType("boolean") + .HasColumnName("isprivate"); - b.Property<string>("Message") - .HasColumnType("text") - .HasColumnName("message"); + b.Property<string>("Message") + .HasColumnType("text") + .HasColumnName("message"); - b.Property<decimal>("ServerId") - .HasColumnType("numeric(20,0)") - .HasColumnName("serverid"); + b.Property<decimal>("ServerId") + .HasColumnType("numeric(20,0)") + .HasColumnName("serverid"); - b.Property<int>("Type") - .HasColumnType("integer") - .HasColumnName("type"); + b.Property<int>("Type") + .HasColumnType("integer") + .HasColumnName("type"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.Property<DateTime>("When") - .HasColumnType("timestamp without time zone") - .HasColumnName("when"); + b.Property<DateTime>("When") + .HasColumnType("timestamp without time zone") + .HasColumnName("when"); - b.HasKey("Id") - .HasName("pk_reminders"); + b.HasKey("Id") + .HasName("pk_reminders"); - b.HasIndex("When") - .HasDatabaseName("ix_reminders_when"); + b.HasIndex("When") + .HasDatabaseName("ix_reminders_when"); - b.ToTable("reminders", (string)null); - }); + b.ToTable("reminders", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.Repeater", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<TimeSpan>("Interval") - .HasColumnType("interval") - .HasColumnName("interval"); + b.Property<TimeSpan>("Interval") + .HasColumnType("interval") + .HasColumnName("interval"); - b.Property<decimal?>("LastMessageId") - .HasColumnType("numeric(20,0)") - .HasColumnName("lastmessageid"); + b.Property<decimal?>("LastMessageId") + .HasColumnType("numeric(20,0)") + .HasColumnName("lastmessageid"); - b.Property<string>("Message") - .HasColumnType("text") - .HasColumnName("message"); + b.Property<string>("Message") + .HasColumnType("text") + .HasColumnName("message"); - b.Property<bool>("NoRedundant") - .HasColumnType("boolean") - .HasColumnName("noredundant"); + b.Property<bool>("NoRedundant") + .HasColumnType("boolean") + .HasColumnName("noredundant"); - b.Property<TimeSpan?>("StartTimeOfDay") - .HasColumnType("interval") - .HasColumnName("starttimeofday"); + b.Property<TimeSpan?>("StartTimeOfDay") + .HasColumnType("interval") + .HasColumnName("starttimeofday"); - b.HasKey("Id") - .HasName("pk_repeaters"); + b.HasKey("Id") + .HasName("pk_repeaters"); - b.ToTable("repeaters", (string)null); - }); + b.ToTable("repeaters", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.RewardedUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<long>("AmountRewardedThisMonth") - .HasColumnType("bigint") - .HasColumnName("amountrewardedthismonth"); + b.Property<long>("AmountRewardedThisMonth") + .HasColumnType("bigint") + .HasColumnName("amountrewardedthismonth"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<DateTime>("LastReward") - .HasColumnType("timestamp without time zone") - .HasColumnName("lastreward"); + b.Property<DateTime>("LastReward") + .HasColumnType("timestamp without time zone") + .HasColumnName("lastreward"); - b.Property<string>("PlatformUserId") - .HasColumnType("text") - .HasColumnName("platformuserid"); + b.Property<string>("PlatformUserId") + .HasColumnType("text") + .HasColumnName("platformuserid"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_rewardedusers"); + b.HasKey("Id") + .HasName("pk_rewardedusers"); - b.HasIndex("PlatformUserId") - .IsUnique() - .HasDatabaseName("ix_rewardedusers_platformuserid"); + b.HasIndex("PlatformUserId") + .IsUnique() + .HasDatabaseName("ix_rewardedusers_platformuserid"); - b.ToTable("rewardedusers", (string)null); - }); + b.ToTable("rewardedusers", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.RotatingPlayingStatus", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<string>("Status") - .HasColumnType("text") - .HasColumnName("status"); + b.Property<string>("Status") + .HasColumnType("text") + .HasColumnName("status"); - b.Property<int>("Type") - .HasColumnType("integer") - .HasColumnName("type"); + b.Property<int>("Type") + .HasColumnType("integer") + .HasColumnName("type"); - b.HasKey("Id") - .HasName("pk_rotatingstatus"); + b.HasKey("Id") + .HasName("pk_rotatingstatus"); - b.ToTable("rotatingstatus", (string)null); - }); + b.ToTable("rotatingstatus", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.Sar", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int>("LevelReq") - .HasColumnType("integer") - .HasColumnName("levelreq"); + b.Property<int>("LevelReq") + .HasColumnType("integer") + .HasColumnName("levelreq"); - b.Property<decimal>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.Property<int>("SarGroupId") - .HasColumnType("integer") - .HasColumnName("sargroupid"); + b.Property<int>("SarGroupId") + .HasColumnType("integer") + .HasColumnName("sargroupid"); - b.HasKey("Id") - .HasName("pk_sar"); + b.HasKey("Id") + .HasName("pk_sar"); - b.HasAlternateKey("GuildId", "RoleId") - .HasName("ak_sar_guildid_roleid"); + b.HasAlternateKey("GuildId", "RoleId") + .HasName("ak_sar_guildid_roleid"); - b.HasIndex("SarGroupId") - .HasDatabaseName("ix_sar_sargroupid"); + b.HasIndex("SarGroupId") + .HasDatabaseName("ix_sar_sargroupid"); - b.ToTable("sar", (string)null); - }); + b.ToTable("sar", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.SarAutoDelete", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<bool>("IsEnabled") - .HasColumnType("boolean") - .HasColumnName("isenabled"); + b.Property<bool>("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("isenabled"); - b.HasKey("Id") - .HasName("pk_sarautodelete"); + b.HasKey("Id") + .HasName("pk_sarautodelete"); - b.HasIndex("GuildId") - .IsUnique() - .HasDatabaseName("ix_sarautodelete_guildid"); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_sarautodelete_guildid"); - b.ToTable("sarautodelete", (string)null); - }); + b.ToTable("sarautodelete", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.SarGroup", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("GroupNumber") - .HasColumnType("integer") - .HasColumnName("groupnumber"); + b.Property<int>("GroupNumber") + .HasColumnType("integer") + .HasColumnName("groupnumber"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<bool>("IsExclusive") - .HasColumnType("boolean") - .HasColumnName("isexclusive"); + b.Property<bool>("IsExclusive") + .HasColumnType("boolean") + .HasColumnName("isexclusive"); - b.Property<string>("Name") - .HasMaxLength(100) - .HasColumnType("character varying(100)") - .HasColumnName("name"); + b.Property<string>("Name") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); - b.Property<decimal?>("RoleReq") - .HasColumnType("numeric(20,0)") - .HasColumnName("rolereq"); + b.Property<decimal?>("RoleReq") + .HasColumnType("numeric(20,0)") + .HasColumnName("rolereq"); - b.HasKey("Id") - .HasName("pk_sargroup"); + b.HasKey("Id") + .HasName("pk_sargroup"); - b.HasAlternateKey("GuildId", "GroupNumber") - .HasName("ak_sargroup_guildid_groupnumber"); + b.HasAlternateKey("GuildId", "GroupNumber") + .HasName("ak_sargroup_guildid_groupnumber"); - b.ToTable("sargroup", (string)null); - }); + b.ToTable("sargroup", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ShopEntry", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("AuthorId") - .HasColumnType("numeric(20,0)") - .HasColumnName("authorid"); + b.Property<decimal>("AuthorId") + .HasColumnType("numeric(20,0)") + .HasColumnName("authorid"); - b.Property<string>("Command") - .HasColumnType("text") - .HasColumnName("command"); + b.Property<string>("Command") + .HasColumnType("text") + .HasColumnName("command"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int>("Index") - .HasColumnType("integer") - .HasColumnName("index"); + b.Property<int>("Index") + .HasColumnType("integer") + .HasColumnName("index"); - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); + b.Property<string>("Name") + .HasColumnType("text") + .HasColumnName("name"); - b.Property<int>("Price") - .HasColumnType("integer") - .HasColumnName("price"); + b.Property<int>("Price") + .HasColumnType("integer") + .HasColumnName("price"); - b.Property<decimal>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.Property<string>("RoleName") - .HasColumnType("text") - .HasColumnName("rolename"); + b.Property<string>("RoleName") + .HasColumnType("text") + .HasColumnName("rolename"); - b.Property<decimal?>("RoleRequirement") - .HasColumnType("numeric(20,0)") - .HasColumnName("rolerequirement"); + b.Property<decimal?>("RoleRequirement") + .HasColumnType("numeric(20,0)") + .HasColumnName("rolerequirement"); - b.Property<int>("Type") - .HasColumnType("integer") - .HasColumnName("type"); + b.Property<int>("Type") + .HasColumnType("integer") + .HasColumnName("type"); - b.HasKey("Id") - .HasName("pk_shopentry"); + b.HasKey("Id") + .HasName("pk_shopentry"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_shopentry_guildconfigid"); + b.HasIndex("GuildId", "Index") + .IsUnique() + .HasDatabaseName("ix_shopentry_guildid_index"); - b.ToTable("shopentry", (string)null); - }); + b.ToTable("shopentry", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.ShopEntryItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("ShopEntryId") - .HasColumnType("integer") - .HasColumnName("shopentryid"); + b.Property<int?>("ShopEntryId") + .HasColumnType("integer") + .HasColumnName("shopentryid"); - b.Property<string>("Text") - .HasColumnType("text") - .HasColumnName("text"); + b.Property<string>("Text") + .HasColumnType("text") + .HasColumnName("text"); - b.HasKey("Id") - .HasName("pk_shopentryitem"); + b.HasKey("Id") + .HasName("pk_shopentryitem"); - b.HasIndex("ShopEntryId") - .HasDatabaseName("ix_shopentryitem_shopentryid"); + b.HasIndex("ShopEntryId") + .HasDatabaseName("ix_shopentryitem_shopentryid"); - b.ToTable("shopentryitem", (string)null); - }); + b.ToTable("shopentryitem", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredRole", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.HasKey("Id") - .HasName("pk_slowmodeignoredrole"); + b.HasKey("Id") + .HasName("pk_slowmodeignoredrole"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_slowmodeignoredrole_guildconfigid"); + b.HasIndex("GuildId", "RoleId") + .IsUnique() + .HasDatabaseName("ix_slowmodeignoredrole_guildid_roleid"); - b.ToTable("slowmodeignoredrole", (string)null); - }); + b.ToTable("slowmodeignoredrole", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_slowmodeignoreduser"); + b.HasKey("Id") + .HasName("pk_slowmodeignoreduser"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_slowmodeignoreduser_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_slowmodeignoreduser_guildid_userid"); - b.ToTable("slowmodeignoreduser", (string)null); - }); + b.ToTable("slowmodeignoreduser", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.StickyRole", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("RoleIds") - .HasColumnType("text") - .HasColumnName("roleids"); + b.Property<string>("RoleIds") + .HasColumnType("text") + .HasColumnName("roleids"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_stickyroles"); + b.HasKey("Id") + .HasName("pk_stickyroles"); - b.HasIndex("GuildId", "UserId") - .IsUnique() - .HasDatabaseName("ix_stickyroles_guildid_userid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_stickyroles_guildid_userid"); - b.ToTable("stickyroles", (string)null); - }); + b.ToTable("stickyroles", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamOnlineMessage", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("MessageId") - .HasColumnType("numeric(20,0)") - .HasColumnName("messageid"); + b.Property<decimal>("MessageId") + .HasColumnType("numeric(20,0)") + .HasColumnName("messageid"); - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); + b.Property<string>("Name") + .HasColumnType("text") + .HasColumnName("name"); - b.Property<int>("Type") - .HasColumnType("integer") - .HasColumnName("type"); + b.Property<int>("Type") + .HasColumnType("integer") + .HasColumnName("type"); - b.HasKey("Id") - .HasName("pk_streamonlinemessages"); + b.HasKey("Id") + .HasName("pk_streamonlinemessages"); - b.ToTable("streamonlinemessages", (string)null); - }); + b.ToTable("streamonlinemessages", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleBlacklistedUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("StreamRoleSettingsId") - .HasColumnType("integer") - .HasColumnName("streamrolesettingsid"); + b.Property<int>("StreamRoleSettingsId") + .HasColumnType("integer") + .HasColumnName("streamrolesettingsid"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); + b.Property<string>("Username") + .HasColumnType("text") + .HasColumnName("username"); - b.HasKey("Id") - .HasName("pk_streamroleblacklisteduser"); + b.HasKey("Id") + .HasName("pk_streamroleblacklisteduser"); - b.HasIndex("StreamRoleSettingsId") - .HasDatabaseName("ix_streamroleblacklisteduser_streamrolesettingsid"); + b.HasIndex("StreamRoleSettingsId") + .HasDatabaseName("ix_streamroleblacklisteduser_streamrolesettingsid"); - b.ToTable("streamroleblacklisteduser", (string)null); - }); + b.ToTable("streamroleblacklisteduser", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleSettings", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<decimal>("AddRoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("addroleid"); + b.Property<decimal>("AddRoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("addroleid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<bool>("Enabled") - .HasColumnType("boolean") - .HasColumnName("enabled"); + b.Property<bool>("Enabled") + .HasColumnType("boolean") + .HasColumnName("enabled"); - b.Property<decimal>("FromRoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("fromroleid"); + b.Property<decimal>("FromRoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("fromroleid"); - b.Property<int>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); - b.Property<string>("Keyword") - .HasColumnType("text") - .HasColumnName("keyword"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.HasKey("Id") - .HasName("pk_streamrolesettings"); + b.Property<string>("Keyword") + .HasColumnType("text") + .HasColumnName("keyword"); - b.HasIndex("GuildConfigId") - .IsUnique() - .HasDatabaseName("ix_streamrolesettings_guildconfigid"); + b.HasKey("Id") + .HasName("pk_streamrolesettings"); - b.ToTable("streamrolesettings", (string)null); - }); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_streamrolesettings_guildid"); + + b.ToTable("streamrolesettings", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleWhitelistedUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("StreamRoleSettingsId") - .HasColumnType("integer") - .HasColumnName("streamrolesettingsid"); + b.Property<int>("StreamRoleSettingsId") + .HasColumnType("integer") + .HasColumnName("streamrolesettingsid"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); + b.Property<string>("Username") + .HasColumnType("text") + .HasColumnName("username"); - b.HasKey("Id") - .HasName("pk_streamrolewhitelisteduser"); + b.HasKey("Id") + .HasName("pk_streamrolewhitelisteduser"); - b.HasIndex("StreamRoleSettingsId") - .HasDatabaseName("ix_streamrolewhitelisteduser_streamrolesettingsid"); + b.HasIndex("StreamRoleSettingsId") + .HasDatabaseName("ix_streamrolewhitelisteduser_streamrolesettingsid"); - b.ToTable("streamrolewhitelisteduser", (string)null); - }); + b.ToTable("streamrolewhitelisteduser", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.TempRole", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime>("ExpiresAt") - .HasColumnType("timestamp without time zone") - .HasColumnName("expiresat"); + b.Property<DateTime>("ExpiresAt") + .HasColumnType("timestamp without time zone") + .HasColumnName("expiresat"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<bool>("Remove") - .HasColumnType("boolean") - .HasColumnName("remove"); + b.Property<bool>("Remove") + .HasColumnType("boolean") + .HasColumnName("remove"); - b.Property<decimal>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_temprole"); + b.HasKey("Id") + .HasName("pk_temprole"); - b.HasAlternateKey("GuildId", "UserId", "RoleId") - .HasName("ak_temprole_guildid_userid_roleid"); + b.HasAlternateKey("GuildId", "UserId", "RoleId") + .HasName("ak_temprole_guildid_userid_roleid"); - b.HasIndex("ExpiresAt") - .HasDatabaseName("ix_temprole_expiresat"); + b.HasIndex("ExpiresAt") + .HasDatabaseName("ix_temprole_expiresat"); - b.ToTable("temprole", (string)null); - }); + b.ToTable("temprole", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.TodoModel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int?>("ArchiveId") - .HasColumnType("integer") - .HasColumnName("archiveid"); + b.Property<int?>("ArchiveId") + .HasColumnType("integer") + .HasColumnName("archiveid"); - b.Property<DateTime>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<bool>("IsDone") - .HasColumnType("boolean") - .HasColumnName("isdone"); + b.Property<bool>("IsDone") + .HasColumnType("boolean") + .HasColumnName("isdone"); - b.Property<string>("Todo") - .HasColumnType("text") - .HasColumnName("todo"); + b.Property<string>("Todo") + .HasColumnType("text") + .HasColumnName("todo"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_todos"); + b.HasKey("Id") + .HasName("pk_todos"); - b.HasIndex("ArchiveId") - .HasDatabaseName("ix_todos_archiveid"); + b.HasIndex("ArchiveId") + .HasDatabaseName("ix_todos_archiveid"); - b.HasIndex("UserId") - .HasDatabaseName("ix_todos_userid"); + b.HasIndex("UserId") + .HasDatabaseName("ix_todos_userid"); - b.ToTable("todos", (string)null); - }); + b.ToTable("todos", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.UnbanTimer", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<DateTime>("UnbanAt") - .HasColumnType("timestamp without time zone") - .HasColumnName("unbanat"); + b.Property<DateTime>("UnbanAt") + .HasColumnType("timestamp without time zone") + .HasColumnName("unbanat"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_unbantimer"); + b.HasKey("Id") + .HasName("pk_unbantimer"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_unbantimer_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_unbantimer_guildid_userid"); - b.ToTable("unbantimer", (string)null); - }); + b.ToTable("unbantimer", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.UnmuteTimer", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<DateTime>("UnmuteAt") - .HasColumnType("timestamp without time zone") - .HasColumnName("unmuteat"); + b.Property<DateTime>("UnmuteAt") + .HasColumnType("timestamp without time zone") + .HasColumnName("unmuteat"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_unmutetimer"); + b.HasKey("Id") + .HasName("pk_unmutetimer"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_unmutetimer_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_unmutetimer_guildid_userid"); - b.ToTable("unmutetimer", (string)null); - }); + b.ToTable("unmutetimer", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.UnroleTimer", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.Property<DateTime>("UnbanAt") - .HasColumnType("timestamp without time zone") - .HasColumnName("unbanat"); + b.Property<DateTime>("UnbanAt") + .HasColumnType("timestamp without time zone") + .HasColumnName("unbanat"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_unroletimer"); + b.HasKey("Id") + .HasName("pk_unroletimer"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_unroletimer_guildconfigid"); + b.HasIndex("GuildId", "UserId") + .IsUnique() + .HasDatabaseName("ix_unroletimer_guildid_userid"); - b.ToTable("unroletimer", (string)null); - }); + b.ToTable("unroletimer", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.UserXpStats", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.Property<long>("Xp") - .HasColumnType("bigint") - .HasColumnName("xp"); + b.Property<long>("Xp") + .HasColumnType("bigint") + .HasColumnName("xp"); - b.HasKey("Id") - .HasName("pk_userxpstats"); + b.HasKey("Id") + .HasName("pk_userxpstats"); - b.HasIndex("GuildId") - .HasDatabaseName("ix_userxpstats_guildid"); + b.HasIndex("GuildId") + .HasDatabaseName("ix_userxpstats_guildid"); - b.HasIndex("UserId") - .HasDatabaseName("ix_userxpstats_userid"); + b.HasIndex("UserId") + .HasDatabaseName("ix_userxpstats_userid"); - b.HasIndex("Xp") - .HasDatabaseName("ix_userxpstats_xp"); + b.HasIndex("Xp") + .HasDatabaseName("ix_userxpstats_xp"); - b.HasIndex("UserId", "GuildId") - .IsUnique() - .HasDatabaseName("ix_userxpstats_userid_guildid"); + b.HasIndex("UserId", "GuildId") + .IsUnique() + .HasDatabaseName("ix_userxpstats_userid_guildid"); - b.ToTable("userxpstats", (string)null); - }); + b.ToTable("userxpstats", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.VcRoleInfo", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<decimal>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.Property<decimal>("VoiceChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("voicechannelid"); + b.Property<decimal>("VoiceChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("voicechannelid"); - b.HasKey("Id") - .HasName("pk_vcroleinfo"); + b.HasKey("Id") + .HasName("pk_vcroleinfo"); - b.HasIndex("GuildConfigId") - .HasDatabaseName("ix_vcroleinfo_guildconfigid"); + b.HasIndex("GuildId", "VoiceChannelId") + .IsUnique() + .HasDatabaseName("ix_vcroleinfo_guildid_voicechannelid"); - b.ToTable("vcroleinfo", (string)null); - }); + b.ToTable("vcroleinfo", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuInfo", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int?>("AffinityId") - .HasColumnType("integer") - .HasColumnName("affinityid"); + b.Property<int?>("AffinityId") + .HasColumnType("integer") + .HasColumnName("affinityid"); - b.Property<int?>("ClaimerId") - .HasColumnType("integer") - .HasColumnName("claimerid"); + b.Property<int?>("ClaimerId") + .HasColumnType("integer") + .HasColumnName("claimerid"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<long>("Price") - .HasColumnType("bigint") - .HasColumnName("price"); + b.Property<long>("Price") + .HasColumnType("bigint") + .HasColumnName("price"); - b.Property<int>("WaifuId") - .HasColumnType("integer") - .HasColumnName("waifuid"); + b.Property<int>("WaifuId") + .HasColumnType("integer") + .HasColumnName("waifuid"); - b.HasKey("Id") - .HasName("pk_waifuinfo"); + b.HasKey("Id") + .HasName("pk_waifuinfo"); - b.HasIndex("AffinityId") - .HasDatabaseName("ix_waifuinfo_affinityid"); + b.HasIndex("AffinityId") + .HasDatabaseName("ix_waifuinfo_affinityid"); - b.HasIndex("ClaimerId") - .HasDatabaseName("ix_waifuinfo_claimerid"); + b.HasIndex("ClaimerId") + .HasDatabaseName("ix_waifuinfo_claimerid"); - b.HasIndex("Price") - .HasDatabaseName("ix_waifuinfo_price"); + b.HasIndex("Price") + .HasDatabaseName("ix_waifuinfo_price"); - b.HasIndex("WaifuId") - .IsUnique() - .HasDatabaseName("ix_waifuinfo_waifuid"); + b.HasIndex("WaifuId") + .IsUnique() + .HasDatabaseName("ix_waifuinfo_waifuid"); - b.ToTable("waifuinfo", (string)null); - }); + b.ToTable("waifuinfo", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<string>("ItemEmoji") - .HasColumnType("text") - .HasColumnName("itememoji"); + b.Property<string>("ItemEmoji") + .HasColumnType("text") + .HasColumnName("itememoji"); - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); + b.Property<string>("Name") + .HasColumnType("text") + .HasColumnName("name"); - b.Property<int?>("WaifuInfoId") - .HasColumnType("integer") - .HasColumnName("waifuinfoid"); + b.Property<int?>("WaifuInfoId") + .HasColumnType("integer") + .HasColumnName("waifuinfoid"); - b.HasKey("Id") - .HasName("pk_waifuitem"); + b.HasKey("Id") + .HasName("pk_waifuitem"); - b.HasIndex("WaifuInfoId") - .HasDatabaseName("ix_waifuitem_waifuinfoid"); + b.HasIndex("WaifuInfoId") + .HasDatabaseName("ix_waifuitem_waifuinfoid"); - b.ToTable("waifuitem", (string)null); - }); + b.ToTable("waifuitem", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuUpdate", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int?>("NewId") - .HasColumnType("integer") - .HasColumnName("newid"); + b.Property<int?>("NewId") + .HasColumnType("integer") + .HasColumnName("newid"); - b.Property<int?>("OldId") - .HasColumnType("integer") - .HasColumnName("oldid"); + b.Property<int?>("OldId") + .HasColumnType("integer") + .HasColumnName("oldid"); - b.Property<int>("UpdateType") - .HasColumnType("integer") - .HasColumnName("updatetype"); + b.Property<int>("UpdateType") + .HasColumnType("integer") + .HasColumnName("updatetype"); - b.Property<int>("UserId") - .HasColumnType("integer") - .HasColumnName("userid"); + b.Property<int>("UserId") + .HasColumnType("integer") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_waifuupdates"); + b.HasKey("Id") + .HasName("pk_waifuupdates"); - b.HasIndex("NewId") - .HasDatabaseName("ix_waifuupdates_newid"); + b.HasIndex("NewId") + .HasDatabaseName("ix_waifuupdates_newid"); - b.HasIndex("OldId") - .HasDatabaseName("ix_waifuupdates_oldid"); + b.HasIndex("OldId") + .HasDatabaseName("ix_waifuupdates_oldid"); - b.HasIndex("UserId") - .HasDatabaseName("ix_waifuupdates_userid"); + b.HasIndex("UserId") + .HasDatabaseName("ix_waifuupdates_userid"); - b.ToTable("waifuupdates", (string)null); - }); + b.ToTable("waifuupdates", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.Warning", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<bool>("Forgiven") - .HasColumnType("boolean") - .HasColumnName("forgiven"); + b.Property<bool>("Forgiven") + .HasColumnType("boolean") + .HasColumnName("forgiven"); - b.Property<string>("ForgivenBy") - .HasColumnType("text") - .HasColumnName("forgivenby"); + b.Property<string>("ForgivenBy") + .HasColumnType("text") + .HasColumnName("forgivenby"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<string>("Moderator") - .HasColumnType("text") - .HasColumnName("moderator"); + b.Property<string>("Moderator") + .HasColumnType("text") + .HasColumnName("moderator"); - b.Property<string>("Reason") - .HasColumnType("text") - .HasColumnName("reason"); + b.Property<string>("Reason") + .HasColumnType("text") + .HasColumnName("reason"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.Property<long>("Weight") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasDefaultValue(1L) - .HasColumnName("weight"); + b.Property<long>("Weight") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(1L) + .HasColumnName("weight"); - b.HasKey("Id") - .HasName("pk_warnings"); + b.HasKey("Id") + .HasName("pk_warnings"); - b.HasIndex("DateAdded") - .HasDatabaseName("ix_warnings_dateadded"); + b.HasIndex("DateAdded") + .HasDatabaseName("ix_warnings_dateadded"); - b.HasIndex("GuildId") - .HasDatabaseName("ix_warnings_guildid"); + b.HasIndex("GuildId") + .HasDatabaseName("ix_warnings_guildid"); - b.HasIndex("UserId") - .HasDatabaseName("ix_warnings_userid"); + b.HasIndex("UserId") + .HasDatabaseName("ix_warnings_userid"); - b.ToTable("warnings", (string)null); - }); + b.ToTable("warnings", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.WarningPunishment", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("Count") - .HasColumnType("integer") - .HasColumnName("count"); + b.Property<int>("Count") + .HasColumnType("integer") + .HasColumnName("count"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<int>("Punishment") - .HasColumnType("integer") - .HasColumnName("punishment"); + b.Property<int>("Punishment") + .HasColumnType("integer") + .HasColumnName("punishment"); - b.Property<decimal?>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal?>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.Property<int>("Time") - .HasColumnType("integer") - .HasColumnName("time"); + b.Property<int>("Time") + .HasColumnType("integer") + .HasColumnName("time"); - b.HasKey("Id") - .HasName("pk_warningpunishment"); + b.HasKey("Id") + .HasName("pk_warningpunishment"); - b.HasAlternateKey("GuildId", "Count") - .HasName("ak_warningpunishment_guildid_count"); + b.HasAlternateKey("GuildId", "Count") + .HasName("ak_warningpunishment_guildid_count"); - b.ToTable("warningpunishment", (string)null); - }); + b.ToTable("warningpunishment", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.XpCurrencyReward", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("Amount") - .HasColumnType("integer") - .HasColumnName("amount"); + b.Property<int>("Amount") + .HasColumnType("integer") + .HasColumnName("amount"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("Level") - .HasColumnType("integer") - .HasColumnName("level"); + b.Property<int>("Level") + .HasColumnType("integer") + .HasColumnName("level"); - b.Property<int>("XpSettingsId") - .HasColumnType("integer") - .HasColumnName("xpsettingsid"); + b.Property<int>("XpSettingsId") + .HasColumnType("integer") + .HasColumnName("xpsettingsid"); - b.HasKey("Id") - .HasName("pk_xpcurrencyreward"); + b.HasKey("Id") + .HasName("pk_xpcurrencyreward"); - b.HasIndex("XpSettingsId") - .HasDatabaseName("ix_xpcurrencyreward_xpsettingsid"); + b.HasIndex("XpSettingsId") + .HasDatabaseName("ix_xpcurrencyreward_xpsettingsid"); - b.ToTable("xpcurrencyreward", (string)null); - }); + b.HasIndex("Level", "XpSettingsId") + .IsUnique() + .HasDatabaseName("ix_xpcurrencyreward_level_xpsettingsid"); + + b.ToTable("xpcurrencyreward", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.XpRoleReward", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("Level") - .HasColumnType("integer") - .HasColumnName("level"); + b.Property<int>("Level") + .HasColumnType("integer") + .HasColumnName("level"); - b.Property<bool>("Remove") - .HasColumnType("boolean") - .HasColumnName("remove"); + b.Property<bool>("Remove") + .HasColumnType("boolean") + .HasColumnName("remove"); - b.Property<decimal>("RoleId") - .HasColumnType("numeric(20,0)") - .HasColumnName("roleid"); + b.Property<decimal>("RoleId") + .HasColumnType("numeric(20,0)") + .HasColumnName("roleid"); - b.Property<int>("XpSettingsId") - .HasColumnType("integer") - .HasColumnName("xpsettingsid"); + b.Property<int>("XpSettingsId") + .HasColumnType("integer") + .HasColumnName("xpsettingsid"); - b.HasKey("Id") - .HasName("pk_xprolereward"); + b.HasKey("Id") + .HasName("pk_xprolereward"); - b.HasIndex("XpSettingsId", "Level") - .IsUnique() - .HasDatabaseName("ix_xprolereward_xpsettingsid_level"); + b.HasIndex("XpSettingsId", "Level") + .IsUnique() + .HasDatabaseName("ix_xprolereward_xpsettingsid_level"); - b.ToTable("xprolereward", (string)null); - }); + b.ToTable("xprolereward", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.XpSettings", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<int>("GuildConfigId") - .HasColumnType("integer") - .HasColumnName("guildconfigid"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); - b.Property<bool>("ServerExcluded") - .HasColumnType("boolean") - .HasColumnName("serverexcluded"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.HasKey("Id") - .HasName("pk_xpsettings"); + b.Property<bool>("ServerExcluded") + .HasColumnType("boolean") + .HasColumnName("serverexcluded"); - b.HasIndex("GuildConfigId") - .IsUnique() - .HasDatabaseName("ix_xpsettings_guildconfigid"); + b.HasKey("Id") + .HasName("pk_xpsettings"); - b.ToTable("xpsettings", (string)null); - }); + b.HasIndex("GuildId") + .IsUnique() + .HasDatabaseName("ix_xpsettings_guildid"); + + b.ToTable("xpsettings", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.XpShopOwnedItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<DateTime?>("DateAdded") - .HasColumnType("timestamp without time zone") - .HasColumnName("dateadded"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("timestamp without time zone") + .HasColumnName("dateadded"); - b.Property<bool>("IsUsing") - .HasColumnType("boolean") - .HasColumnName("isusing"); + b.Property<bool>("IsUsing") + .HasColumnType("boolean") + .HasColumnName("isusing"); - b.Property<string>("ItemKey") - .IsRequired() - .HasColumnType("text") - .HasColumnName("itemkey"); + b.Property<string>("ItemKey") + .IsRequired() + .HasColumnType("text") + .HasColumnName("itemkey"); - b.Property<int>("ItemType") - .HasColumnType("integer") - .HasColumnName("itemtype"); + b.Property<int>("ItemType") + .HasColumnType("integer") + .HasColumnName("itemtype"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_xpshopowneditem"); + b.HasKey("Id") + .HasName("pk_xpshopowneditem"); - b.HasIndex("UserId", "ItemType", "ItemKey") - .IsUnique() - .HasDatabaseName("ix_xpshopowneditem_userid_itemtype_itemkey"); + b.HasIndex("UserId", "ItemType", "ItemKey") + .IsUnique() + .HasDatabaseName("ix_xpshopowneditem_userid_itemtype_itemkey"); - b.ToTable("xpshopowneditem", (string)null); - }); + b.ToTable("xpshopowneditem", (string)null); + }); modelBuilder.Entity("EllieBot.Modules.Games.FishCatch", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("Count") - .HasColumnType("integer") - .HasColumnName("count"); + b.Property<int>("Count") + .HasColumnType("integer") + .HasColumnName("count"); - b.Property<int>("FishId") - .HasColumnType("integer") - .HasColumnName("fishid"); + b.Property<int>("FishId") + .HasColumnType("integer") + .HasColumnName("fishid"); - b.Property<int>("MaxStars") - .HasColumnType("integer") - .HasColumnName("maxstars"); + b.Property<int>("MaxStars") + .HasColumnType("integer") + .HasColumnName("maxstars"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_fishcatch"); + b.HasKey("Id") + .HasName("pk_fishcatch"); - b.HasAlternateKey("UserId", "FishId") - .HasName("ak_fishcatch_userid_fishid"); + b.HasAlternateKey("UserId", "FishId") + .HasName("ak_fishcatch_userid_fishid"); - b.ToTable("fishcatch", (string)null); - }); + b.ToTable("fishcatch", (string)null); + }); modelBuilder.Entity("EllieBot.Modules.Games.UserFishStats", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("Skill") - .HasColumnType("integer") - .HasColumnName("skill"); + b.Property<int>("Skill") + .HasColumnType("integer") + .HasColumnName("skill"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.HasKey("Id") - .HasName("pk_userfishstats"); + b.HasKey("Id") + .HasName("pk_userfishstats"); - b.HasIndex("UserId") - .IsUnique() - .HasDatabaseName("ix_userfishstats_userid"); + b.HasIndex("UserId") + .IsUnique() + .HasDatabaseName("ix_userfishstats_userid"); - b.ToTable("userfishstats", (string)null); - }); + b.ToTable("userfishstats", (string)null); + }); modelBuilder.Entity("EllieBot.Services.GreetSettings", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("AutoDeleteTimer") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasDefaultValue(0) - .HasColumnName("autodeletetimer"); + b.Property<int>("AutoDeleteTimer") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("autodeletetimer"); - b.Property<decimal?>("ChannelId") - .HasColumnType("numeric(20,0)") - .HasColumnName("channelid"); + b.Property<decimal?>("ChannelId") + .HasColumnType("numeric(20,0)") + .HasColumnName("channelid"); - b.Property<int>("GreetType") - .HasColumnType("integer") - .HasColumnName("greettype"); + b.Property<int>("GreetType") + .HasColumnType("integer") + .HasColumnName("greettype"); - b.Property<decimal>("GuildId") - .HasColumnType("numeric(20,0)") - .HasColumnName("guildid"); + b.Property<decimal>("GuildId") + .HasColumnType("numeric(20,0)") + .HasColumnName("guildid"); - b.Property<bool>("IsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("boolean") - .HasDefaultValue(false) - .HasColumnName("isenabled"); + b.Property<bool>("IsEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("isenabled"); - b.Property<string>("MessageText") - .HasColumnType("text") - .HasColumnName("messagetext"); + b.Property<string>("MessageText") + .HasColumnType("text") + .HasColumnName("messagetext"); - b.HasKey("Id") - .HasName("pk_greetsettings"); + b.HasKey("Id") + .HasName("pk_greetsettings"); - b.HasIndex("GuildId", "GreetType") - .IsUnique() - .HasDatabaseName("ix_greetsettings_guildid_greettype"); + b.HasIndex("GuildId", "GreetType") + .IsUnique() + .HasDatabaseName("ix_greetsettings_guildid_greettype"); - b.ToTable("greetsettings", (string)null); - }); + b.ToTable("greetsettings", (string)null); + }); modelBuilder.Entity("EllieBot.Services.Rakeback", b => - { - b.Property<decimal>("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + { + b.Property<decimal>("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.Property<decimal>("Amount") - .HasColumnType("numeric") - .HasColumnName("amount"); + b.Property<decimal>("Amount") + .HasColumnType("numeric") + .HasColumnName("amount"); - b.HasKey("UserId") - .HasName("pk_rakeback"); + b.HasKey("UserId") + .HasName("pk_rakeback"); - b.ToTable("rakeback", (string)null); - }); + b.ToTable("rakeback", (string)null); + }); modelBuilder.Entity("EllieBot.Services.UserBetStats", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("Game") - .HasColumnType("integer") - .HasColumnName("game"); + b.Property<int>("Game") + .HasColumnType("integer") + .HasColumnName("game"); - b.Property<long>("LoseCount") - .HasColumnType("bigint") - .HasColumnName("losecount"); + b.Property<long>("LoseCount") + .HasColumnType("bigint") + .HasColumnName("losecount"); - b.Property<long>("MaxBet") - .HasColumnType("bigint") - .HasColumnName("maxbet"); + b.Property<long>("MaxBet") + .HasColumnType("bigint") + .HasColumnName("maxbet"); - b.Property<long>("MaxWin") - .HasColumnType("bigint") - .HasColumnName("maxwin"); + b.Property<long>("MaxWin") + .HasColumnType("bigint") + .HasColumnName("maxwin"); - b.Property<decimal>("PaidOut") - .HasColumnType("numeric") - .HasColumnName("paidout"); + b.Property<decimal>("PaidOut") + .HasColumnType("numeric") + .HasColumnName("paidout"); - b.Property<decimal>("TotalBet") - .HasColumnType("numeric") - .HasColumnName("totalbet"); + b.Property<decimal>("TotalBet") + .HasColumnType("numeric") + .HasColumnName("totalbet"); - b.Property<decimal>("UserId") - .HasColumnType("numeric(20,0)") - .HasColumnName("userid"); + b.Property<decimal>("UserId") + .HasColumnType("numeric(20,0)") + .HasColumnName("userid"); - b.Property<long>("WinCount") - .HasColumnType("bigint") - .HasColumnName("wincount"); + b.Property<long>("WinCount") + .HasColumnType("bigint") + .HasColumnName("wincount"); - b.HasKey("Id") - .HasName("pk_userbetstats"); + b.HasKey("Id") + .HasName("pk_userbetstats"); - b.HasIndex("MaxWin") - .HasDatabaseName("ix_userbetstats_maxwin"); + b.HasIndex("MaxWin") + .HasDatabaseName("ix_userbetstats_maxwin"); - b.HasIndex("UserId", "Game") - .IsUnique() - .HasDatabaseName("ix_userbetstats_userid_game"); + b.HasIndex("UserId", "Game") + .IsUnique() + .HasDatabaseName("ix_userbetstats_userid_game"); - b.ToTable("userbetstats", (string)null); - }); - - modelBuilder.Entity("EllieBot.Db.Models.AntiAltSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiAltSetting") - .HasForeignKey("EllieBot.Db.Models.AntiAltSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_antialtsetting_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.AntiRaidSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiRaidSetting") - .HasForeignKey("EllieBot.Db.Models.AntiRaidSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_antiraidsetting_guildconfigs_guildconfigid"); - }); + b.ToTable("userbetstats", (string)null); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamIgnore", b => - { - b.HasOne("EllieBot.Db.Models.AntiSpamSetting", null) - .WithMany("IgnoredChannels") - .HasForeignKey("AntiSpamSettingId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_antispamignore_antispamsetting_antispamsettingid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiSpamSetting") - .HasForeignKey("EllieBot.Db.Models.AntiSpamSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_antispamsetting_guildconfigs_guildconfigid"); - }); + { + b.HasOne("EllieBot.Db.Models.AntiSpamSetting", null) + .WithMany("IgnoredChannels") + .HasForeignKey("AntiSpamSettingId") + .OnDelete(DeleteBehavior.Cascade) + .HasConstraintName("fk_antispamignore_antispamsetting_antispamsettingid"); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateUser", b => - { - b.HasOne("EllieBot.Db.Models.AutoTranslateChannel", "Channel") - .WithMany("Users") - .HasForeignKey("ChannelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_autotranslateusers_autotranslatechannels_channelid"); + { + b.HasOne("EllieBot.Db.Models.AutoTranslateChannel", "Channel") + .WithMany("Users") + .HasForeignKey("ChannelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_autotranslateusers_autotranslatechannels_channelid"); - b.Navigation("Channel"); - }); + b.Navigation("Channel"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubApplicants", b => - { - b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") - .WithMany("Applicants") - .HasForeignKey("ClubId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_clubapplicants_clubs_clubid"); + { + b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") + .WithMany("Applicants") + .HasForeignKey("ClubId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_clubapplicants_clubs_clubid"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_clubapplicants_discorduser_userid"); + b.HasOne("EllieBot.Db.Models.DiscordUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_clubapplicants_discorduser_userid"); - b.Navigation("Club"); + b.Navigation("Club"); - b.Navigation("User"); - }); + b.Navigation("User"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubBans", b => - { - b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") - .WithMany("Bans") - .HasForeignKey("ClubId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_clubbans_clubs_clubid"); + { + b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") + .WithMany("Bans") + .HasForeignKey("ClubId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_clubbans_clubs_clubid"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_clubbans_discorduser_userid"); + b.HasOne("EllieBot.Db.Models.DiscordUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_clubbans_discorduser_userid"); - b.Navigation("Club"); + b.Navigation("Club"); - b.Navigation("User"); - }); + b.Navigation("User"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubInfo", b => - { - b.HasOne("EllieBot.Db.Models.DiscordUser", "Owner") - .WithOne() - .HasForeignKey("EllieBot.Db.Models.ClubInfo", "OwnerId") - .OnDelete(DeleteBehavior.SetNull) - .HasConstraintName("fk_clubs_discorduser_ownerid"); + { + b.HasOne("EllieBot.Db.Models.DiscordUser", "Owner") + .WithOne() + .HasForeignKey("EllieBot.Db.Models.ClubInfo", "OwnerId") + .OnDelete(DeleteBehavior.SetNull) + .HasConstraintName("fk_clubs_discorduser_ownerid"); - b.Navigation("Owner"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.CommandAlias", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("CommandAliases") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_commandalias_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.CommandCooldown", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("CommandCooldowns") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_commandcooldown_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.DelMsgOnCmdChannel", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("DelMsgOnCmdChannels") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_delmsgoncmdchannel_guildconfigs_guildconfigid"); - }); + b.Navigation("Owner"); + }); modelBuilder.Entity("EllieBot.Db.Models.DiscordUser", b => - { - b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") - .WithMany("Members") - .HasForeignKey("ClubId") - .OnDelete(DeleteBehavior.NoAction) - .HasConstraintName("fk_discorduser_clubs_clubid"); + { + b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") + .WithMany("Members") + .HasForeignKey("ClubId") + .OnDelete(DeleteBehavior.NoAction) + .HasConstraintName("fk_discorduser_clubs_clubid"); - b.Navigation("Club"); - }); + b.Navigation("Club"); + }); modelBuilder.Entity("EllieBot.Db.Models.ExcludedItem", b => - { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") - .WithMany("ExclusionList") - .HasForeignKey("XpSettingsId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_excludeditem_xpsettings_xpsettingsid"); - - b.Navigation("XpSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.FeedSub", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithMany("FeedSubs") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_feedsub_guildconfigs_guildconfigid"); - - b.Navigation("GuildConfig"); - }); + { + b.HasOne("EllieBot.Db.Models.XpSettings", null) + .WithMany("ExclusionList") + .HasForeignKey("XpSettingsId") + .HasConstraintName("fk_excludeditem_xpsettings_xpsettingsid"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FilterInvitesChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_filterchannelid_guildconfigs_guildconfigid"); - }); + { + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) + .WithMany("FilterInvitesChannelIds") + .HasForeignKey("GuildFilterConfigId") + .HasConstraintName("fk_filterchannelid_guildfilterconfig_guildfilterconfigid"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterLinksChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FilterLinksChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_filterlinkschannelid_guildconfigs_guildconfigid"); - }); + { + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) + .WithMany("FilterLinksChannelIds") + .HasForeignKey("GuildFilterConfigId") + .HasConstraintName("fk_filterlinkschannelid_guildfilterconfig_guildfilterconfigid"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterWordsChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FilterWordsChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_filterwordschannelid_guildconfigs_guildconfigid"); - }); + { + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) + .WithMany("FilterWordsChannelIds") + .HasForeignKey("GuildFilterConfigId") + .HasConstraintName("fk_filterwordschannelid_guildfilterconfig_guildfilterconfigid"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilteredWord", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FilteredWords") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_filteredword_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.FollowedStream", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FollowedStreams") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_followedstream_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.GCChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithMany("GenerateCurrencyChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_gcchannelid_guildconfigs_guildconfigid"); - - b.Navigation("GuildConfig"); - }); + { + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) + .WithMany("FilteredWords") + .HasForeignKey("GuildFilterConfigId") + .HasConstraintName("fk_filteredword_guildfilterconfig_guildfilterconfigid"); + }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayUser", b => - { - b.HasOne("EllieBot.Db.Models.GiveawayModel", null) - .WithMany("Participants") - .HasForeignKey("GiveawayId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_giveawayuser_giveawaymodel_giveawayid"); - }); + { + b.HasOne("EllieBot.Db.Models.GiveawayModel", null) + .WithMany("Participants") + .HasForeignKey("GiveawayId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_giveawayuser_giveawaymodel_giveawayid"); + }); modelBuilder.Entity("EllieBot.Db.Models.IgnoredLogItem", b => - { - b.HasOne("EllieBot.Db.Models.LogSetting", "LogSetting") - .WithMany("LogIgnores") - .HasForeignKey("LogSettingId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_ignoredlogchannels_logsettings_logsettingid"); + { + b.HasOne("EllieBot.Db.Models.LogSetting", "LogSetting") + .WithMany("LogIgnores") + .HasForeignKey("LogSettingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_ignoredlogchannels_logsettings_logsettingid"); - b.Navigation("LogSetting"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.MutedUserId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("MutedUsers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_muteduserid_guildconfigs_guildconfigid"); - }); + b.Navigation("LogSetting"); + }); modelBuilder.Entity("EllieBot.Db.Models.Permissionv2", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("Permissions") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_permissions_guildconfigs_guildconfigid"); - }); + { + b.HasOne("EllieBot.Db.Models.GuildConfig", null) + .WithMany("Permissions") + .HasForeignKey("GuildConfigId") + .HasConstraintName("fk_permissions_guildconfigs_guildconfigid"); + }); modelBuilder.Entity("EllieBot.Db.Models.PlaylistSong", b => - { - b.HasOne("EllieBot.Db.Models.MusicPlaylist", null) - .WithMany("Songs") - .HasForeignKey("MusicPlaylistId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_playlistsong_musicplaylists_musicplaylistid"); - }); + { + b.HasOne("EllieBot.Db.Models.MusicPlaylist", null) + .WithMany("Songs") + .HasForeignKey("MusicPlaylistId") + .OnDelete(DeleteBehavior.Cascade) + .HasConstraintName("fk_playlistsong_musicplaylists_musicplaylistid"); + }); modelBuilder.Entity("EllieBot.Db.Models.Sar", b => - { - b.HasOne("EllieBot.Db.Models.SarGroup", null) - .WithMany("Roles") - .HasForeignKey("SarGroupId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_sar_sargroup_sargroupid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.ShopEntry", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("ShopEntries") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_shopentry_guildconfigs_guildconfigid"); - }); + { + b.HasOne("EllieBot.Db.Models.SarGroup", null) + .WithMany("Roles") + .HasForeignKey("SarGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_sar_sargroup_sargroupid"); + }); modelBuilder.Entity("EllieBot.Db.Models.ShopEntryItem", b => - { - b.HasOne("EllieBot.Db.Models.ShopEntry", null) - .WithMany("Items") - .HasForeignKey("ShopEntryId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_shopentryitem_shopentry_shopentryid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredRole", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("SlowmodeIgnoredRoles") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_slowmodeignoredrole_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredUser", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("SlowmodeIgnoredUsers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_slowmodeignoreduser_guildconfigs_guildconfigid"); - }); + { + b.HasOne("EllieBot.Db.Models.ShopEntry", null) + .WithMany("Items") + .HasForeignKey("ShopEntryId") + .OnDelete(DeleteBehavior.Cascade) + .HasConstraintName("fk_shopentryitem_shopentry_shopentryid"); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleBlacklistedUser", b => - { - b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") - .WithMany("Blacklist") - .HasForeignKey("StreamRoleSettingsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_streamroleblacklisteduser_streamrolesettings_streamrolesett~"); + { + b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") + .WithMany("Blacklist") + .HasForeignKey("StreamRoleSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_streamroleblacklisteduser_streamrolesettings_streamrolesett~"); - b.Navigation("StreamRoleSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.StreamRoleSettings", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithOne("StreamRole") - .HasForeignKey("EllieBot.Db.Models.StreamRoleSettings", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_streamrolesettings_guildconfigs_guildconfigid"); - - b.Navigation("GuildConfig"); - }); + b.Navigation("StreamRoleSettings"); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleWhitelistedUser", b => - { - b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") - .WithMany("Whitelist") - .HasForeignKey("StreamRoleSettingsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_streamrolewhitelisteduser_streamrolesettings_streamrolesett~"); + { + b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") + .WithMany("Whitelist") + .HasForeignKey("StreamRoleSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_streamrolewhitelisteduser_streamrolesettings_streamrolesett~"); - b.Navigation("StreamRoleSettings"); - }); + b.Navigation("StreamRoleSettings"); + }); modelBuilder.Entity("EllieBot.Db.Models.TodoModel", b => - { - b.HasOne("EllieBot.Db.Models.ArchivedTodoListModel", null) - .WithMany("Items") - .HasForeignKey("ArchiveId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_todos_todosarchive_archiveid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnbanTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnbanTimer") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_unbantimer_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnmuteTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnmuteTimers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_unmutetimer_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnroleTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnroleTimer") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_unroletimer_guildconfigs_guildconfigid"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.VcRoleInfo", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("VcRoleInfos") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .HasConstraintName("fk_vcroleinfo_guildconfigs_guildconfigid"); - }); + { + b.HasOne("EllieBot.Db.Models.ArchivedTodoListModel", null) + .WithMany("Items") + .HasForeignKey("ArchiveId") + .OnDelete(DeleteBehavior.Cascade) + .HasConstraintName("fk_todos_todosarchive_archiveid"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuInfo", b => - { - b.HasOne("EllieBot.Db.Models.DiscordUser", "Affinity") - .WithMany() - .HasForeignKey("AffinityId") - .HasConstraintName("fk_waifuinfo_discorduser_affinityid"); + { + b.HasOne("EllieBot.Db.Models.DiscordUser", "Affinity") + .WithMany() + .HasForeignKey("AffinityId") + .HasConstraintName("fk_waifuinfo_discorduser_affinityid"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "Claimer") - .WithMany() - .HasForeignKey("ClaimerId") - .HasConstraintName("fk_waifuinfo_discorduser_claimerid"); + b.HasOne("EllieBot.Db.Models.DiscordUser", "Claimer") + .WithMany() + .HasForeignKey("ClaimerId") + .HasConstraintName("fk_waifuinfo_discorduser_claimerid"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "Waifu") - .WithOne() - .HasForeignKey("EllieBot.Db.Models.WaifuInfo", "WaifuId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_waifuinfo_discorduser_waifuid"); + b.HasOne("EllieBot.Db.Models.DiscordUser", "Waifu") + .WithOne() + .HasForeignKey("EllieBot.Db.Models.WaifuInfo", "WaifuId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_waifuinfo_discorduser_waifuid"); - b.Navigation("Affinity"); + b.Navigation("Affinity"); - b.Navigation("Claimer"); + b.Navigation("Claimer"); - b.Navigation("Waifu"); - }); + b.Navigation("Waifu"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuItem", b => - { - b.HasOne("EllieBot.Db.Models.WaifuInfo", "WaifuInfo") - .WithMany("Items") - .HasForeignKey("WaifuInfoId") - .HasConstraintName("fk_waifuitem_waifuinfo_waifuinfoid"); + { + b.HasOne("EllieBot.Db.Models.WaifuInfo", "WaifuInfo") + .WithMany("Items") + .HasForeignKey("WaifuInfoId") + .HasConstraintName("fk_waifuitem_waifuinfo_waifuinfoid"); - b.Navigation("WaifuInfo"); - }); + b.Navigation("WaifuInfo"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuUpdate", b => - { - b.HasOne("EllieBot.Db.Models.DiscordUser", "New") - .WithMany() - .HasForeignKey("NewId") - .HasConstraintName("fk_waifuupdates_discorduser_newid"); + { + b.HasOne("EllieBot.Db.Models.DiscordUser", "New") + .WithMany() + .HasForeignKey("NewId") + .HasConstraintName("fk_waifuupdates_discorduser_newid"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "Old") - .WithMany() - .HasForeignKey("OldId") - .HasConstraintName("fk_waifuupdates_discorduser_oldid"); + b.HasOne("EllieBot.Db.Models.DiscordUser", "Old") + .WithMany() + .HasForeignKey("OldId") + .HasConstraintName("fk_waifuupdates_discorduser_oldid"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_waifuupdates_discorduser_userid"); + b.HasOne("EllieBot.Db.Models.DiscordUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_waifuupdates_discorduser_userid"); - b.Navigation("New"); + b.Navigation("New"); - b.Navigation("Old"); + b.Navigation("Old"); - b.Navigation("User"); - }); + b.Navigation("User"); + }); modelBuilder.Entity("EllieBot.Db.Models.XpCurrencyReward", b => - { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") - .WithMany("CurrencyRewards") - .HasForeignKey("XpSettingsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_xpcurrencyreward_xpsettings_xpsettingsid"); - - b.Navigation("XpSettings"); - }); + { + b.HasOne("EllieBot.Db.Models.XpSettings", null) + .WithMany("CurrencyRewards") + .HasForeignKey("XpSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_xpcurrencyreward_xpsettings_xpsettingsid"); + }); modelBuilder.Entity("EllieBot.Db.Models.XpRoleReward", b => - { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") - .WithMany("RoleRewards") - .HasForeignKey("XpSettingsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_xprolereward_xpsettings_xpsettingsid"); - - b.Navigation("XpSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.XpSettings", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithOne("XpSettings") - .HasForeignKey("EllieBot.Db.Models.XpSettings", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_xpsettings_guildconfigs_guildconfigid"); - - b.Navigation("GuildConfig"); - }); + { + b.HasOne("EllieBot.Db.Models.XpSettings", null) + .WithMany("RoleRewards") + .HasForeignKey("XpSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_xprolereward_xpsettings_xpsettingsid"); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => - { - b.Navigation("IgnoredChannels"); - }); + { + b.Navigation("IgnoredChannels"); + }); modelBuilder.Entity("EllieBot.Db.Models.ArchivedTodoListModel", b => - { - b.Navigation("Items"); - }); + { + b.Navigation("Items"); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateChannel", b => - { - b.Navigation("Users"); - }); + { + b.Navigation("Users"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubInfo", b => - { - b.Navigation("Applicants"); + { + b.Navigation("Applicants"); - b.Navigation("Bans"); + b.Navigation("Bans"); - b.Navigation("Members"); - }); + b.Navigation("Members"); + }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayModel", b => - { - b.Navigation("Participants"); - }); + { + b.Navigation("Participants"); + }); modelBuilder.Entity("EllieBot.Db.Models.GuildConfig", b => - { - b.Navigation("AntiAltSetting"); + { + b.Navigation("Permissions"); + }); - b.Navigation("AntiRaidSetting"); + modelBuilder.Entity("EllieBot.Db.Models.GuildFilterConfig", b => + { + b.Navigation("FilterInvitesChannelIds"); - b.Navigation("AntiSpamSetting"); + b.Navigation("FilterLinksChannelIds"); - b.Navigation("CommandAliases"); + b.Navigation("FilterWordsChannelIds"); - b.Navigation("CommandCooldowns"); - - b.Navigation("DelMsgOnCmdChannels"); - - b.Navigation("FeedSubs"); - - b.Navigation("FilterInvitesChannelIds"); - - b.Navigation("FilterLinksChannelIds"); - - b.Navigation("FilterWordsChannelIds"); - - b.Navigation("FilteredWords"); - - b.Navigation("FollowedStreams"); - - b.Navigation("GenerateCurrencyChannelIds"); - - b.Navigation("MutedUsers"); - - b.Navigation("Permissions"); - - b.Navigation("ShopEntries"); - - b.Navigation("SlowmodeIgnoredRoles"); - - b.Navigation("SlowmodeIgnoredUsers"); - - b.Navigation("StreamRole"); - - b.Navigation("UnbanTimer"); - - b.Navigation("UnmuteTimers"); - - b.Navigation("UnroleTimer"); - - b.Navigation("VcRoleInfos"); - - b.Navigation("XpSettings"); - }); + b.Navigation("FilteredWords"); + }); modelBuilder.Entity("EllieBot.Db.Models.LogSetting", b => - { - b.Navigation("LogIgnores"); - }); + { + b.Navigation("LogIgnores"); + }); modelBuilder.Entity("EllieBot.Db.Models.MusicPlaylist", b => - { - b.Navigation("Songs"); - }); + { + b.Navigation("Songs"); + }); modelBuilder.Entity("EllieBot.Db.Models.SarGroup", b => - { - b.Navigation("Roles"); - }); + { + b.Navigation("Roles"); + }); modelBuilder.Entity("EllieBot.Db.Models.ShopEntry", b => - { - b.Navigation("Items"); - }); + { + b.Navigation("Items"); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleSettings", b => - { - b.Navigation("Blacklist"); + { + b.Navigation("Blacklist"); - b.Navigation("Whitelist"); - }); + b.Navigation("Whitelist"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuInfo", b => - { - b.Navigation("Items"); - }); + { + b.Navigation("Items"); + }); modelBuilder.Entity("EllieBot.Db.Models.XpSettings", b => - { - b.Navigation("CurrencyRewards"); + { + b.Navigation("CurrencyRewards"); - b.Navigation("ExclusionList"); + b.Navigation("ExclusionList"); - b.Navigation("RoleRewards"); - }); + b.Navigation("RoleRewards"); + }); #pragma warning restore 612, 618 } } diff --git a/src/EllieBot/Migrations/Sqlite/20250126062816_cleanup.sql b/src/EllieBot/Migrations/Sqlite/20250126062816_cleanup.sql new file mode 100644 index 0000000..78cd76f --- /dev/null +++ b/src/EllieBot/Migrations/Sqlite/20250126062816_cleanup.sql @@ -0,0 +1,762 @@ +BEGIN TRANSACTION; + +DROP INDEX "IX_XpSettings_GuildConfigId"; + +DROP INDEX "IX_VcRoleInfo_GuildConfigId"; + +DROP INDEX "IX_UnroleTimer_GuildConfigId"; + +DROP INDEX "IX_UnmuteTimer_GuildConfigId"; + +DROP INDEX "IX_UnbanTimer_GuildConfigId"; + +DROP INDEX "IX_StreamRoleSettings_GuildConfigId"; + +DROP INDEX "IX_SlowmodeIgnoredUser_GuildConfigId"; + +DROP INDEX "IX_SlowmodeIgnoredRole_GuildConfigId"; + +DROP INDEX "IX_ShopEntry_GuildConfigId"; + +DROP INDEX "IX_MutedUserId_GuildConfigId"; + +DROP INDEX "IX_GCChannelId_GuildConfigId"; + +DROP INDEX "IX_FollowedStream_GuildConfigId"; + +DROP INDEX "IX_DelMsgOnCmdChannel_GuildConfigId"; + +DROP INDEX "IX_CommandCooldown_GuildConfigId"; + +DROP INDEX "IX_CommandAlias_GuildConfigId"; + +DROP INDEX "IX_AntiSpamSetting_GuildConfigId"; + +DROP INDEX "IX_AntiRaidSetting_GuildConfigId"; + +DROP INDEX "IX_AntiAltSetting_GuildConfigId"; + +ALTER TABLE "FilterWordsChannelId" RENAME COLUMN "GuildConfigId" TO "GuildFilterConfigId"; + +DROP INDEX "IX_FilterWordsChannelId_GuildConfigId"; + +CREATE INDEX "IX_FilterWordsChannelId_GuildFilterConfigId" ON "FilterWordsChannelId" ("GuildFilterConfigId"); + +ALTER TABLE "FilterLinksChannelId" RENAME COLUMN "GuildConfigId" TO "GuildFilterConfigId"; + +DROP INDEX "IX_FilterLinksChannelId_GuildConfigId"; + +CREATE INDEX "IX_FilterLinksChannelId_GuildFilterConfigId" ON "FilterLinksChannelId" ("GuildFilterConfigId"); + +ALTER TABLE "FilteredWord" RENAME COLUMN "GuildConfigId" TO "GuildFilterConfigId"; + +DROP INDEX "IX_FilteredWord_GuildConfigId"; + +CREATE INDEX "IX_FilteredWord_GuildFilterConfigId" ON "FilteredWord" ("GuildFilterConfigId"); + +ALTER TABLE "FilterChannelId" RENAME COLUMN "GuildConfigId" TO "GuildFilterConfigId"; + +DROP INDEX "IX_FilterChannelId_GuildConfigId"; + +CREATE INDEX "IX_FilterChannelId_GuildFilterConfigId" ON "FilterChannelId" ("GuildFilterConfigId"); + +ALTER TABLE "XpSettings" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "VcRoleInfo" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "UnroleTimer" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "UnmuteTimer" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "UnbanTimer" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "StreamRoleSettings" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "SlowmodeIgnoredUser" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "SlowmodeIgnoredRole" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "ShopEntry" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "Permissions" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "MutedUserId" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "GCChannelId" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "FeedSub" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "DelMsgOnCmdChannel" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "CommandCooldown" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "CommandAlias" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "AntiSpamSetting" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "AntiRaidSetting" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE "AntiAltSetting" ADD "GuildId" INTEGER NOT NULL DEFAULT 0; + +CREATE TABLE "GuildFilterConfig" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_GuildFilterConfig" PRIMARY KEY AUTOINCREMENT, + "GuildId" INTEGER NOT NULL, + "FilterInvites" INTEGER NOT NULL, + "FilterLinks" INTEGER NOT NULL, + "FilterWords" INTEGER NOT NULL +); + +insert into guildfilterconfig (Id, GuildId, FilterLinks, FilterInvites, FilterWords) +select Id, GuildId, FilterLinks, FilterInvites, FilterWords +from guildconfigs; + +DELETE FROM XPSettings WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE XpSettings +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = XpSettings.GuildConfigId); + +DELETE FROM StreamRoleSettings WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE StreamRoleSettings +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = StreamRoleSettings.GuildConfigId); + +DELETE FROM FeedSub WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE FeedSub +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = FeedSub.GuildConfigId); + +DELETE FROM DelMsgOnCmdChannel WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE DelMsgOnCmdChannel +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = DelMsgOnCmdChannel.GuildConfigId); + +DELETE FROM AntiSpamSetting WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE AntiSpamSetting +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = AntiSpamSetting.GuildConfigId); + +DELETE FROM AntiRaidSetting WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE AntiRaidSetting +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = AntiRaidSetting.GuildConfigId); + +DELETE FROM AntiAltSetting WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE AntiAltSetting +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = AntiAltSetting.GuildConfigId); + +DELETE FROM VcRoleInfo WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE VcRoleInfo +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = VcRoleInfo.GuildConfigId); + +DELETE FROM UnroleTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE UnroleTimer +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = UnroleTimer.GuildConfigId); + +DELETE FROM UnmuteTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE UnmuteTimer +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = UnmuteTimer.GuildConfigId); + +DELETE FROM UnbanTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE UnbanTimer +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = UnbanTimer.GuildConfigId); + +DELETE FROM SlowmodeIgnoredUser WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE SlowmodeIgnoredUser +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = SlowmodeIgnoredUser.GuildConfigId); + +DELETE FROM SlowmodeIgnoredRole WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE SlowmodeIgnoredRole +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = SlowmodeIgnoredRole.GuildConfigId); + +DELETE FROM ShopEntry WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE ShopEntry +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = ShopEntry.GuildConfigId); + +DELETE FROM Permissions WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE Permissions +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = Permissions.GuildConfigId); + +DELETE FROM MutedUserId WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE MutedUserId +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = MutedUserId.GuildConfigId); + +DELETE FROM GcChannelId WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE GcChannelId +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = GcChannelId.GuildConfigId); + +DELETE FROM CommandCooldown WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE CommandCooldown +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = CommandCooldown.GuildConfigId); + +DELETE FROM CommandAlias WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs); +UPDATE CommandAlias +SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = CommandAlias.GuildConfigId); + +CREATE UNIQUE INDEX "IX_XpSettings_GuildId" ON "XpSettings" ("GuildId"); + +CREATE UNIQUE INDEX "IX_XpCurrencyReward_Level_XpSettingsId" ON "XpCurrencyReward" ("Level", "XpSettingsId"); + +CREATE UNIQUE INDEX "IX_VcRoleInfo_GuildId_VoiceChannelId" ON "VcRoleInfo" ("GuildId", "VoiceChannelId"); + +CREATE UNIQUE INDEX "IX_UnroleTimer_GuildId_UserId" ON "UnroleTimer" ("GuildId", "UserId"); + +CREATE UNIQUE INDEX "IX_UnmuteTimer_GuildId_UserId" ON "UnmuteTimer" ("GuildId", "UserId"); + +CREATE UNIQUE INDEX "IX_UnbanTimer_GuildId_UserId" ON "UnbanTimer" ("GuildId", "UserId"); + +CREATE UNIQUE INDEX "IX_StreamRoleSettings_GuildId" ON "StreamRoleSettings" ("GuildId"); + +CREATE UNIQUE INDEX "IX_SlowmodeIgnoredUser_GuildId_UserId" ON "SlowmodeIgnoredUser" ("GuildId", "UserId"); + +CREATE UNIQUE INDEX "IX_SlowmodeIgnoredRole_GuildId_RoleId" ON "SlowmodeIgnoredRole" ("GuildId", "RoleId"); + +CREATE UNIQUE INDEX "IX_ShopEntry_GuildId_Index" ON "ShopEntry" ("GuildId", "Index"); + +CREATE INDEX "IX_Permissions_GuildId" ON "Permissions" ("GuildId"); + +CREATE UNIQUE INDEX "IX_MutedUserId_GuildId_UserId" ON "MutedUserId" ("GuildId", "UserId"); + +CREATE UNIQUE INDEX "IX_GCChannelId_GuildId_ChannelId" ON "GCChannelId" ("GuildId", "ChannelId"); + +CREATE INDEX "IX_FollowedStream_GuildId_Username_Type" ON "FollowedStream" ("GuildId", "Username", "Type"); + +CREATE UNIQUE INDEX "IX_FeedSub_GuildId_Url" ON "FeedSub" ("GuildId", "Url"); + +CREATE UNIQUE INDEX "IX_DelMsgOnCmdChannel_GuildId_ChannelId" ON "DelMsgOnCmdChannel" ("GuildId", "ChannelId"); + +CREATE UNIQUE INDEX "IX_CommandCooldown_GuildId_CommandName" ON "CommandCooldown" ("GuildId", "CommandName"); + +CREATE INDEX "IX_CommandAlias_GuildId" ON "CommandAlias" ("GuildId"); + +CREATE UNIQUE INDEX "IX_AntiSpamSetting_GuildId" ON "AntiSpamSetting" ("GuildId"); + +CREATE UNIQUE INDEX "IX_AntiRaidSetting_GuildId" ON "AntiRaidSetting" ("GuildId"); + +CREATE UNIQUE INDEX "IX_AntiAltSetting_GuildId" ON "AntiAltSetting" ("GuildId"); + +CREATE INDEX "IX_GuildFilterConfig_GuildId" ON "GuildFilterConfig" ("GuildId"); + +CREATE TABLE "ef_temp_AntiAltSetting" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_AntiAltSetting" PRIMARY KEY AUTOINCREMENT, + "Action" INTEGER NOT NULL, + "ActionDurationMinutes" INTEGER NOT NULL, + "GuildConfigId" INTEGER NOT NULL, + "GuildId" INTEGER NOT NULL, + "MinAge" TEXT NOT NULL, + "RoleId" INTEGER NULL +); + +INSERT INTO "ef_temp_AntiAltSetting" ("Id", "Action", "ActionDurationMinutes", "GuildConfigId", "GuildId", "MinAge", "RoleId") +SELECT "Id", "Action", "ActionDurationMinutes", "GuildConfigId", "GuildId", "MinAge", "RoleId" +FROM "AntiAltSetting"; + +CREATE TABLE "ef_temp_AntiRaidSetting" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_AntiRaidSetting" PRIMARY KEY AUTOINCREMENT, + "Action" INTEGER NOT NULL, + "DateAdded" TEXT NULL, + "GuildConfigId" INTEGER NOT NULL, + "GuildId" INTEGER NOT NULL, + "PunishDuration" INTEGER NOT NULL, + "Seconds" INTEGER NOT NULL, + "UserThreshold" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_AntiRaidSetting" ("Id", "Action", "DateAdded", "GuildConfigId", "GuildId", "PunishDuration", "Seconds", "UserThreshold") +SELECT "Id", "Action", "DateAdded", "GuildConfigId", "GuildId", "PunishDuration", "Seconds", "UserThreshold" +FROM "AntiRaidSetting"; + +CREATE TABLE "ef_temp_AntiSpamSetting" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_AntiSpamSetting" PRIMARY KEY AUTOINCREMENT, + "Action" INTEGER NOT NULL, + "DateAdded" TEXT NULL, + "GuildConfigId" INTEGER NOT NULL, + "GuildId" INTEGER NOT NULL, + "MessageThreshold" INTEGER NOT NULL, + "MuteTime" INTEGER NOT NULL, + "RoleId" INTEGER NULL +); + +INSERT INTO "ef_temp_AntiSpamSetting" ("Id", "Action", "DateAdded", "GuildConfigId", "GuildId", "MessageThreshold", "MuteTime", "RoleId") +SELECT "Id", "Action", "DateAdded", "GuildConfigId", "GuildId", "MessageThreshold", "MuteTime", "RoleId" +FROM "AntiSpamSetting"; + +CREATE TABLE "ef_temp_CommandAlias" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_CommandAlias" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "Mapping" TEXT NULL, + "Trigger" TEXT NULL +); + +INSERT INTO "ef_temp_CommandAlias" ("Id", "DateAdded", "GuildId", "Mapping", "Trigger") +SELECT "Id", "DateAdded", "GuildId", "Mapping", "Trigger" +FROM "CommandAlias"; + +CREATE TABLE "ef_temp_CommandCooldown" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_CommandCooldown" PRIMARY KEY AUTOINCREMENT, + "CommandName" TEXT NULL, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "Seconds" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_CommandCooldown" ("Id", "CommandName", "DateAdded", "GuildId", "Seconds") +SELECT "Id", "CommandName", "DateAdded", "GuildId", "Seconds" +FROM "CommandCooldown"; + +CREATE TABLE "ef_temp_DelMsgOnCmdChannel" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_DelMsgOnCmdChannel" PRIMARY KEY AUTOINCREMENT, + "ChannelId" INTEGER NOT NULL, + "DateAdded" TEXT NULL, + "GuildConfigId" INTEGER NOT NULL, + "GuildId" INTEGER NOT NULL, + "State" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_DelMsgOnCmdChannel" ("Id", "ChannelId", "DateAdded", "GuildConfigId", "GuildId", "State") +SELECT "Id", "ChannelId", "DateAdded", "GuildConfigId", "GuildId", "State" +FROM "DelMsgOnCmdChannel"; + +CREATE TABLE "ef_temp_ExcludedItem" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_ExcludedItem" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "ItemId" INTEGER NOT NULL, + "ItemType" INTEGER NOT NULL, + "XpSettingsId" INTEGER NULL, + CONSTRAINT "FK_ExcludedItem_XpSettings_XpSettingsId" FOREIGN KEY ("XpSettingsId") REFERENCES "XpSettings" ("Id") +); + +INSERT INTO "ef_temp_ExcludedItem" ("Id", "DateAdded", "ItemId", "ItemType", "XpSettingsId") +SELECT "Id", "DateAdded", "ItemId", "ItemType", "XpSettingsId" +FROM "ExcludedItem"; + +CREATE TABLE "ef_temp_FeedSub" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_FeedSub" PRIMARY KEY AUTOINCREMENT, + "ChannelId" INTEGER NOT NULL, + "DateAdded" TEXT NULL, + "GuildConfigId" INTEGER NOT NULL, + "GuildId" INTEGER NOT NULL, + "Message" TEXT NULL, + "Url" TEXT NULL +); + +INSERT INTO "ef_temp_FeedSub" ("Id", "ChannelId", "DateAdded", "GuildConfigId", "GuildId", "Message", "Url") +SELECT "Id", "ChannelId", "DateAdded", "GuildConfigId", "GuildId", "Message", "Url" +FROM "FeedSub"; + +CREATE TABLE "ef_temp_FilterChannelId" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_FilterChannelId" PRIMARY KEY AUTOINCREMENT, + "ChannelId" INTEGER NOT NULL, + "GuildFilterConfigId" INTEGER NULL, + CONSTRAINT "FK_FilterChannelId_GuildFilterConfig_GuildFilterConfigId" FOREIGN KEY ("GuildFilterConfigId") REFERENCES "GuildFilterConfig" ("Id") +); + +INSERT INTO "ef_temp_FilterChannelId" ("Id", "ChannelId", "GuildFilterConfigId") +SELECT "Id", "ChannelId", "GuildFilterConfigId" +FROM "FilterChannelId"; + +CREATE TABLE "ef_temp_FilteredWord" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_FilteredWord" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildFilterConfigId" INTEGER NULL, + "Word" TEXT NULL, + CONSTRAINT "FK_FilteredWord_GuildFilterConfig_GuildFilterConfigId" FOREIGN KEY ("GuildFilterConfigId") REFERENCES "GuildFilterConfig" ("Id") +); + +INSERT INTO "ef_temp_FilteredWord" ("Id", "DateAdded", "GuildFilterConfigId", "Word") +SELECT "Id", "DateAdded", "GuildFilterConfigId", "Word" +FROM "FilteredWord"; + +CREATE TABLE "ef_temp_FilterLinksChannelId" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_FilterLinksChannelId" PRIMARY KEY AUTOINCREMENT, + "ChannelId" INTEGER NOT NULL, + "DateAdded" TEXT NULL, + "GuildFilterConfigId" INTEGER NULL, + CONSTRAINT "FK_FilterLinksChannelId_GuildFilterConfig_GuildFilterConfigId" FOREIGN KEY ("GuildFilterConfigId") REFERENCES "GuildFilterConfig" ("Id") +); + +INSERT INTO "ef_temp_FilterLinksChannelId" ("Id", "ChannelId", "DateAdded", "GuildFilterConfigId") +SELECT "Id", "ChannelId", "DateAdded", "GuildFilterConfigId" +FROM "FilterLinksChannelId"; + +CREATE TABLE "ef_temp_FilterWordsChannelId" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_FilterWordsChannelId" PRIMARY KEY AUTOINCREMENT, + "ChannelId" INTEGER NOT NULL, + "DateAdded" TEXT NULL, + "GuildFilterConfigId" INTEGER NULL, + CONSTRAINT "FK_FilterWordsChannelId_GuildFilterConfig_GuildFilterConfigId" FOREIGN KEY ("GuildFilterConfigId") REFERENCES "GuildFilterConfig" ("Id") +); + +INSERT INTO "ef_temp_FilterWordsChannelId" ("Id", "ChannelId", "DateAdded", "GuildFilterConfigId") +SELECT "Id", "ChannelId", "DateAdded", "GuildFilterConfigId" +FROM "FilterWordsChannelId"; + +CREATE TABLE "ef_temp_FollowedStream" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_FollowedStream" PRIMARY KEY AUTOINCREMENT, + "ChannelId" INTEGER NOT NULL, + "GuildId" INTEGER NOT NULL, + "Message" TEXT NULL, + "Type" INTEGER NOT NULL, + "Username" TEXT NULL +); + +INSERT INTO "ef_temp_FollowedStream" ("Id", "ChannelId", "GuildId", "Message", "Type", "Username") +SELECT "Id", "ChannelId", "GuildId", "Message", "Type", "Username" +FROM "FollowedStream"; + +CREATE TABLE "ef_temp_GCChannelId" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_GCChannelId" PRIMARY KEY AUTOINCREMENT, + "ChannelId" INTEGER NOT NULL, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_GCChannelId" ("Id", "ChannelId", "DateAdded", "GuildId") +SELECT "Id", "ChannelId", "DateAdded", "GuildId" +FROM "GCChannelId"; + +CREATE TABLE "ef_temp_MutedUserId" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_MutedUserId" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "UserId" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_MutedUserId" ("Id", "DateAdded", "GuildId", "UserId") +SELECT "Id", "DateAdded", "GuildId", "UserId" +FROM "MutedUserId"; + +CREATE TABLE "ef_temp_Permissions" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_Permissions" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildConfigId" INTEGER NULL, + "GuildId" INTEGER NOT NULL, + "Index" INTEGER NOT NULL, + "IsCustomCommand" INTEGER NOT NULL, + "PrimaryTarget" INTEGER NOT NULL, + "PrimaryTargetId" INTEGER NOT NULL, + "SecondaryTarget" INTEGER NOT NULL, + "SecondaryTargetName" TEXT NULL, + "State" INTEGER NOT NULL, + CONSTRAINT "FK_Permissions_GuildConfigs_GuildConfigId" FOREIGN KEY ("GuildConfigId") REFERENCES "GuildConfigs" ("Id") +); + +INSERT INTO "ef_temp_Permissions" ("Id", "DateAdded", "GuildConfigId", "GuildId", "Index", "IsCustomCommand", "PrimaryTarget", "PrimaryTargetId", "SecondaryTarget", "SecondaryTargetName", "State") +SELECT "Id", "DateAdded", "GuildConfigId", "GuildId", "Index", "IsCustomCommand", "PrimaryTarget", "PrimaryTargetId", "SecondaryTarget", "SecondaryTargetName", "State" +FROM "Permissions"; + +CREATE TABLE "ef_temp_ShopEntry" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_ShopEntry" PRIMARY KEY AUTOINCREMENT, + "AuthorId" INTEGER NOT NULL, + "Command" TEXT NULL, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "Index" INTEGER NOT NULL, + "Name" TEXT NULL, + "Price" INTEGER NOT NULL, + "RoleId" INTEGER NOT NULL, + "RoleName" TEXT NULL, + "RoleRequirement" INTEGER NULL, + "Type" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_ShopEntry" ("Id", "AuthorId", "Command", "DateAdded", "GuildId", "Index", "Name", "Price", "RoleId", "RoleName", "RoleRequirement", "Type") +SELECT "Id", "AuthorId", "Command", "DateAdded", "GuildId", "Index", "Name", "Price", "RoleId", "RoleName", "RoleRequirement", "Type" +FROM "ShopEntry"; + +CREATE TABLE "ef_temp_SlowmodeIgnoredRole" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_SlowmodeIgnoredRole" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "RoleId" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_SlowmodeIgnoredRole" ("Id", "DateAdded", "GuildId", "RoleId") +SELECT "Id", "DateAdded", "GuildId", "RoleId" +FROM "SlowmodeIgnoredRole"; + +CREATE TABLE "ef_temp_SlowmodeIgnoredUser" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_SlowmodeIgnoredUser" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "UserId" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_SlowmodeIgnoredUser" ("Id", "DateAdded", "GuildId", "UserId") +SELECT "Id", "DateAdded", "GuildId", "UserId" +FROM "SlowmodeIgnoredUser"; + +CREATE TABLE "ef_temp_StreamRoleSettings" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_StreamRoleSettings" PRIMARY KEY AUTOINCREMENT, + "AddRoleId" INTEGER NOT NULL, + "DateAdded" TEXT NULL, + "Enabled" INTEGER NOT NULL, + "FromRoleId" INTEGER NOT NULL, + "GuildConfigId" INTEGER NOT NULL, + "GuildId" INTEGER NOT NULL, + "Keyword" TEXT NULL +); + +INSERT INTO "ef_temp_StreamRoleSettings" ("Id", "AddRoleId", "DateAdded", "Enabled", "FromRoleId", "GuildConfigId", "GuildId", "Keyword") +SELECT "Id", "AddRoleId", "DateAdded", "Enabled", "FromRoleId", "GuildConfigId", "GuildId", "Keyword" +FROM "StreamRoleSettings"; + +CREATE TABLE "ef_temp_UnbanTimer" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_UnbanTimer" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "UnbanAt" TEXT NOT NULL, + "UserId" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_UnbanTimer" ("Id", "DateAdded", "GuildId", "UnbanAt", "UserId") +SELECT "Id", "DateAdded", "GuildId", "UnbanAt", "UserId" +FROM "UnbanTimer"; + +CREATE TABLE "ef_temp_UnmuteTimer" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_UnmuteTimer" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "UnmuteAt" TEXT NOT NULL, + "UserId" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_UnmuteTimer" ("Id", "DateAdded", "GuildId", "UnmuteAt", "UserId") +SELECT "Id", "DateAdded", "GuildId", "UnmuteAt", "UserId" +FROM "UnmuteTimer"; + +CREATE TABLE "ef_temp_UnroleTimer" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_UnroleTimer" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "RoleId" INTEGER NOT NULL, + "UnbanAt" TEXT NOT NULL, + "UserId" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_UnroleTimer" ("Id", "DateAdded", "GuildId", "RoleId", "UnbanAt", "UserId") +SELECT "Id", "DateAdded", "GuildId", "RoleId", "UnbanAt", "UserId" +FROM "UnroleTimer"; + +CREATE TABLE "ef_temp_VcRoleInfo" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_VcRoleInfo" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildId" INTEGER NOT NULL, + "RoleId" INTEGER NOT NULL, + "VoiceChannelId" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_VcRoleInfo" ("Id", "DateAdded", "GuildId", "RoleId", "VoiceChannelId") +SELECT "Id", "DateAdded", "GuildId", "RoleId", "VoiceChannelId" +FROM "VcRoleInfo"; + +CREATE TABLE "ef_temp_XpSettings" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_XpSettings" PRIMARY KEY AUTOINCREMENT, + "DateAdded" TEXT NULL, + "GuildConfigId" INTEGER NOT NULL, + "GuildId" INTEGER NOT NULL, + "ServerExcluded" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_XpSettings" ("Id", "DateAdded", "GuildConfigId", "GuildId", "ServerExcluded") +SELECT "Id", "DateAdded", "GuildConfigId", "GuildId", "ServerExcluded" +FROM "XpSettings"; + +CREATE TABLE "ef_temp_GuildConfigs" ( + "Id" INTEGER NOT NULL CONSTRAINT "PK_GuildConfigs" PRIMARY KEY AUTOINCREMENT, + "AutoAssignRoleIds" TEXT NULL, + "CleverbotEnabled" INTEGER NOT NULL, + "DateAdded" TEXT NULL, + "DeleteMessageOnCommand" INTEGER NOT NULL, + "DeleteStreamOnlineMessage" INTEGER NOT NULL, + "DisableGlobalExpressions" INTEGER NOT NULL, + "GameVoiceChannel" INTEGER NULL, + "GuildId" INTEGER NOT NULL, + "Locale" TEXT NULL, + "MuteRoleName" TEXT NULL, + "NotifyStreamOffline" INTEGER NOT NULL, + "PermissionRole" TEXT NULL, + "Prefix" TEXT NULL, + "StickyRoles" INTEGER NOT NULL, + "TimeZoneId" TEXT NULL, + "VerboseErrors" INTEGER NOT NULL DEFAULT 1, + "VerbosePermissions" INTEGER NOT NULL, + "WarnExpireAction" INTEGER NOT NULL, + "WarnExpireHours" INTEGER NOT NULL, + "WarningsInitialized" INTEGER NOT NULL +); + +INSERT INTO "ef_temp_GuildConfigs" ("Id", "AutoAssignRoleIds", "CleverbotEnabled", "DateAdded", "DeleteMessageOnCommand", "DeleteStreamOnlineMessage", "DisableGlobalExpressions", "GameVoiceChannel", "GuildId", "Locale", "MuteRoleName", "NotifyStreamOffline", "PermissionRole", "Prefix", "StickyRoles", "TimeZoneId", "VerboseErrors", "VerbosePermissions", "WarnExpireAction", "WarnExpireHours", "WarningsInitialized") +SELECT "Id", "AutoAssignRoleIds", "CleverbotEnabled", "DateAdded", "DeleteMessageOnCommand", "DeleteStreamOnlineMessage", "DisableGlobalExpressions", "GameVoiceChannel", "GuildId", "Locale", "MuteRoleName", "NotifyStreamOffline", "PermissionRole", "Prefix", "StickyRoles", "TimeZoneId", "VerboseErrors", "VerbosePermissions", "WarnExpireAction", "WarnExpireHours", "WarningsInitialized" +FROM "GuildConfigs"; + +COMMIT; + +PRAGMA foreign_keys = 0; + +BEGIN TRANSACTION; + +DROP TABLE "AntiAltSetting"; + +ALTER TABLE "ef_temp_AntiAltSetting" RENAME TO "AntiAltSetting"; + +DROP TABLE "AntiRaidSetting"; + +ALTER TABLE "ef_temp_AntiRaidSetting" RENAME TO "AntiRaidSetting"; + +DROP TABLE "AntiSpamSetting"; + +ALTER TABLE "ef_temp_AntiSpamSetting" RENAME TO "AntiSpamSetting"; + +DROP TABLE "CommandAlias"; + +ALTER TABLE "ef_temp_CommandAlias" RENAME TO "CommandAlias"; + +DROP TABLE "CommandCooldown"; + +ALTER TABLE "ef_temp_CommandCooldown" RENAME TO "CommandCooldown"; + +DROP TABLE "DelMsgOnCmdChannel"; + +ALTER TABLE "ef_temp_DelMsgOnCmdChannel" RENAME TO "DelMsgOnCmdChannel"; + +DROP TABLE "ExcludedItem"; + +ALTER TABLE "ef_temp_ExcludedItem" RENAME TO "ExcludedItem"; + +DROP TABLE "FeedSub"; + +ALTER TABLE "ef_temp_FeedSub" RENAME TO "FeedSub"; + +DROP TABLE "FilterChannelId"; + +ALTER TABLE "ef_temp_FilterChannelId" RENAME TO "FilterChannelId"; + +DROP TABLE "FilteredWord"; + +ALTER TABLE "ef_temp_FilteredWord" RENAME TO "FilteredWord"; + +DROP TABLE "FilterLinksChannelId"; + +ALTER TABLE "ef_temp_FilterLinksChannelId" RENAME TO "FilterLinksChannelId"; + +DROP TABLE "FilterWordsChannelId"; + +ALTER TABLE "ef_temp_FilterWordsChannelId" RENAME TO "FilterWordsChannelId"; + +DROP TABLE "FollowedStream"; + +ALTER TABLE "ef_temp_FollowedStream" RENAME TO "FollowedStream"; + +DROP TABLE "GCChannelId"; + +ALTER TABLE "ef_temp_GCChannelId" RENAME TO "GCChannelId"; + +DROP TABLE "MutedUserId"; + +ALTER TABLE "ef_temp_MutedUserId" RENAME TO "MutedUserId"; + +DROP TABLE "Permissions"; + +ALTER TABLE "ef_temp_Permissions" RENAME TO "Permissions"; + +DROP TABLE "ShopEntry"; + +ALTER TABLE "ef_temp_ShopEntry" RENAME TO "ShopEntry"; + +DROP TABLE "SlowmodeIgnoredRole"; + +ALTER TABLE "ef_temp_SlowmodeIgnoredRole" RENAME TO "SlowmodeIgnoredRole"; + +DROP TABLE "SlowmodeIgnoredUser"; + +ALTER TABLE "ef_temp_SlowmodeIgnoredUser" RENAME TO "SlowmodeIgnoredUser"; + +DROP TABLE "StreamRoleSettings"; + +ALTER TABLE "ef_temp_StreamRoleSettings" RENAME TO "StreamRoleSettings"; + +DROP TABLE "UnbanTimer"; + +ALTER TABLE "ef_temp_UnbanTimer" RENAME TO "UnbanTimer"; + +DROP TABLE "UnmuteTimer"; + +ALTER TABLE "ef_temp_UnmuteTimer" RENAME TO "UnmuteTimer"; + +DROP TABLE "UnroleTimer"; + +ALTER TABLE "ef_temp_UnroleTimer" RENAME TO "UnroleTimer"; + +DROP TABLE "VcRoleInfo"; + +ALTER TABLE "ef_temp_VcRoleInfo" RENAME TO "VcRoleInfo"; + +DROP TABLE "XpSettings"; + +ALTER TABLE "ef_temp_XpSettings" RENAME TO "XpSettings"; + +DROP TABLE "GuildConfigs"; + +ALTER TABLE "ef_temp_GuildConfigs" RENAME TO "GuildConfigs"; + +COMMIT; + +PRAGMA foreign_keys = 1; + +BEGIN TRANSACTION; + +CREATE UNIQUE INDEX "IX_AntiAltSetting_GuildId" ON "AntiAltSetting" ("GuildId"); + +CREATE UNIQUE INDEX "IX_AntiRaidSetting_GuildId" ON "AntiRaidSetting" ("GuildId"); + +CREATE UNIQUE INDEX "IX_AntiSpamSetting_GuildId" ON "AntiSpamSetting" ("GuildId"); + +CREATE INDEX "IX_CommandAlias_GuildId" ON "CommandAlias" ("GuildId"); + +CREATE UNIQUE INDEX "IX_CommandCooldown_GuildId_CommandName" ON "CommandCooldown" ("GuildId", "CommandName"); + +CREATE UNIQUE INDEX "IX_DelMsgOnCmdChannel_GuildId_ChannelId" ON "DelMsgOnCmdChannel" ("GuildId", "ChannelId"); + +CREATE INDEX "IX_ExcludedItem_XpSettingsId" ON "ExcludedItem" ("XpSettingsId"); + +CREATE UNIQUE INDEX "IX_FeedSub_GuildId_Url" ON "FeedSub" ("GuildId", "Url"); + +CREATE INDEX "IX_FilterChannelId_GuildFilterConfigId" ON "FilterChannelId" ("GuildFilterConfigId"); + +CREATE INDEX "IX_FilteredWord_GuildFilterConfigId" ON "FilteredWord" ("GuildFilterConfigId"); + +CREATE INDEX "IX_FilterLinksChannelId_GuildFilterConfigId" ON "FilterLinksChannelId" ("GuildFilterConfigId"); + +CREATE INDEX "IX_FilterWordsChannelId_GuildFilterConfigId" ON "FilterWordsChannelId" ("GuildFilterConfigId"); + +CREATE INDEX "IX_FollowedStream_GuildId_Username_Type" ON "FollowedStream" ("GuildId", "Username", "Type"); + +CREATE UNIQUE INDEX "IX_GCChannelId_GuildId_ChannelId" ON "GCChannelId" ("GuildId", "ChannelId"); + +CREATE UNIQUE INDEX "IX_MutedUserId_GuildId_UserId" ON "MutedUserId" ("GuildId", "UserId"); + +CREATE INDEX "IX_Permissions_GuildConfigId" ON "Permissions" ("GuildConfigId"); + +CREATE INDEX "IX_Permissions_GuildId" ON "Permissions" ("GuildId"); + +CREATE UNIQUE INDEX "IX_ShopEntry_GuildId_Index" ON "ShopEntry" ("GuildId", "Index"); + +CREATE UNIQUE INDEX "IX_SlowmodeIgnoredRole_GuildId_RoleId" ON "SlowmodeIgnoredRole" ("GuildId", "RoleId"); + +CREATE UNIQUE INDEX "IX_SlowmodeIgnoredUser_GuildId_UserId" ON "SlowmodeIgnoredUser" ("GuildId", "UserId"); + +CREATE UNIQUE INDEX "IX_StreamRoleSettings_GuildId" ON "StreamRoleSettings" ("GuildId"); + +CREATE UNIQUE INDEX "IX_UnbanTimer_GuildId_UserId" ON "UnbanTimer" ("GuildId", "UserId"); + +CREATE UNIQUE INDEX "IX_UnmuteTimer_GuildId_UserId" ON "UnmuteTimer" ("GuildId", "UserId"); + +CREATE UNIQUE INDEX "IX_UnroleTimer_GuildId_UserId" ON "UnroleTimer" ("GuildId", "UserId"); + +CREATE UNIQUE INDEX "IX_VcRoleInfo_GuildId_VoiceChannelId" ON "VcRoleInfo" ("GuildId", "VoiceChannelId"); + +CREATE UNIQUE INDEX "IX_XpSettings_GuildId" ON "XpSettings" ("GuildId"); + +CREATE UNIQUE INDEX "IX_GuildConfigs_GuildId" ON "GuildConfigs" ("GuildId"); + +CREATE INDEX "IX_GuildConfigs_WarnExpireHours" ON "GuildConfigs" ("WarnExpireHours"); + +INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") +VALUES ('20250126062816_cleanup', '8.0.8'); + +COMMIT; \ No newline at end of file diff --git a/src/EllieBot/Migrations/Sqlite/20250124023317_init.Designer.cs b/src/EllieBot/Migrations/Sqlite/20250127062834_init.Designer.cs similarity index 88% rename from src/EllieBot/Migrations/Sqlite/20250124023317_init.Designer.cs rename to src/EllieBot/Migrations/Sqlite/20250127062834_init.Designer.cs index 85ad68c..6e40885 100644 --- a/src/EllieBot/Migrations/Sqlite/20250124023317_init.Designer.cs +++ b/src/EllieBot/Migrations/Sqlite/20250127062834_init.Designer.cs @@ -11,7 +11,7 @@ using EllieBot.Db; namespace EllieBot.Migrations.Sqlite { [DbContext(typeof(SqliteContext))] - [Migration("20250124023317_init")] + [Migration("20250127062834_init")] partial class init { /// <inheritdoc /> @@ -35,6 +35,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<int>("GuildConfigId") .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + b.Property<TimeSpan>("MinAge") .HasColumnType("TEXT"); @@ -43,7 +46,7 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique(); b.ToTable("AntiAltSetting"); @@ -64,6 +67,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<int>("GuildConfigId") .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + b.Property<int>("PunishDuration") .HasColumnType("INTEGER"); @@ -75,7 +81,7 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique(); b.ToTable("AntiRaidSetting"); @@ -118,6 +124,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<int>("GuildConfigId") .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + b.Property<int>("MessageThreshold") .HasColumnType("INTEGER"); @@ -129,7 +138,7 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique(); b.ToTable("AntiSpamSetting"); @@ -461,7 +470,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<string>("Mapping") @@ -472,7 +481,7 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId"); b.ToTable("CommandAlias"); }); @@ -489,7 +498,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<int>("Seconds") @@ -497,7 +506,8 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "CommandName") + .IsUnique(); b.ToTable("CommandCooldown"); }); @@ -555,12 +565,16 @@ namespace EllieBot.Migrations.Sqlite b.Property<int>("GuildConfigId") .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + b.Property<bool>("State") .HasColumnType("INTEGER"); b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "ChannelId") + .IsUnique(); b.ToTable("DelMsgOnCmdChannel"); }); @@ -689,16 +703,19 @@ namespace EllieBot.Migrations.Sqlite b.Property<int>("GuildConfigId") .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + b.Property<string>("Message") .HasColumnType("TEXT"); b.Property<string>("Url") - .IsRequired() .HasColumnType("TEXT"); b.HasKey("Id"); - b.HasAlternateKey("GuildConfigId", "Url"); + b.HasIndex("GuildId", "Url") + .IsUnique(); b.ToTable("FeedSub"); }); @@ -712,15 +729,12 @@ namespace EllieBot.Migrations.Sqlite b.Property<ulong>("ChannelId") .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); - - b.Property<int?>("GuildConfigId") + b.Property<int?>("GuildFilterConfigId") .HasColumnType("INTEGER"); b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildFilterConfigId"); b.ToTable("FilterChannelId"); }); @@ -737,12 +751,12 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<int?>("GuildFilterConfigId") .HasColumnType("INTEGER"); b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildFilterConfigId"); b.ToTable("FilterLinksChannelId"); }); @@ -759,12 +773,12 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<int?>("GuildFilterConfigId") .HasColumnType("INTEGER"); b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildFilterConfigId"); b.ToTable("FilterWordsChannelId"); }); @@ -778,7 +792,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<int?>("GuildFilterConfigId") .HasColumnType("INTEGER"); b.Property<string>("Word") @@ -786,7 +800,7 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildFilterConfigId"); b.ToTable("FilteredWord"); }); @@ -823,12 +837,6 @@ namespace EllieBot.Migrations.Sqlite b.Property<ulong>("ChannelId") .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); - - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -843,7 +851,7 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "Username", "Type"); b.ToTable("FollowedStream"); }); @@ -860,12 +868,13 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "ChannelId") + .IsUnique(); b.ToTable("GCChannelId"); }); @@ -983,9 +992,6 @@ namespace EllieBot.Migrations.Sqlite b.Property<string>("AutoAssignRoleIds") .HasColumnType("TEXT"); - b.Property<bool>("AutoDeleteSelfAssignedRoleMessages") - .HasColumnType("INTEGER"); - b.Property<bool>("CleverbotEnabled") .HasColumnType("INTEGER"); @@ -1001,18 +1007,6 @@ namespace EllieBot.Migrations.Sqlite b.Property<bool>("DisableGlobalExpressions") .HasColumnType("INTEGER"); - b.Property<bool>("ExclusiveSelfAssignedRoles") - .HasColumnType("INTEGER"); - - b.Property<bool>("FilterInvites") - .HasColumnType("INTEGER"); - - b.Property<bool>("FilterLinks") - .HasColumnType("INTEGER"); - - b.Property<bool>("FilterWords") - .HasColumnType("INTEGER"); - b.Property<ulong?>("GameVoiceChannel") .HasColumnType("INTEGER"); @@ -1067,6 +1061,31 @@ namespace EllieBot.Migrations.Sqlite b.ToTable("GuildConfigs"); }); + modelBuilder.Entity("EllieBot.Db.Models.GuildFilterConfig", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<bool>("FilterInvites") + .HasColumnType("INTEGER"); + + b.Property<bool>("FilterLinks") + .HasColumnType("INTEGER"); + + b.Property<bool>("FilterWords") + .HasColumnType("INTEGER"); + + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("GuildId"); + + b.ToTable("GuildFilterConfig"); + }); + modelBuilder.Entity("EllieBot.Db.Models.HoneypotChannel", b => { b.Property<ulong>("GuildId") @@ -1276,7 +1295,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<ulong>("UserId") @@ -1284,7 +1303,8 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); b.ToTable("MutedUserId"); }); @@ -1424,6 +1444,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<int?>("GuildConfigId") .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + b.Property<int>("Index") .HasColumnType("INTEGER"); @@ -1449,6 +1472,8 @@ namespace EllieBot.Migrations.Sqlite b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId"); + b.ToTable("Permissions"); }); @@ -1812,7 +1837,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<int>("Index") @@ -1838,7 +1863,8 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "Index") + .IsUnique(); b.ToTable("ShopEntry"); }); @@ -1874,7 +1900,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<ulong>("RoleId") @@ -1882,7 +1908,8 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "RoleId") + .IsUnique(); b.ToTable("SlowmodeIgnoredRole"); }); @@ -1896,7 +1923,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<ulong>("UserId") @@ -1904,7 +1931,8 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); b.ToTable("SlowmodeIgnoredUser"); }); @@ -2007,12 +2035,15 @@ namespace EllieBot.Migrations.Sqlite b.Property<int>("GuildConfigId") .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + b.Property<string>("Keyword") .HasColumnType("TEXT"); b.HasKey("Id"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique(); b.ToTable("StreamRoleSettings"); @@ -2112,7 +2143,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<DateTime>("UnbanAt") @@ -2123,7 +2154,8 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); b.ToTable("UnbanTimer"); }); @@ -2137,7 +2169,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<DateTime>("UnmuteAt") @@ -2148,7 +2180,8 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); b.ToTable("UnmuteTimer"); }); @@ -2162,7 +2195,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<ulong>("RoleId") @@ -2176,7 +2209,8 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); b.ToTable("UnroleTimer"); }); @@ -2222,7 +2256,7 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); b.Property<ulong>("RoleId") @@ -2233,7 +2267,8 @@ namespace EllieBot.Migrations.Sqlite b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "VoiceChannelId") + .IsUnique(); b.ToTable("VcRoleInfo"); }); @@ -2426,6 +2461,9 @@ namespace EllieBot.Migrations.Sqlite b.HasIndex("XpSettingsId"); + b.HasIndex("Level", "XpSettingsId") + .IsUnique(); + b.ToTable("XpCurrencyReward"); }); @@ -2470,12 +2508,15 @@ namespace EllieBot.Migrations.Sqlite b.Property<int>("GuildConfigId") .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + b.Property<bool>("ServerExcluded") .HasColumnType("INTEGER"); b.HasKey("Id"); - b.HasIndex("GuildConfigId") + b.HasIndex("GuildId") .IsUnique(); b.ToTable("XpSettings"); @@ -2646,24 +2687,6 @@ namespace EllieBot.Migrations.Sqlite b.ToTable("UserBetStats"); }); - modelBuilder.Entity("EllieBot.Db.Models.AntiAltSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiAltSetting") - .HasForeignKey("EllieBot.Db.Models.AntiAltSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("EllieBot.Db.Models.AntiRaidSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiRaidSetting") - .HasForeignKey("EllieBot.Db.Models.AntiRaidSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - modelBuilder.Entity("EllieBot.Db.Models.AntiSpamIgnore", b => { b.HasOne("EllieBot.Db.Models.AntiSpamSetting", null) @@ -2672,15 +2695,6 @@ namespace EllieBot.Migrations.Sqlite .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiSpamSetting") - .HasForeignKey("EllieBot.Db.Models.AntiSpamSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateUser", b => { b.HasOne("EllieBot.Db.Models.AutoTranslateChannel", "Channel") @@ -2740,31 +2754,6 @@ namespace EllieBot.Migrations.Sqlite b.Navigation("Owner"); }); - modelBuilder.Entity("EllieBot.Db.Models.CommandAlias", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("CommandAliases") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.CommandCooldown", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("CommandCooldowns") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.DelMsgOnCmdChannel", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("DelMsgOnCmdChannels") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - modelBuilder.Entity("EllieBot.Db.Models.DiscordUser", b => { b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") @@ -2777,73 +2766,37 @@ namespace EllieBot.Migrations.Sqlite modelBuilder.Entity("EllieBot.Db.Models.ExcludedItem", b => { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") + b.HasOne("EllieBot.Db.Models.XpSettings", null) .WithMany("ExclusionList") - .HasForeignKey("XpSettingsId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("XpSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.FeedSub", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithMany("FeedSubs") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("GuildConfig"); + .HasForeignKey("XpSettingsId"); }); modelBuilder.Entity("EllieBot.Db.Models.FilterChannelId", b => { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) .WithMany("FilterInvitesChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); + .HasForeignKey("GuildFilterConfigId"); }); modelBuilder.Entity("EllieBot.Db.Models.FilterLinksChannelId", b => { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) .WithMany("FilterLinksChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); + .HasForeignKey("GuildFilterConfigId"); }); modelBuilder.Entity("EllieBot.Db.Models.FilterWordsChannelId", b => { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) .WithMany("FilterWordsChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); + .HasForeignKey("GuildFilterConfigId"); }); modelBuilder.Entity("EllieBot.Db.Models.FilteredWord", b => { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) .WithMany("FilteredWords") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.FollowedStream", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FollowedStreams") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.GCChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithMany("GenerateCurrencyChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("GuildConfig"); + .HasForeignKey("GuildFilterConfigId"); }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayUser", b => @@ -2866,20 +2819,11 @@ namespace EllieBot.Migrations.Sqlite b.Navigation("LogSetting"); }); - modelBuilder.Entity("EllieBot.Db.Models.MutedUserId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("MutedUsers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("EllieBot.Db.Models.Permissionv2", b => { b.HasOne("EllieBot.Db.Models.GuildConfig", null) .WithMany("Permissions") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); + .HasForeignKey("GuildConfigId"); }); modelBuilder.Entity("EllieBot.Db.Models.PlaylistSong", b => @@ -2899,14 +2843,6 @@ namespace EllieBot.Migrations.Sqlite .IsRequired(); }); - modelBuilder.Entity("EllieBot.Db.Models.ShopEntry", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("ShopEntries") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("EllieBot.Db.Models.ShopEntryItem", b => { b.HasOne("EllieBot.Db.Models.ShopEntry", null) @@ -2915,22 +2851,6 @@ namespace EllieBot.Migrations.Sqlite .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredRole", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("SlowmodeIgnoredRoles") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredUser", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("SlowmodeIgnoredUsers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("EllieBot.Db.Models.StreamRoleBlacklistedUser", b => { b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") @@ -2942,17 +2862,6 @@ namespace EllieBot.Migrations.Sqlite b.Navigation("StreamRoleSettings"); }); - modelBuilder.Entity("EllieBot.Db.Models.StreamRoleSettings", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithOne("StreamRole") - .HasForeignKey("EllieBot.Db.Models.StreamRoleSettings", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("GuildConfig"); - }); - modelBuilder.Entity("EllieBot.Db.Models.StreamRoleWhitelistedUser", b => { b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") @@ -2972,38 +2881,6 @@ namespace EllieBot.Migrations.Sqlite .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("EllieBot.Db.Models.UnbanTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnbanTimer") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnmuteTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnmuteTimers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnroleTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnroleTimer") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.VcRoleInfo", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("VcRoleInfos") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("EllieBot.Db.Models.WaifuInfo", b => { b.HasOne("EllieBot.Db.Models.DiscordUser", "Affinity") @@ -3061,35 +2938,20 @@ namespace EllieBot.Migrations.Sqlite modelBuilder.Entity("EllieBot.Db.Models.XpCurrencyReward", b => { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") + b.HasOne("EllieBot.Db.Models.XpSettings", null) .WithMany("CurrencyRewards") .HasForeignKey("XpSettingsId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - - b.Navigation("XpSettings"); }); modelBuilder.Entity("EllieBot.Db.Models.XpRoleReward", b => { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") + b.HasOne("EllieBot.Db.Models.XpSettings", null) .WithMany("RoleRewards") .HasForeignKey("XpSettingsId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - - b.Navigation("XpSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.XpSettings", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithOne("XpSettings") - .HasForeignKey("EllieBot.Db.Models.XpSettings", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("GuildConfig"); }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => @@ -3123,20 +2985,11 @@ namespace EllieBot.Migrations.Sqlite modelBuilder.Entity("EllieBot.Db.Models.GuildConfig", b => { - b.Navigation("AntiAltSetting"); - - b.Navigation("AntiRaidSetting"); - - b.Navigation("AntiSpamSetting"); - - b.Navigation("CommandAliases"); - - b.Navigation("CommandCooldowns"); - - b.Navigation("DelMsgOnCmdChannels"); - - b.Navigation("FeedSubs"); + b.Navigation("Permissions"); + }); + modelBuilder.Entity("EllieBot.Db.Models.GuildFilterConfig", b => + { b.Navigation("FilterInvitesChannelIds"); b.Navigation("FilterLinksChannelIds"); @@ -3144,32 +2997,6 @@ namespace EllieBot.Migrations.Sqlite b.Navigation("FilterWordsChannelIds"); b.Navigation("FilteredWords"); - - b.Navigation("FollowedStreams"); - - b.Navigation("GenerateCurrencyChannelIds"); - - b.Navigation("MutedUsers"); - - b.Navigation("Permissions"); - - b.Navigation("ShopEntries"); - - b.Navigation("SlowmodeIgnoredRoles"); - - b.Navigation("SlowmodeIgnoredUsers"); - - b.Navigation("StreamRole"); - - b.Navigation("UnbanTimer"); - - b.Navigation("UnmuteTimers"); - - b.Navigation("UnroleTimer"); - - b.Navigation("VcRoleInfos"); - - b.Navigation("XpSettings"); }); modelBuilder.Entity("EllieBot.Db.Models.LogSetting", b => diff --git a/src/EllieBot/Migrations/Sqlite/20250124023317_init.cs b/src/EllieBot/Migrations/Sqlite/20250127062834_init.cs similarity index 90% rename from src/EllieBot/Migrations/Sqlite/20250124023317_init.cs rename to src/EllieBot/Migrations/Sqlite/20250127062834_init.cs index 99d865f..b91fdd7 100644 --- a/src/EllieBot/Migrations/Sqlite/20250124023317_init.cs +++ b/src/EllieBot/Migrations/Sqlite/20250127062834_init.cs @@ -11,6 +11,62 @@ namespace EllieBot.Migrations.Sqlite /// <inheritdoc /> protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "AntiAltSetting", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + MinAge = table.Column<TimeSpan>(type: "TEXT", nullable: false), + Action = table.Column<int>(type: "INTEGER", nullable: false), + ActionDurationMinutes = table.Column<int>(type: "INTEGER", nullable: false), + RoleId = table.Column<ulong>(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AntiAltSetting", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AntiRaidSetting", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + UserThreshold = table.Column<int>(type: "INTEGER", nullable: false), + Seconds = table.Column<int>(type: "INTEGER", nullable: false), + Action = table.Column<int>(type: "INTEGER", nullable: false), + PunishDuration = table.Column<int>(type: "INTEGER", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AntiRaidSetting", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AntiSpamSetting", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + Action = table.Column<int>(type: "INTEGER", nullable: false), + MessageThreshold = table.Column<int>(type: "INTEGER", nullable: false), + MuteTime = table.Column<int>(type: "INTEGER", nullable: false), + RoleId = table.Column<ulong>(type: "INTEGER", nullable: true), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AntiSpamSetting", x => x.Id); + }); + migrationBuilder.CreateTable( name: "AutoCommands", columns: table => new @@ -131,6 +187,38 @@ namespace EllieBot.Migrations.Sqlite table.UniqueConstraint("AK_ButtonRole_RoleId_MessageId", x => new { x.RoleId, x.MessageId }); }); + migrationBuilder.CreateTable( + name: "CommandAlias", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + Trigger = table.Column<string>(type: "TEXT", nullable: true), + Mapping = table.Column<string>(type: "TEXT", nullable: true), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CommandAlias", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CommandCooldown", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + Seconds = table.Column<int>(type: "INTEGER", nullable: false), + CommandName = table.Column<string>(type: "TEXT", nullable: true), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CommandCooldown", x => x.Id); + }); + migrationBuilder.CreateTable( name: "CurrencyTransactions", columns: table => new @@ -150,6 +238,23 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_CurrencyTransactions", x => x.Id); }); + migrationBuilder.CreateTable( + name: "DelMsgOnCmdChannel", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), + State = table.Column<bool>(type: "INTEGER", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_DelMsgOnCmdChannel", x => x.Id); + }); + migrationBuilder.CreateTable( name: "DiscordPermOverrides", columns: table => new @@ -187,6 +292,24 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_Expressions", x => x.Id); }); + migrationBuilder.CreateTable( + name: "FeedSub", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), + Url = table.Column<string>(type: "TEXT", nullable: true), + Message = table.Column<string>(type: "TEXT", nullable: true), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_FeedSub", x => x.Id); + }); + migrationBuilder.CreateTable( name: "FishCatch", columns: table => new @@ -219,6 +342,23 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_FlagTranslateChannel", x => x.Id); }); + migrationBuilder.CreateTable( + name: "FollowedStream", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), + Username = table.Column<string>(type: "TEXT", nullable: true), + Type = table.Column<int>(type: "INTEGER", nullable: false), + Message = table.Column<string>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_FollowedStream", x => x.Id); + }); + migrationBuilder.CreateTable( name: "GamblingStats", columns: table => new @@ -235,6 +375,21 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_GamblingStats", x => x.Id); }); + migrationBuilder.CreateTable( + name: "GCChannelId", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GCChannelId", x => x.Id); + }); + migrationBuilder.CreateTable( name: "GiveawayModel", columns: table => new @@ -296,17 +451,10 @@ namespace EllieBot.Migrations.Sqlite Prefix = table.Column<string>(type: "TEXT", nullable: true), DeleteMessageOnCommand = table.Column<bool>(type: "INTEGER", nullable: false), AutoAssignRoleIds = table.Column<string>(type: "TEXT", nullable: true), - ExclusiveSelfAssignedRoles = table.Column<bool>(type: "INTEGER", nullable: false), - AutoDeleteSelfAssignedRoleMessages = table.Column<bool>(type: "INTEGER", nullable: false), VerbosePermissions = table.Column<bool>(type: "INTEGER", nullable: false), PermissionRole = table.Column<string>(type: "TEXT", nullable: true), - FilterInvites = table.Column<bool>(type: "INTEGER", nullable: false), - FilterLinks = table.Column<bool>(type: "INTEGER", nullable: false), - FilterWords = table.Column<bool>(type: "INTEGER", nullable: false), MuteRoleName = table.Column<string>(type: "TEXT", nullable: true), CleverbotEnabled = table.Column<bool>(type: "INTEGER", nullable: false), - Locale = table.Column<string>(type: "TEXT", nullable: true), - TimeZoneId = table.Column<string>(type: "TEXT", nullable: true), WarningsInitialized = table.Column<bool>(type: "INTEGER", nullable: false), GameVoiceChannel = table.Column<ulong>(type: "INTEGER", nullable: true), VerboseErrors = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: true), @@ -316,6 +464,8 @@ namespace EllieBot.Migrations.Sqlite WarnExpireAction = table.Column<int>(type: "INTEGER", nullable: false), DisableGlobalExpressions = table.Column<bool>(type: "INTEGER", nullable: false), StickyRoles = table.Column<bool>(type: "INTEGER", nullable: false), + TimeZoneId = table.Column<string>(type: "TEXT", nullable: true), + Locale = table.Column<string>(type: "TEXT", nullable: true), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, constraints: table => @@ -323,6 +473,22 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_GuildConfigs", x => x.Id); }); + migrationBuilder.CreateTable( + name: "GuildFilterConfig", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + FilterInvites = table.Column<bool>(type: "INTEGER", nullable: false), + FilterLinks = table.Column<bool>(type: "INTEGER", nullable: false), + FilterWords = table.Column<bool>(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GuildFilterConfig", x => x.Id); + }); + migrationBuilder.CreateTable( name: "HoneyPotChannels", columns: table => new @@ -419,6 +585,21 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_MusicPlaylists", x => x.Id); }); + migrationBuilder.CreateTable( + name: "MutedUserId", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + UserId = table.Column<ulong>(type: "INTEGER", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_MutedUserId", x => x.Id); + }); + migrationBuilder.CreateTable( name: "NCPixel", columns: table => new @@ -644,6 +825,59 @@ namespace EllieBot.Migrations.Sqlite table.UniqueConstraint("AK_SarGroup_GuildId_GroupNumber", x => new { x.GuildId, x.GroupNumber }); }); + migrationBuilder.CreateTable( + name: "ShopEntry", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + Index = table.Column<int>(type: "INTEGER", nullable: false), + Price = table.Column<int>(type: "INTEGER", nullable: false), + Name = table.Column<string>(type: "TEXT", nullable: true), + AuthorId = table.Column<ulong>(type: "INTEGER", nullable: false), + Type = table.Column<int>(type: "INTEGER", nullable: false), + RoleName = table.Column<string>(type: "TEXT", nullable: true), + RoleId = table.Column<ulong>(type: "INTEGER", nullable: false), + RoleRequirement = table.Column<ulong>(type: "INTEGER", nullable: true), + Command = table.Column<string>(type: "TEXT", nullable: true), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ShopEntry", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "SlowmodeIgnoredRole", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + RoleId = table.Column<ulong>(type: "INTEGER", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SlowmodeIgnoredRole", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "SlowmodeIgnoredUser", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + UserId = table.Column<ulong>(type: "INTEGER", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SlowmodeIgnoredUser", x => x.Id); + }); + migrationBuilder.CreateTable( name: "StickyRoles", columns: table => new @@ -677,6 +911,25 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_StreamOnlineMessages", x => x.Id); }); + migrationBuilder.CreateTable( + name: "StreamRoleSettings", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + Enabled = table.Column<bool>(type: "INTEGER", nullable: false), + AddRoleId = table.Column<ulong>(type: "INTEGER", nullable: false), + FromRoleId = table.Column<ulong>(type: "INTEGER", nullable: false), + Keyword = table.Column<string>(type: "TEXT", nullable: true), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_StreamRoleSettings", x => x.Id); + }); + migrationBuilder.CreateTable( name: "TempRole", columns: table => new @@ -709,6 +962,55 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_TodosArchive", x => x.Id); }); + migrationBuilder.CreateTable( + name: "UnbanTimer", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + UserId = table.Column<ulong>(type: "INTEGER", nullable: false), + UnbanAt = table.Column<DateTime>(type: "TEXT", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UnbanTimer", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "UnmuteTimer", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + UserId = table.Column<ulong>(type: "INTEGER", nullable: false), + UnmuteAt = table.Column<DateTime>(type: "TEXT", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UnmuteTimer", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "UnroleTimer", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + UserId = table.Column<ulong>(type: "INTEGER", nullable: false), + RoleId = table.Column<ulong>(type: "INTEGER", nullable: false), + UnbanAt = table.Column<DateTime>(type: "TEXT", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UnroleTimer", x => x.Id); + }); + migrationBuilder.CreateTable( name: "UserBetStats", columns: table => new @@ -759,6 +1061,22 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_UserXpStats", x => x.Id); }); + migrationBuilder.CreateTable( + name: "VcRoleInfo", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + VoiceChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), + RoleId = table.Column<ulong>(type: "INTEGER", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_VcRoleInfo", x => x.Id); + }); + migrationBuilder.CreateTable( name: "WarningPunishment", columns: table => new @@ -798,6 +1116,22 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_Warnings", x => x.Id); }); + migrationBuilder.CreateTable( + name: "XpSettings", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), + ServerExcluded = table.Column<bool>(type: "INTEGER", nullable: false), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_XpSettings", x => x.Id); + }); + migrationBuilder.CreateTable( name: "XpShopOwnedItem", columns: table => new @@ -815,6 +1149,27 @@ namespace EllieBot.Migrations.Sqlite table.PrimaryKey("PK_XpShopOwnedItem", x => x.Id); }); + migrationBuilder.CreateTable( + name: "AntiSpamIgnore", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), + AntiSpamSettingId = table.Column<int>(type: "INTEGER", nullable: true), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AntiSpamIgnore", x => x.Id); + table.ForeignKey( + name: "FK_AntiSpamIgnore_AntiSpamSetting_AntiSpamSettingId", + column: x => x.AntiSpamSettingId, + principalTable: "AntiSpamSetting", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "AutoTranslateUsers", columns: table => new @@ -860,325 +1215,13 @@ namespace EllieBot.Migrations.Sqlite onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "AntiAltSetting", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), - MinAge = table.Column<TimeSpan>(type: "TEXT", nullable: false), - Action = table.Column<int>(type: "INTEGER", nullable: false), - ActionDurationMinutes = table.Column<int>(type: "INTEGER", nullable: false), - RoleId = table.Column<ulong>(type: "INTEGER", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AntiAltSetting", x => x.Id); - table.ForeignKey( - name: "FK_AntiAltSetting_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AntiRaidSetting", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), - UserThreshold = table.Column<int>(type: "INTEGER", nullable: false), - Seconds = table.Column<int>(type: "INTEGER", nullable: false), - Action = table.Column<int>(type: "INTEGER", nullable: false), - PunishDuration = table.Column<int>(type: "INTEGER", nullable: false), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AntiRaidSetting", x => x.Id); - table.ForeignKey( - name: "FK_AntiRaidSetting_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AntiSpamSetting", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), - Action = table.Column<int>(type: "INTEGER", nullable: false), - MessageThreshold = table.Column<int>(type: "INTEGER", nullable: false), - MuteTime = table.Column<int>(type: "INTEGER", nullable: false), - RoleId = table.Column<ulong>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AntiSpamSetting", x => x.Id); - table.ForeignKey( - name: "FK_AntiSpamSetting_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CommandAlias", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Trigger = table.Column<string>(type: "TEXT", nullable: true), - Mapping = table.Column<string>(type: "TEXT", nullable: true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CommandAlias", x => x.Id); - table.ForeignKey( - name: "FK_CommandAlias_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CommandCooldown", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Seconds = table.Column<int>(type: "INTEGER", nullable: false), - CommandName = table.Column<string>(type: "TEXT", nullable: true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_CommandCooldown", x => x.Id); - table.ForeignKey( - name: "FK_CommandCooldown_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "DelMsgOnCmdChannel", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - State = table.Column<bool>(type: "INTEGER", nullable: false), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_DelMsgOnCmdChannel", x => x.Id); - table.ForeignKey( - name: "FK_DelMsgOnCmdChannel_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FeedSub", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - Url = table.Column<string>(type: "TEXT", nullable: false), - Message = table.Column<string>(type: "TEXT", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_FeedSub", x => x.Id); - table.UniqueConstraint("AK_FeedSub_GuildConfigId_Url", x => new { x.GuildConfigId, x.Url }); - table.ForeignKey( - name: "FK_FeedSub_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FilterChannelId", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_FilterChannelId", x => x.Id); - table.ForeignKey( - name: "FK_FilterChannelId_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FilteredWord", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Word = table.Column<string>(type: "TEXT", nullable: true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_FilteredWord", x => x.Id); - table.ForeignKey( - name: "FK_FilteredWord_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FilterLinksChannelId", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_FilterLinksChannelId", x => x.Id); - table.ForeignKey( - name: "FK_FilterLinksChannelId_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FilterWordsChannelId", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_FilterWordsChannelId", x => x.Id); - table.ForeignKey( - name: "FK_FilterWordsChannelId_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FollowedStream", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - Username = table.Column<string>(type: "TEXT", nullable: true), - Type = table.Column<int>(type: "INTEGER", nullable: false), - Message = table.Column<string>(type: "TEXT", nullable: true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_FollowedStream", x => x.Id); - table.ForeignKey( - name: "FK_FollowedStream_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "GCChannelId", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_GCChannelId", x => x.Id); - table.ForeignKey( - name: "FK_GCChannelId_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "MutedUserId", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column<ulong>(type: "INTEGER", nullable: false), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_MutedUserId", x => x.Id); - table.ForeignKey( - name: "FK_MutedUserId_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "Permissions", columns: table => new { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), + GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), Index = table.Column<int>(type: "INTEGER", nullable: false), PrimaryTarget = table.Column<int>(type: "INTEGER", nullable: false), PrimaryTargetId = table.Column<ulong>(type: "INTEGER", nullable: false), @@ -1186,6 +1229,7 @@ namespace EllieBot.Migrations.Sqlite SecondaryTargetName = table.Column<string>(type: "TEXT", nullable: true), IsCustomCommand = table.Column<bool>(type: "INTEGER", nullable: false), State = table.Column<bool>(type: "INTEGER", nullable: false), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, constraints: table => @@ -1195,213 +1239,86 @@ namespace EllieBot.Migrations.Sqlite name: "FK_Permissions_GuildConfigs_GuildConfigId", column: x => x.GuildConfigId, principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( - name: "ShopEntry", + name: "FilterChannelId", columns: table => new { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - Index = table.Column<int>(type: "INTEGER", nullable: false), - Price = table.Column<int>(type: "INTEGER", nullable: false), - Name = table.Column<string>(type: "TEXT", nullable: true), - AuthorId = table.Column<ulong>(type: "INTEGER", nullable: false), - Type = table.Column<int>(type: "INTEGER", nullable: false), - RoleName = table.Column<string>(type: "TEXT", nullable: true), - RoleId = table.Column<ulong>(type: "INTEGER", nullable: false), - RoleRequirement = table.Column<ulong>(type: "INTEGER", nullable: true), - Command = table.Column<string>(type: "TEXT", nullable: true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), + GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_ShopEntry", x => x.Id); + table.PrimaryKey("PK_FilterChannelId", x => x.Id); table.ForeignKey( - name: "FK_ShopEntry_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + name: "FK_FilterChannelId_GuildFilterConfig_GuildFilterConfigId", + column: x => x.GuildFilterConfigId, + principalTable: "GuildFilterConfig", + principalColumn: "Id"); }); migrationBuilder.CreateTable( - name: "SlowmodeIgnoredRole", + name: "FilteredWord", columns: table => new { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - RoleId = table.Column<ulong>(type: "INTEGER", nullable: false), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), + Word = table.Column<string>(type: "TEXT", nullable: true), + GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_SlowmodeIgnoredRole", x => x.Id); + table.PrimaryKey("PK_FilteredWord", x => x.Id); table.ForeignKey( - name: "FK_SlowmodeIgnoredRole_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + name: "FK_FilteredWord_GuildFilterConfig_GuildFilterConfigId", + column: x => x.GuildFilterConfigId, + principalTable: "GuildFilterConfig", + principalColumn: "Id"); }); migrationBuilder.CreateTable( - name: "SlowmodeIgnoredUser", + name: "FilterLinksChannelId", columns: table => new { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column<ulong>(type: "INTEGER", nullable: false), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), + GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_SlowmodeIgnoredUser", x => x.Id); + table.PrimaryKey("PK_FilterLinksChannelId", x => x.Id); table.ForeignKey( - name: "FK_SlowmodeIgnoredUser_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + name: "FK_FilterLinksChannelId_GuildFilterConfig_GuildFilterConfigId", + column: x => x.GuildFilterConfigId, + principalTable: "GuildFilterConfig", + principalColumn: "Id"); }); migrationBuilder.CreateTable( - name: "StreamRoleSettings", + name: "FilterWordsChannelId", columns: table => new { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), - Enabled = table.Column<bool>(type: "INTEGER", nullable: false), - AddRoleId = table.Column<ulong>(type: "INTEGER", nullable: false), - FromRoleId = table.Column<ulong>(type: "INTEGER", nullable: false), - Keyword = table.Column<string>(type: "TEXT", nullable: true), + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), + GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_StreamRoleSettings", x => x.Id); + table.PrimaryKey("PK_FilterWordsChannelId", x => x.Id); table.ForeignKey( - name: "FK_StreamRoleSettings_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UnbanTimer", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column<ulong>(type: "INTEGER", nullable: false), - UnbanAt = table.Column<DateTime>(type: "TEXT", nullable: false), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_UnbanTimer", x => x.Id); - table.ForeignKey( - name: "FK_UnbanTimer_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UnmuteTimer", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column<ulong>(type: "INTEGER", nullable: false), - UnmuteAt = table.Column<DateTime>(type: "TEXT", nullable: false), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_UnmuteTimer", x => x.Id); - table.ForeignKey( - name: "FK_UnmuteTimer_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UnroleTimer", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column<ulong>(type: "INTEGER", nullable: false), - RoleId = table.Column<ulong>(type: "INTEGER", nullable: false), - UnbanAt = table.Column<DateTime>(type: "TEXT", nullable: false), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_UnroleTimer", x => x.Id); - table.ForeignKey( - name: "FK_UnroleTimer_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "VcRoleInfo", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - VoiceChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - RoleId = table.Column<ulong>(type: "INTEGER", nullable: false), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_VcRoleInfo", x => x.Id); - table.ForeignKey( - name: "FK_VcRoleInfo_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "XpSettings", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), - ServerExcluded = table.Column<bool>(type: "INTEGER", nullable: false), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_XpSettings", x => x.Id); - table.ForeignKey( - name: "FK_XpSettings_GuildConfigs_GuildConfigId", - column: x => x.GuildConfigId, - principalTable: "GuildConfigs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + name: "FK_FilterWordsChannelId_GuildFilterConfig_GuildFilterConfigId", + column: x => x.GuildFilterConfigId, + principalTable: "GuildFilterConfig", + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -1474,50 +1391,6 @@ namespace EllieBot.Migrations.Sqlite onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "Todos", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column<ulong>(type: "INTEGER", nullable: false), - Todo = table.Column<string>(type: "TEXT", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: false), - IsDone = table.Column<bool>(type: "INTEGER", nullable: false), - ArchiveId = table.Column<int>(type: "INTEGER", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Todos", x => x.Id); - table.ForeignKey( - name: "FK_Todos_TodosArchive_ArchiveId", - column: x => x.ArchiveId, - principalTable: "TodosArchive", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AntiSpamIgnore", - columns: table => new - { - Id = table.Column<int>(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - AntiSpamSettingId = table.Column<int>(type: "INTEGER", nullable: true), - DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AntiSpamIgnore", x => x.Id); - table.ForeignKey( - name: "FK_AntiSpamIgnore_AntiSpamSetting_AntiSpamSettingId", - column: x => x.AntiSpamSettingId, - principalTable: "AntiSpamSetting", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "ShopEntryItem", columns: table => new @@ -1583,15 +1456,38 @@ namespace EllieBot.Migrations.Sqlite onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "Todos", + columns: table => new + { + Id = table.Column<int>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + UserId = table.Column<ulong>(type: "INTEGER", nullable: false), + Todo = table.Column<string>(type: "TEXT", nullable: true), + DateAdded = table.Column<DateTime>(type: "TEXT", nullable: false), + IsDone = table.Column<bool>(type: "INTEGER", nullable: false), + ArchiveId = table.Column<int>(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Todos", x => x.Id); + table.ForeignKey( + name: "FK_Todos_TodosArchive_ArchiveId", + column: x => x.ArchiveId, + principalTable: "TodosArchive", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "ExcludedItem", columns: table => new { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - XpSettingsId = table.Column<int>(type: "INTEGER", nullable: true), ItemId = table.Column<ulong>(type: "INTEGER", nullable: false), ItemType = table.Column<int>(type: "INTEGER", nullable: false), + XpSettingsId = table.Column<int>(type: "INTEGER", nullable: true), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, constraints: table => @@ -1601,8 +1497,7 @@ namespace EllieBot.Migrations.Sqlite name: "FK_ExcludedItem_XpSettings_XpSettingsId", column: x => x.XpSettingsId, principalTable: "XpSettings", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -1807,15 +1702,15 @@ namespace EllieBot.Migrations.Sqlite }); migrationBuilder.CreateIndex( - name: "IX_AntiAltSetting_GuildConfigId", + name: "IX_AntiAltSetting_GuildId", table: "AntiAltSetting", - column: "GuildConfigId", + column: "GuildId", unique: true); migrationBuilder.CreateIndex( - name: "IX_AntiRaidSetting_GuildConfigId", + name: "IX_AntiRaidSetting_GuildId", table: "AntiRaidSetting", - column: "GuildConfigId", + column: "GuildId", unique: true); migrationBuilder.CreateIndex( @@ -1824,9 +1719,9 @@ namespace EllieBot.Migrations.Sqlite column: "AntiSpamSettingId"); migrationBuilder.CreateIndex( - name: "IX_AntiSpamSetting_GuildConfigId", + name: "IX_AntiSpamSetting_GuildId", table: "AntiSpamSetting", - column: "GuildConfigId", + column: "GuildId", unique: true); migrationBuilder.CreateIndex( @@ -1886,14 +1781,15 @@ namespace EllieBot.Migrations.Sqlite unique: true); migrationBuilder.CreateIndex( - name: "IX_CommandAlias_GuildConfigId", + name: "IX_CommandAlias_GuildId", table: "CommandAlias", - column: "GuildConfigId"); + column: "GuildId"); migrationBuilder.CreateIndex( - name: "IX_CommandCooldown_GuildConfigId", + name: "IX_CommandCooldown_GuildId_CommandName", table: "CommandCooldown", - column: "GuildConfigId"); + columns: new[] { "GuildId", "CommandName" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_CurrencyTransactions_UserId", @@ -1901,9 +1797,10 @@ namespace EllieBot.Migrations.Sqlite column: "UserId"); migrationBuilder.CreateIndex( - name: "IX_DelMsgOnCmdChannel_GuildConfigId", + name: "IX_DelMsgOnCmdChannel_GuildId_ChannelId", table: "DelMsgOnCmdChannel", - column: "GuildConfigId"); + columns: new[] { "GuildId", "ChannelId" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_DiscordPermOverrides_GuildId_Command", @@ -1942,24 +1839,30 @@ namespace EllieBot.Migrations.Sqlite column: "XpSettingsId"); migrationBuilder.CreateIndex( - name: "IX_FilterChannelId_GuildConfigId", + name: "IX_FeedSub_GuildId_Url", + table: "FeedSub", + columns: new[] { "GuildId", "Url" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_FilterChannelId_GuildFilterConfigId", table: "FilterChannelId", - column: "GuildConfigId"); + column: "GuildFilterConfigId"); migrationBuilder.CreateIndex( - name: "IX_FilteredWord_GuildConfigId", + name: "IX_FilteredWord_GuildFilterConfigId", table: "FilteredWord", - column: "GuildConfigId"); + column: "GuildFilterConfigId"); migrationBuilder.CreateIndex( - name: "IX_FilterLinksChannelId_GuildConfigId", + name: "IX_FilterLinksChannelId_GuildFilterConfigId", table: "FilterLinksChannelId", - column: "GuildConfigId"); + column: "GuildFilterConfigId"); migrationBuilder.CreateIndex( - name: "IX_FilterWordsChannelId_GuildConfigId", + name: "IX_FilterWordsChannelId_GuildFilterConfigId", table: "FilterWordsChannelId", - column: "GuildConfigId"); + column: "GuildFilterConfigId"); migrationBuilder.CreateIndex( name: "IX_FlagTranslateChannel_GuildId_ChannelId", @@ -1968,9 +1871,9 @@ namespace EllieBot.Migrations.Sqlite unique: true); migrationBuilder.CreateIndex( - name: "IX_FollowedStream_GuildConfigId", + name: "IX_FollowedStream_GuildId_Username_Type", table: "FollowedStream", - column: "GuildConfigId"); + columns: new[] { "GuildId", "Username", "Type" }); migrationBuilder.CreateIndex( name: "IX_GamblingStats_Feature", @@ -1979,9 +1882,10 @@ namespace EllieBot.Migrations.Sqlite unique: true); migrationBuilder.CreateIndex( - name: "IX_GCChannelId_GuildConfigId", + name: "IX_GCChannelId_GuildId_ChannelId", table: "GCChannelId", - column: "GuildConfigId"); + columns: new[] { "GuildId", "ChannelId" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_GiveawayUser_GiveawayId_UserId", @@ -2012,6 +1916,11 @@ namespace EllieBot.Migrations.Sqlite table: "GuildConfigs", column: "WarnExpireHours"); + migrationBuilder.CreateIndex( + name: "IX_GuildFilterConfig_GuildId", + table: "GuildFilterConfig", + column: "GuildId"); + migrationBuilder.CreateIndex( name: "IX_IgnoredLogChannels_LogSettingId_LogItemId_ItemType", table: "IgnoredLogChannels", @@ -2037,9 +1946,10 @@ namespace EllieBot.Migrations.Sqlite unique: true); migrationBuilder.CreateIndex( - name: "IX_MutedUserId_GuildConfigId", + name: "IX_MutedUserId_GuildId_UserId", table: "MutedUserId", - column: "GuildConfigId"); + columns: new[] { "GuildId", "UserId" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_NCPixel_OwnerId", @@ -2057,6 +1967,11 @@ namespace EllieBot.Migrations.Sqlite table: "Permissions", column: "GuildConfigId"); + migrationBuilder.CreateIndex( + name: "IX_Permissions_GuildId", + table: "Permissions", + column: "GuildId"); + migrationBuilder.CreateIndex( name: "IX_PlantedCurrency_ChannelId", table: "PlantedCurrency", @@ -2117,9 +2032,10 @@ namespace EllieBot.Migrations.Sqlite unique: true); migrationBuilder.CreateIndex( - name: "IX_ShopEntry_GuildConfigId", + name: "IX_ShopEntry_GuildId_Index", table: "ShopEntry", - column: "GuildConfigId"); + columns: new[] { "GuildId", "Index" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_ShopEntryItem_ShopEntryId", @@ -2127,14 +2043,16 @@ namespace EllieBot.Migrations.Sqlite column: "ShopEntryId"); migrationBuilder.CreateIndex( - name: "IX_SlowmodeIgnoredRole_GuildConfigId", + name: "IX_SlowmodeIgnoredRole_GuildId_RoleId", table: "SlowmodeIgnoredRole", - column: "GuildConfigId"); + columns: new[] { "GuildId", "RoleId" }, + unique: true); migrationBuilder.CreateIndex( - name: "IX_SlowmodeIgnoredUser_GuildConfigId", + name: "IX_SlowmodeIgnoredUser_GuildId_UserId", table: "SlowmodeIgnoredUser", - column: "GuildConfigId"); + columns: new[] { "GuildId", "UserId" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_StickyRoles_GuildId_UserId", @@ -2148,9 +2066,9 @@ namespace EllieBot.Migrations.Sqlite column: "StreamRoleSettingsId"); migrationBuilder.CreateIndex( - name: "IX_StreamRoleSettings_GuildConfigId", + name: "IX_StreamRoleSettings_GuildId", table: "StreamRoleSettings", - column: "GuildConfigId", + column: "GuildId", unique: true); migrationBuilder.CreateIndex( @@ -2174,19 +2092,22 @@ namespace EllieBot.Migrations.Sqlite column: "UserId"); migrationBuilder.CreateIndex( - name: "IX_UnbanTimer_GuildConfigId", + name: "IX_UnbanTimer_GuildId_UserId", table: "UnbanTimer", - column: "GuildConfigId"); + columns: new[] { "GuildId", "UserId" }, + unique: true); migrationBuilder.CreateIndex( - name: "IX_UnmuteTimer_GuildConfigId", + name: "IX_UnmuteTimer_GuildId_UserId", table: "UnmuteTimer", - column: "GuildConfigId"); + columns: new[] { "GuildId", "UserId" }, + unique: true); migrationBuilder.CreateIndex( - name: "IX_UnroleTimer_GuildConfigId", + name: "IX_UnroleTimer_GuildId_UserId", table: "UnroleTimer", - column: "GuildConfigId"); + columns: new[] { "GuildId", "UserId" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_UserBetStats_MaxWin", @@ -2227,9 +2148,10 @@ namespace EllieBot.Migrations.Sqlite column: "Xp"); migrationBuilder.CreateIndex( - name: "IX_VcRoleInfo_GuildConfigId", + name: "IX_VcRoleInfo_GuildId_VoiceChannelId", table: "VcRoleInfo", - column: "GuildConfigId"); + columns: new[] { "GuildId", "VoiceChannelId" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_WaifuInfo_AffinityId", @@ -2287,6 +2209,12 @@ namespace EllieBot.Migrations.Sqlite table: "Warnings", column: "UserId"); + migrationBuilder.CreateIndex( + name: "IX_XpCurrencyReward_Level_XpSettingsId", + table: "XpCurrencyReward", + columns: new[] { "Level", "XpSettingsId" }, + unique: true); + migrationBuilder.CreateIndex( name: "IX_XpCurrencyReward_XpSettingsId", table: "XpCurrencyReward", @@ -2299,9 +2227,9 @@ namespace EllieBot.Migrations.Sqlite unique: true); migrationBuilder.CreateIndex( - name: "IX_XpSettings_GuildConfigId", + name: "IX_XpSettings_GuildId", table: "XpSettings", - column: "GuildConfigId", + column: "GuildId", unique: true); migrationBuilder.CreateIndex( @@ -2589,12 +2517,18 @@ namespace EllieBot.Migrations.Sqlite migrationBuilder.DropTable( name: "AutoTranslateChannels"); + migrationBuilder.DropTable( + name: "GuildFilterConfig"); + migrationBuilder.DropTable( name: "GiveawayModel"); migrationBuilder.DropTable( name: "LogSettings"); + migrationBuilder.DropTable( + name: "GuildConfigs"); + migrationBuilder.DropTable( name: "MusicPlaylists"); @@ -2616,9 +2550,6 @@ namespace EllieBot.Migrations.Sqlite migrationBuilder.DropTable( name: "XpSettings"); - migrationBuilder.DropTable( - name: "GuildConfigs"); - migrationBuilder.DropTable( name: "Clubs"); diff --git a/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs b/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs index 70150e4..457aec3 100644 --- a/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs +++ b/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs @@ -18,3197 +18,3024 @@ namespace EllieBot.Migrations.Sqlite modelBuilder.HasAnnotation("ProductVersion", "9.0.1"); modelBuilder.Entity("EllieBot.Db.Models.AntiAltSetting", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("Action") - .HasColumnType("INTEGER"); + b.Property<int>("Action") + .HasColumnType("INTEGER"); - b.Property<int>("ActionDurationMinutes") - .HasColumnType("INTEGER"); + b.Property<int>("ActionDurationMinutes") + .HasColumnType("INTEGER"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); - b.Property<TimeSpan>("MinAge") - .HasColumnType("TEXT"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("RoleId") - .HasColumnType("INTEGER"); + b.Property<TimeSpan>("MinAge") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.Property<ulong?>("RoleId") + .HasColumnType("INTEGER"); - b.HasIndex("GuildConfigId") - .IsUnique(); + b.HasKey("Id"); - b.ToTable("AntiAltSetting"); - }); + b.HasIndex("GuildId") + .IsUnique(); + + b.ToTable("AntiAltSetting"); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiRaidSetting", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("Action") - .HasColumnType("INTEGER"); + b.Property<int>("Action") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); - b.Property<int>("PunishDuration") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int>("Seconds") - .HasColumnType("INTEGER"); + b.Property<int>("PunishDuration") + .HasColumnType("INTEGER"); - b.Property<int>("UserThreshold") - .HasColumnType("INTEGER"); + b.Property<int>("Seconds") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.Property<int>("UserThreshold") + .HasColumnType("INTEGER"); - b.HasIndex("GuildConfigId") - .IsUnique(); + b.HasKey("Id"); - b.ToTable("AntiRaidSetting"); - }); + b.HasIndex("GuildId") + .IsUnique(); + + b.ToTable("AntiRaidSetting"); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamIgnore", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int?>("AntiSpamSettingId") - .HasColumnType("INTEGER"); + b.Property<int?>("AntiSpamSettingId") + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("AntiSpamSettingId"); + b.HasIndex("AntiSpamSettingId"); - b.ToTable("AntiSpamIgnore"); - }); + b.ToTable("AntiSpamIgnore"); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("Action") - .HasColumnType("INTEGER"); + b.Property<int>("Action") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); - b.Property<int>("MessageThreshold") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int>("MuteTime") - .HasColumnType("INTEGER"); + b.Property<int>("MessageThreshold") + .HasColumnType("INTEGER"); - b.Property<ulong?>("RoleId") - .HasColumnType("INTEGER"); + b.Property<int>("MuteTime") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.Property<ulong?>("RoleId") + .HasColumnType("INTEGER"); - b.HasIndex("GuildConfigId") - .IsUnique(); + b.HasKey("Id"); - b.ToTable("AntiSpamSetting"); - }); + b.HasIndex("GuildId") + .IsUnique(); + + b.ToTable("AntiSpamSetting"); + }); modelBuilder.Entity("EllieBot.Db.Models.ArchivedTodoListModel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<string>("Name") - .HasColumnType("TEXT"); + b.Property<string>("Name") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("TodosArchive"); - }); + b.ToTable("TodosArchive"); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoCommand", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<string>("ChannelName") - .HasColumnType("TEXT"); + b.Property<string>("ChannelName") + .HasColumnType("TEXT"); - b.Property<string>("CommandText") - .HasColumnType("TEXT"); + b.Property<string>("CommandText") + .HasColumnType("TEXT"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong?>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("GuildName") - .HasColumnType("TEXT"); + b.Property<string>("GuildName") + .HasColumnType("TEXT"); - b.Property<int>("Interval") - .HasColumnType("INTEGER"); + b.Property<int>("Interval") + .HasColumnType("INTEGER"); - b.Property<ulong?>("VoiceChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("VoiceChannelId") + .HasColumnType("INTEGER"); - b.Property<string>("VoiceChannelName") - .HasColumnType("TEXT"); + b.Property<string>("VoiceChannelName") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("AutoCommands"); - }); + b.ToTable("AutoCommands"); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoPublishChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId") - .IsUnique(); + b.HasIndex("GuildId") + .IsUnique(); - b.ToTable("AutoPublishChannel"); - }); + b.ToTable("AutoPublishChannel"); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<bool>("AutoDelete") - .HasColumnType("INTEGER"); + b.Property<bool>("AutoDelete") + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("ChannelId") - .IsUnique(); + b.HasIndex("ChannelId") + .IsUnique(); - b.HasIndex("GuildId"); + b.HasIndex("GuildId"); - b.ToTable("AutoTranslateChannels"); - }); + b.ToTable("AutoTranslateChannels"); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<int>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<string>("Source") - .HasColumnType("TEXT"); + b.Property<string>("Source") + .HasColumnType("TEXT"); - b.Property<string>("Target") - .HasColumnType("TEXT"); + b.Property<string>("Target") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("ChannelId", "UserId"); + b.HasAlternateKey("ChannelId", "UserId"); - b.ToTable("AutoTranslateUsers"); - }); + b.ToTable("AutoTranslateUsers"); + }); modelBuilder.Entity("EllieBot.Db.Models.BanTemplate", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int?>("PruneDays") - .HasColumnType("INTEGER"); + b.Property<int?>("PruneDays") + .HasColumnType("INTEGER"); - b.Property<string>("Text") - .HasColumnType("TEXT"); + b.Property<string>("Text") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId") - .IsUnique(); + b.HasIndex("GuildId") + .IsUnique(); - b.ToTable("BanTemplates"); - }); + b.ToTable("BanTemplates"); + }); modelBuilder.Entity("EllieBot.Db.Models.BankUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<long>("Balance") - .HasColumnType("INTEGER"); + b.Property<long>("Balance") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("UserId") - .IsUnique(); + b.HasIndex("UserId") + .IsUnique(); - b.ToTable("BankUsers"); - }); + b.ToTable("BankUsers"); + }); modelBuilder.Entity("EllieBot.Db.Models.BlacklistEntry", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("ItemId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ItemId") + .HasColumnType("INTEGER"); - b.Property<int>("Type") - .HasColumnType("INTEGER"); + b.Property<int>("Type") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("Blacklist"); - }); + b.ToTable("Blacklist"); + }); modelBuilder.Entity("EllieBot.Db.Models.ButtonRole", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<string>("ButtonId") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("TEXT"); + b.Property<string>("ButtonId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("TEXT"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<string>("Emote") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); + b.Property<string>("Emote") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); - b.Property<bool>("Exclusive") - .HasColumnType("INTEGER"); + b.Property<bool>("Exclusive") + .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("Label") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("TEXT"); + b.Property<string>("Label") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); - b.Property<ulong>("MessageId") - .HasColumnType("INTEGER"); + b.Property<ulong>("MessageId") + .HasColumnType("INTEGER"); - b.Property<int>("Position") - .HasColumnType("INTEGER"); + b.Property<int>("Position") + .HasColumnType("INTEGER"); - b.Property<ulong>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("RoleId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("RoleId", "MessageId"); + b.HasAlternateKey("RoleId", "MessageId"); - b.HasIndex("GuildId"); + b.HasIndex("GuildId"); - b.ToTable("ButtonRole"); - }); + b.ToTable("ButtonRole"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubApplicants", b => - { - b.Property<int>("ClubId") - .HasColumnType("INTEGER"); + { + b.Property<int>("ClubId") + .HasColumnType("INTEGER"); - b.Property<int>("UserId") - .HasColumnType("INTEGER"); + b.Property<int>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("ClubId", "UserId"); + b.HasKey("ClubId", "UserId"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.ToTable("ClubApplicants"); - }); + b.ToTable("ClubApplicants"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubBans", b => - { - b.Property<int>("ClubId") - .HasColumnType("INTEGER"); + { + b.Property<int>("ClubId") + .HasColumnType("INTEGER"); - b.Property<int>("UserId") - .HasColumnType("INTEGER"); + b.Property<int>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("ClubId", "UserId"); + b.HasKey("ClubId", "UserId"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.ToTable("ClubBans"); - }); + b.ToTable("ClubBans"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubInfo", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<string>("Description") - .HasColumnType("TEXT"); + b.Property<string>("Description") + .HasColumnType("TEXT"); - b.Property<string>("ImageUrl") - .HasColumnType("TEXT"); + b.Property<string>("ImageUrl") + .HasColumnType("TEXT"); - b.Property<string>("Name") - .HasMaxLength(20) - .HasColumnType("TEXT"); + b.Property<string>("Name") + .HasMaxLength(20) + .HasColumnType("TEXT"); - b.Property<int?>("OwnerId") - .HasColumnType("INTEGER"); + b.Property<int?>("OwnerId") + .HasColumnType("INTEGER"); - b.Property<int>("Xp") - .HasColumnType("INTEGER"); + b.Property<int>("Xp") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); + b.HasIndex("Name") + .IsUnique(); - b.HasIndex("OwnerId") - .IsUnique(); + b.HasIndex("OwnerId") + .IsUnique(); - b.ToTable("Clubs"); - }); + b.ToTable("Clubs"); + }); modelBuilder.Entity("EllieBot.Db.Models.CommandAlias", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("Mapping") - .HasColumnType("TEXT"); + b.Property<string>("Mapping") + .HasColumnType("TEXT"); - b.Property<string>("Trigger") - .HasColumnType("TEXT"); + b.Property<string>("Trigger") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId"); - b.ToTable("CommandAlias"); - }); + b.ToTable("CommandAlias"); + }); modelBuilder.Entity("EllieBot.Db.Models.CommandCooldown", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<string>("CommandName") - .HasColumnType("TEXT"); + b.Property<string>("CommandName") + .HasColumnType("TEXT"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int>("Seconds") - .HasColumnType("INTEGER"); + b.Property<int>("Seconds") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "CommandName") + .IsUnique(); - b.ToTable("CommandCooldown"); - }); + b.ToTable("CommandCooldown"); + }); modelBuilder.Entity("EllieBot.Db.Models.CurrencyTransaction", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<long>("Amount") - .HasColumnType("INTEGER"); + b.Property<long>("Amount") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<string>("Extra") - .IsRequired() - .HasColumnType("TEXT"); + b.Property<string>("Extra") + .IsRequired() + .HasColumnType("TEXT"); - b.Property<string>("Note") - .HasColumnType("TEXT"); + b.Property<string>("Note") + .HasColumnType("TEXT"); - b.Property<ulong?>("OtherId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValueSql("NULL"); + b.Property<ulong?>("OtherId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValueSql("NULL"); - b.Property<string>("Type") - .IsRequired() - .HasColumnType("TEXT"); + b.Property<string>("Type") + .IsRequired() + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.ToTable("CurrencyTransactions"); - }); + b.ToTable("CurrencyTransactions"); + }); modelBuilder.Entity("EllieBot.Db.Models.DelMsgOnCmdChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); - b.Property<bool>("State") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.Property<bool>("State") + .HasColumnType("INTEGER"); - b.HasIndex("GuildConfigId"); + b.HasKey("Id"); - b.ToTable("DelMsgOnCmdChannel"); - }); + b.HasIndex("GuildId", "ChannelId") + .IsUnique(); + + b.ToTable("DelMsgOnCmdChannel"); + }); modelBuilder.Entity("EllieBot.Db.Models.DiscordPermOverride", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<string>("Command") - .HasColumnType("TEXT"); + b.Property<string>("Command") + .HasColumnType("TEXT"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong?>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong>("Perm") - .HasColumnType("INTEGER"); + b.Property<ulong>("Perm") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId", "Command") - .IsUnique(); + b.HasIndex("GuildId", "Command") + .IsUnique(); - b.ToTable("DiscordPermOverrides"); - }); + b.ToTable("DiscordPermOverrides"); + }); modelBuilder.Entity("EllieBot.Db.Models.DiscordUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<string>("AvatarId") - .HasColumnType("TEXT"); + b.Property<string>("AvatarId") + .HasColumnType("TEXT"); - b.Property<int?>("ClubId") - .HasColumnType("INTEGER"); + b.Property<int?>("ClubId") + .HasColumnType("INTEGER"); - b.Property<long>("CurrencyAmount") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(0L); + b.Property<long>("CurrencyAmount") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0L); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<bool>("IsClubAdmin") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(false); + b.Property<bool>("IsClubAdmin") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(false); - b.Property<int>("NotifyOnLevelUp") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(0); + b.Property<int>("NotifyOnLevelUp") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0); - b.Property<long>("TotalXp") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(0L); + b.Property<long>("TotalXp") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0L); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.Property<string>("Username") - .HasColumnType("TEXT"); + b.Property<string>("Username") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("UserId"); + b.HasAlternateKey("UserId"); - b.HasIndex("ClubId"); + b.HasIndex("ClubId"); - b.HasIndex("CurrencyAmount"); + b.HasIndex("CurrencyAmount"); - b.HasIndex("TotalXp"); + b.HasIndex("TotalXp"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.HasIndex("Username"); + b.HasIndex("Username"); - b.ToTable("DiscordUser"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.EllieExpression", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property<bool>("AllowTarget") - .HasColumnType("INTEGER"); - - b.Property<bool>("AutoDeleteTrigger") - .HasColumnType("INTEGER"); - - b.Property<bool>("ContainsAnywhere") - .HasColumnType("INTEGER"); - - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); - - b.Property<bool>("DmResponse") - .HasColumnType("INTEGER"); - - b.Property<ulong?>("GuildId") - .HasColumnType("INTEGER"); - - b.Property<string>("Reactions") - .HasColumnType("TEXT"); - - b.Property<string>("Response") - .HasColumnType("TEXT"); - - b.Property<string>("Trigger") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Expressions"); - }); + b.ToTable("DiscordUser"); + }); modelBuilder.Entity("EllieBot.Db.Models.ExcludedItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("ItemId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ItemId") + .HasColumnType("INTEGER"); - b.Property<int>("ItemType") - .HasColumnType("INTEGER"); + b.Property<int>("ItemType") + .HasColumnType("INTEGER"); - b.Property<int?>("XpSettingsId") - .HasColumnType("INTEGER"); + b.Property<int?>("XpSettingsId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("XpSettingsId"); + b.HasIndex("XpSettingsId"); - b.ToTable("ExcludedItem"); - }); + b.ToTable("ExcludedItem"); + }); modelBuilder.Entity("EllieBot.Db.Models.FeedSub", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); - b.Property<string>("Message") - .HasColumnType("TEXT"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("Url") - .IsRequired() - .HasColumnType("TEXT"); + b.Property<string>("Message") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.Property<string>("Url") + .HasColumnType("TEXT"); - b.HasAlternateKey("GuildConfigId", "Url"); + b.HasKey("Id"); - b.ToTable("FeedSub"); - }); + b.HasIndex("GuildId", "Url") + .IsUnique(); + + b.ToTable("FeedSub"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterChannelId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<int?>("GuildFilterConfigId") + .HasColumnType("INTEGER"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.HasKey("Id"); - b.HasKey("Id"); + b.HasIndex("GuildFilterConfigId"); - b.HasIndex("GuildConfigId"); - - b.ToTable("FilterChannelId"); - }); + b.ToTable("FilterChannelId"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterLinksChannelId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int?>("GuildFilterConfigId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildFilterConfigId"); - b.ToTable("FilterLinksChannelId"); - }); + b.ToTable("FilterLinksChannelId"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterWordsChannelId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int?>("GuildFilterConfigId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildFilterConfigId"); - b.ToTable("FilterWordsChannelId"); - }); + b.ToTable("FilterWordsChannelId"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilteredWord", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int?>("GuildFilterConfigId") + .HasColumnType("INTEGER"); - b.Property<string>("Word") - .HasColumnType("TEXT"); + b.Property<string>("Word") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildFilterConfigId"); - b.ToTable("FilteredWord"); - }); + b.ToTable("FilteredWord"); + }); modelBuilder.Entity("EllieBot.Db.Models.FlagTranslateChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId", "ChannelId") - .IsUnique(); + b.HasIndex("GuildId", "ChannelId") + .IsUnique(); - b.ToTable("FlagTranslateChannel"); - }); + b.ToTable("FlagTranslateChannel"); + }); modelBuilder.Entity("EllieBot.Db.Models.FollowedStream", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<string>("Message") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<int>("Type") + .HasColumnType("INTEGER"); - b.Property<string>("Message") - .HasColumnType("TEXT"); + b.Property<string>("Username") + .HasColumnType("TEXT"); - b.Property<int>("Type") - .HasColumnType("INTEGER"); + b.HasKey("Id"); - b.Property<string>("Username") - .HasColumnType("TEXT"); + b.HasIndex("GuildId", "Username", "Type"); - b.HasKey("Id"); - - b.HasIndex("GuildConfigId"); - - b.ToTable("FollowedStream"); - }); + b.ToTable("FollowedStream"); + }); modelBuilder.Entity("EllieBot.Db.Models.GCChannelId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "ChannelId") + .IsUnique(); - b.ToTable("GCChannelId"); - }); + b.ToTable("GCChannelId"); + }); modelBuilder.Entity("EllieBot.Db.Models.GamblingStats", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<decimal>("Bet") - .HasColumnType("TEXT"); + b.Property<decimal>("Bet") + .HasColumnType("TEXT"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<string>("Feature") - .HasColumnType("TEXT"); + b.Property<string>("Feature") + .HasColumnType("TEXT"); - b.Property<decimal>("PaidOut") - .HasColumnType("TEXT"); + b.Property<decimal>("PaidOut") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("Feature") - .IsUnique(); + b.HasIndex("Feature") + .IsUnique(); - b.ToTable("GamblingStats"); - }); + b.ToTable("GamblingStats"); + }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayModel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime>("EndsAt") - .HasColumnType("TEXT"); + b.Property<DateTime>("EndsAt") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("Message") - .HasColumnType("TEXT"); + b.Property<string>("Message") + .HasColumnType("TEXT"); - b.Property<ulong>("MessageId") - .HasColumnType("INTEGER"); + b.Property<ulong>("MessageId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("GiveawayModel"); - }); + b.ToTable("GiveawayModel"); + }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("GiveawayId") - .HasColumnType("INTEGER"); + b.Property<int>("GiveawayId") + .HasColumnType("INTEGER"); - b.Property<string>("Name") - .HasColumnType("TEXT"); + b.Property<string>("Name") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GiveawayId", "UserId") - .IsUnique(); + b.HasIndex("GiveawayId", "UserId") + .IsUnique(); - b.ToTable("GiveawayUser"); - }); + b.ToTable("GiveawayUser"); + }); modelBuilder.Entity("EllieBot.Db.Models.GuildColors", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<string>("ErrorColor") - .HasMaxLength(9) - .HasColumnType("TEXT"); + b.Property<string>("ErrorColor") + .HasMaxLength(9) + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("OkColor") - .HasMaxLength(9) - .HasColumnType("TEXT"); + b.Property<string>("OkColor") + .HasMaxLength(9) + .HasColumnType("TEXT"); - b.Property<string>("PendingColor") - .HasMaxLength(9) - .HasColumnType("TEXT"); + b.Property<string>("PendingColor") + .HasMaxLength(9) + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId") - .IsUnique(); + b.HasIndex("GuildId") + .IsUnique(); - b.ToTable("GuildColors"); - }); + b.ToTable("GuildColors"); + }); modelBuilder.Entity("EllieBot.Db.Models.GuildConfig", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<string>("AutoAssignRoleIds") - .HasColumnType("TEXT"); + b.Property<string>("AutoAssignRoleIds") + .HasColumnType("TEXT"); - b.Property<bool>("AutoDeleteSelfAssignedRoleMessages") - .HasColumnType("INTEGER"); + b.Property<bool>("CleverbotEnabled") + .HasColumnType("INTEGER"); - b.Property<bool>("CleverbotEnabled") - .HasColumnType("INTEGER"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<bool>("DeleteMessageOnCommand") + .HasColumnType("INTEGER"); - b.Property<bool>("DeleteMessageOnCommand") - .HasColumnType("INTEGER"); + b.Property<bool>("DeleteStreamOnlineMessage") + .HasColumnType("INTEGER"); - b.Property<bool>("DeleteStreamOnlineMessage") - .HasColumnType("INTEGER"); + b.Property<bool>("DisableGlobalExpressions") + .HasColumnType("INTEGER"); - b.Property<bool>("DisableGlobalExpressions") - .HasColumnType("INTEGER"); + b.Property<ulong?>("GameVoiceChannel") + .HasColumnType("INTEGER"); - b.Property<bool>("ExclusiveSelfAssignedRoles") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<bool>("FilterInvites") - .HasColumnType("INTEGER"); + b.Property<string>("Locale") + .HasColumnType("TEXT"); - b.Property<bool>("FilterLinks") - .HasColumnType("INTEGER"); + b.Property<string>("MuteRoleName") + .HasColumnType("TEXT"); - b.Property<bool>("FilterWords") - .HasColumnType("INTEGER"); + b.Property<bool>("NotifyStreamOffline") + .HasColumnType("INTEGER"); - b.Property<ulong?>("GameVoiceChannel") - .HasColumnType("INTEGER"); + b.Property<string>("PermissionRole") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<string>("Prefix") + .HasColumnType("TEXT"); - b.Property<string>("Locale") - .HasColumnType("TEXT"); + b.Property<bool>("StickyRoles") + .HasColumnType("INTEGER"); - b.Property<string>("MuteRoleName") - .HasColumnType("TEXT"); + b.Property<string>("TimeZoneId") + .HasColumnType("TEXT"); - b.Property<bool>("NotifyStreamOffline") - .HasColumnType("INTEGER"); + b.Property<bool>("VerboseErrors") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); - b.Property<string>("PermissionRole") - .HasColumnType("TEXT"); + b.Property<bool>("VerbosePermissions") + .HasColumnType("INTEGER"); - b.Property<string>("Prefix") - .HasColumnType("TEXT"); + b.Property<int>("WarnExpireAction") + .HasColumnType("INTEGER"); - b.Property<bool>("StickyRoles") - .HasColumnType("INTEGER"); + b.Property<int>("WarnExpireHours") + .HasColumnType("INTEGER"); - b.Property<string>("TimeZoneId") - .HasColumnType("TEXT"); + b.Property<bool>("WarningsInitialized") + .HasColumnType("INTEGER"); - b.Property<bool>("VerboseErrors") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(true); + b.HasKey("Id"); - b.Property<bool>("VerbosePermissions") - .HasColumnType("INTEGER"); + b.HasIndex("GuildId") + .IsUnique(); - b.Property<int>("WarnExpireAction") - .HasColumnType("INTEGER"); + b.HasIndex("WarnExpireHours"); - b.Property<int>("WarnExpireHours") - .HasColumnType("INTEGER"); + b.ToTable("GuildConfigs"); + }); - b.Property<bool>("WarningsInitialized") - .HasColumnType("INTEGER"); + modelBuilder.Entity("EllieBot.Db.Models.GuildFilterConfig", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.Property<bool>("FilterInvites") + .HasColumnType("INTEGER"); - b.HasIndex("GuildId") - .IsUnique(); + b.Property<bool>("FilterLinks") + .HasColumnType("INTEGER"); - b.HasIndex("WarnExpireHours"); + b.Property<bool>("FilterWords") + .HasColumnType("INTEGER"); - b.ToTable("GuildConfigs"); - }); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("GuildId"); + + b.ToTable("GuildFilterConfig"); + }); modelBuilder.Entity("EllieBot.Db.Models.HoneypotChannel", b => - { - b.Property<ulong>("GuildId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<ulong>("GuildId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.HasKey("GuildId"); + b.HasKey("GuildId"); - b.ToTable("HoneyPotChannels"); - }); + b.ToTable("HoneyPotChannels"); + }); modelBuilder.Entity("EllieBot.Db.Models.IgnoredLogItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("ItemType") - .HasColumnType("INTEGER"); + b.Property<int>("ItemType") + .HasColumnType("INTEGER"); - b.Property<ulong>("LogItemId") - .HasColumnType("INTEGER"); + b.Property<ulong>("LogItemId") + .HasColumnType("INTEGER"); - b.Property<int>("LogSettingId") - .HasColumnType("INTEGER"); + b.Property<int>("LogSettingId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("LogSettingId", "LogItemId", "ItemType") - .IsUnique(); + b.HasIndex("LogSettingId", "LogItemId", "ItemType") + .IsUnique(); - b.ToTable("IgnoredLogChannels"); - }); + b.ToTable("IgnoredLogChannels"); + }); modelBuilder.Entity("EllieBot.Db.Models.ImageOnlyChannel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int>("Type") - .HasColumnType("INTEGER"); + b.Property<int>("Type") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("ChannelId") - .IsUnique(); + b.HasIndex("ChannelId") + .IsUnique(); - b.ToTable("ImageOnlyChannels"); - }); + b.ToTable("ImageOnlyChannels"); + }); modelBuilder.Entity("EllieBot.Db.Models.LogSetting", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong?>("ChannelCreatedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("ChannelCreatedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("ChannelDestroyedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("ChannelDestroyedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("ChannelUpdatedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("ChannelUpdatedId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("LogOtherId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("LogOtherId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("LogUserPresenceId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("LogUserPresenceId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("LogVoicePresenceId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("LogVoicePresenceId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("LogVoicePresenceTTSId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("LogVoicePresenceTTSId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("LogWarnsId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("LogWarnsId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("MessageDeletedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("MessageDeletedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("MessageUpdatedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("MessageUpdatedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("ThreadCreatedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("ThreadCreatedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("ThreadDeletedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("ThreadDeletedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("UserBannedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("UserBannedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("UserJoinedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("UserJoinedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("UserLeftId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("UserLeftId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("UserMutedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("UserMutedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("UserUnbannedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("UserUnbannedId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("UserUpdatedId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("UserUpdatedId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId") - .IsUnique(); + b.HasIndex("GuildId") + .IsUnique(); - b.ToTable("LogSettings"); - }); + b.ToTable("LogSettings"); + }); modelBuilder.Entity("EllieBot.Db.Models.MusicPlayerSettings", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<bool>("AutoDisconnect") - .HasColumnType("INTEGER"); + b.Property<bool>("AutoDisconnect") + .HasColumnType("INTEGER"); - b.Property<bool>("AutoPlay") - .HasColumnType("INTEGER"); + b.Property<bool>("AutoPlay") + .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong?>("MusicChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("MusicChannelId") + .HasColumnType("INTEGER"); - b.Property<int>("PlayerRepeat") - .HasColumnType("INTEGER"); + b.Property<int>("PlayerRepeat") + .HasColumnType("INTEGER"); - b.Property<int>("QualityPreset") - .HasColumnType("INTEGER"); + b.Property<int>("QualityPreset") + .HasColumnType("INTEGER"); - b.Property<int>("Volume") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(100); + b.Property<int>("Volume") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(100); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId") - .IsUnique(); + b.HasIndex("GuildId") + .IsUnique(); - b.ToTable("MusicPlayerSettings"); - }); + b.ToTable("MusicPlayerSettings"); + }); modelBuilder.Entity("EllieBot.Db.Models.MusicPlaylist", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<string>("Author") - .HasColumnType("TEXT"); + b.Property<string>("Author") + .HasColumnType("TEXT"); - b.Property<ulong>("AuthorId") - .HasColumnType("INTEGER"); + b.Property<ulong>("AuthorId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<string>("Name") - .HasColumnType("TEXT"); + b.Property<string>("Name") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("MusicPlaylists"); - }); + b.ToTable("MusicPlaylists"); + }); modelBuilder.Entity("EllieBot.Db.Models.MutedUserId", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); - b.ToTable("MutedUserId"); - }); + b.ToTable("MutedUserId"); + }); modelBuilder.Entity("EllieBot.Db.Models.NCPixel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<uint>("Color") - .HasColumnType("INTEGER"); + b.Property<uint>("Color") + .HasColumnType("INTEGER"); - b.Property<ulong>("OwnerId") - .HasColumnType("INTEGER"); + b.Property<ulong>("OwnerId") + .HasColumnType("INTEGER"); - b.Property<int>("Position") - .HasColumnType("INTEGER"); + b.Property<int>("Position") + .HasColumnType("INTEGER"); - b.Property<long>("Price") - .HasColumnType("INTEGER"); + b.Property<long>("Price") + .HasColumnType("INTEGER"); - b.Property<string>("Text") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("TEXT"); + b.Property<string>("Text") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("Position"); + b.HasAlternateKey("Position"); - b.HasIndex("OwnerId"); + b.HasIndex("OwnerId"); - b.ToTable("NCPixel"); - }); + b.ToTable("NCPixel"); + }); + + modelBuilder.Entity("EllieBot.Db.Models.EllieExpression", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<bool>("AllowTarget") + .HasColumnType("INTEGER"); + + b.Property<bool>("AutoDeleteTrigger") + .HasColumnType("INTEGER"); + + b.Property<bool>("ContainsAnywhere") + .HasColumnType("INTEGER"); + + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); + + b.Property<bool>("DmResponse") + .HasColumnType("INTEGER"); + + b.Property<ulong?>("GuildId") + .HasColumnType("INTEGER"); + + b.Property<string>("Reactions") + .HasColumnType("TEXT"); + + b.Property<string>("Response") + .HasColumnType("TEXT"); + + b.Property<string>("Trigger") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Expressions"); + }); modelBuilder.Entity("EllieBot.Db.Models.Notify", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("Message") - .IsRequired() - .HasMaxLength(10000) - .HasColumnType("TEXT"); + b.Property<string>("Message") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("TEXT"); - b.Property<int>("Type") - .HasColumnType("INTEGER"); + b.Property<int>("Type") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("GuildId", "Type"); + b.HasAlternateKey("GuildId", "Type"); - b.ToTable("Notify"); - }); + b.ToTable("Notify"); + }); modelBuilder.Entity("EllieBot.Db.Models.PatronUser", b => - { - b.Property<ulong>("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<ulong>("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("AmountCents") - .HasColumnType("INTEGER"); + b.Property<int>("AmountCents") + .HasColumnType("INTEGER"); - b.Property<DateTime>("LastCharge") - .HasColumnType("TEXT"); + b.Property<DateTime>("LastCharge") + .HasColumnType("TEXT"); - b.Property<string>("UniquePlatformUserId") - .HasColumnType("TEXT"); + b.Property<string>("UniquePlatformUserId") + .HasColumnType("TEXT"); - b.Property<DateTime>("ValidThru") - .HasColumnType("TEXT"); + b.Property<DateTime>("ValidThru") + .HasColumnType("TEXT"); - b.HasKey("UserId"); + b.HasKey("UserId"); - b.HasIndex("UniquePlatformUserId") - .IsUnique(); + b.HasIndex("UniquePlatformUserId") + .IsUnique(); - b.ToTable("Patrons"); - }); + b.ToTable("Patrons"); + }); modelBuilder.Entity("EllieBot.Db.Models.Permissionv2", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int?>("GuildConfigId") + .HasColumnType("INTEGER"); - b.Property<int>("Index") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<bool>("IsCustomCommand") - .HasColumnType("INTEGER"); + b.Property<int>("Index") + .HasColumnType("INTEGER"); - b.Property<int>("PrimaryTarget") - .HasColumnType("INTEGER"); + b.Property<bool>("IsCustomCommand") + .HasColumnType("INTEGER"); - b.Property<ulong>("PrimaryTargetId") - .HasColumnType("INTEGER"); + b.Property<int>("PrimaryTarget") + .HasColumnType("INTEGER"); - b.Property<int>("SecondaryTarget") - .HasColumnType("INTEGER"); + b.Property<ulong>("PrimaryTargetId") + .HasColumnType("INTEGER"); - b.Property<string>("SecondaryTargetName") - .HasColumnType("TEXT"); + b.Property<int>("SecondaryTarget") + .HasColumnType("INTEGER"); - b.Property<bool>("State") - .HasColumnType("INTEGER"); + b.Property<string>("SecondaryTargetName") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.Property<bool>("State") + .HasColumnType("INTEGER"); - b.HasIndex("GuildConfigId"); + b.HasKey("Id"); - b.ToTable("Permissions"); - }); + b.HasIndex("GuildConfigId"); + + b.HasIndex("GuildId"); + + b.ToTable("Permissions"); + }); modelBuilder.Entity("EllieBot.Db.Models.PlantedCurrency", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<long>("Amount") - .HasColumnType("INTEGER"); + b.Property<long>("Amount") + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong>("MessageId") - .HasColumnType("INTEGER"); + b.Property<ulong>("MessageId") + .HasColumnType("INTEGER"); - b.Property<string>("Password") - .HasColumnType("TEXT"); + b.Property<string>("Password") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("ChannelId"); + b.HasIndex("ChannelId"); - b.HasIndex("MessageId") - .IsUnique(); + b.HasIndex("MessageId") + .IsUnique(); - b.ToTable("PlantedCurrency"); - }); + b.ToTable("PlantedCurrency"); + }); modelBuilder.Entity("EllieBot.Db.Models.PlaylistSong", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("MusicPlaylistId") - .HasColumnType("INTEGER"); + b.Property<int?>("MusicPlaylistId") + .HasColumnType("INTEGER"); - b.Property<string>("Provider") - .HasColumnType("TEXT"); + b.Property<string>("Provider") + .HasColumnType("TEXT"); - b.Property<int>("ProviderType") - .HasColumnType("INTEGER"); + b.Property<int>("ProviderType") + .HasColumnType("INTEGER"); - b.Property<string>("Query") - .HasColumnType("TEXT"); + b.Property<string>("Query") + .HasColumnType("TEXT"); - b.Property<string>("Title") - .HasColumnType("TEXT"); + b.Property<string>("Title") + .HasColumnType("TEXT"); - b.Property<string>("Uri") - .HasColumnType("TEXT"); + b.Property<string>("Uri") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("MusicPlaylistId"); + b.HasIndex("MusicPlaylistId"); - b.ToTable("PlaylistSong"); - }); + b.ToTable("PlaylistSong"); + }); modelBuilder.Entity("EllieBot.Db.Models.Quote", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("AuthorId") - .HasColumnType("INTEGER"); + b.Property<ulong>("AuthorId") + .HasColumnType("INTEGER"); - b.Property<string>("AuthorName") - .IsRequired() - .HasColumnType("TEXT"); + b.Property<string>("AuthorName") + .IsRequired() + .HasColumnType("TEXT"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("Keyword") - .IsRequired() - .HasColumnType("TEXT"); + b.Property<string>("Keyword") + .IsRequired() + .HasColumnType("TEXT"); - b.Property<string>("Text") - .IsRequired() - .HasColumnType("TEXT"); + b.Property<string>("Text") + .IsRequired() + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId"); + b.HasIndex("GuildId"); - b.HasIndex("Keyword"); + b.HasIndex("Keyword"); - b.ToTable("Quotes"); - }); + b.ToTable("Quotes"); + }); modelBuilder.Entity("EllieBot.Db.Models.ReactionRoleV2", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<string>("Emote") - .HasMaxLength(100) - .HasColumnType("TEXT"); + b.Property<string>("Emote") + .HasMaxLength(100) + .HasColumnType("TEXT"); - b.Property<int>("Group") - .HasColumnType("INTEGER"); + b.Property<int>("Group") + .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int>("LevelReq") - .HasColumnType("INTEGER"); + b.Property<int>("LevelReq") + .HasColumnType("INTEGER"); - b.Property<ulong>("MessageId") - .HasColumnType("INTEGER"); + b.Property<ulong>("MessageId") + .HasColumnType("INTEGER"); - b.Property<ulong>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("RoleId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId"); + b.HasIndex("GuildId"); - b.HasIndex("MessageId", "Emote") - .IsUnique(); + b.HasIndex("MessageId", "Emote") + .IsUnique(); - b.ToTable("ReactionRoles"); - }); + b.ToTable("ReactionRoles"); + }); modelBuilder.Entity("EllieBot.Db.Models.Reminder", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<bool>("IsPrivate") - .HasColumnType("INTEGER"); + b.Property<bool>("IsPrivate") + .HasColumnType("INTEGER"); - b.Property<string>("Message") - .HasColumnType("TEXT"); + b.Property<string>("Message") + .HasColumnType("TEXT"); - b.Property<ulong>("ServerId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ServerId") + .HasColumnType("INTEGER"); - b.Property<int>("Type") - .HasColumnType("INTEGER"); + b.Property<int>("Type") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.Property<DateTime>("When") - .HasColumnType("TEXT"); + b.Property<DateTime>("When") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("When"); + b.HasIndex("When"); - b.ToTable("Reminders"); - }); + b.ToTable("Reminders"); + }); modelBuilder.Entity("EllieBot.Db.Models.Repeater", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<TimeSpan>("Interval") - .HasColumnType("TEXT"); + b.Property<TimeSpan>("Interval") + .HasColumnType("TEXT"); - b.Property<ulong?>("LastMessageId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("LastMessageId") + .HasColumnType("INTEGER"); - b.Property<string>("Message") - .HasColumnType("TEXT"); + b.Property<string>("Message") + .HasColumnType("TEXT"); - b.Property<bool>("NoRedundant") - .HasColumnType("INTEGER"); + b.Property<bool>("NoRedundant") + .HasColumnType("INTEGER"); - b.Property<TimeSpan?>("StartTimeOfDay") - .HasColumnType("TEXT"); + b.Property<TimeSpan?>("StartTimeOfDay") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("Repeaters"); - }); + b.ToTable("Repeaters"); + }); modelBuilder.Entity("EllieBot.Db.Models.RewardedUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<long>("AmountRewardedThisMonth") - .HasColumnType("INTEGER"); + b.Property<long>("AmountRewardedThisMonth") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<DateTime>("LastReward") - .HasColumnType("TEXT"); + b.Property<DateTime>("LastReward") + .HasColumnType("TEXT"); - b.Property<string>("PlatformUserId") - .HasColumnType("TEXT"); + b.Property<string>("PlatformUserId") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("PlatformUserId") - .IsUnique(); + b.HasIndex("PlatformUserId") + .IsUnique(); - b.ToTable("RewardedUsers"); - }); + b.ToTable("RewardedUsers"); + }); modelBuilder.Entity("EllieBot.Db.Models.RotatingPlayingStatus", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<string>("Status") - .HasColumnType("TEXT"); + b.Property<string>("Status") + .HasColumnType("TEXT"); - b.Property<int>("Type") - .HasColumnType("INTEGER"); + b.Property<int>("Type") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("RotatingStatus"); - }); + b.ToTable("RotatingStatus"); + }); modelBuilder.Entity("EllieBot.Db.Models.Sar", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int>("LevelReq") - .HasColumnType("INTEGER"); + b.Property<int>("LevelReq") + .HasColumnType("INTEGER"); - b.Property<ulong>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("RoleId") + .HasColumnType("INTEGER"); - b.Property<int>("SarGroupId") - .HasColumnType("INTEGER"); + b.Property<int>("SarGroupId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("GuildId", "RoleId"); + b.HasAlternateKey("GuildId", "RoleId"); - b.HasIndex("SarGroupId"); + b.HasIndex("SarGroupId"); - b.ToTable("Sar"); - }); + b.ToTable("Sar"); + }); modelBuilder.Entity("EllieBot.Db.Models.SarAutoDelete", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<bool>("IsEnabled") - .HasColumnType("INTEGER"); + b.Property<bool>("IsEnabled") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId") - .IsUnique(); + b.HasIndex("GuildId") + .IsUnique(); - b.ToTable("SarAutoDelete"); - }); + b.ToTable("SarAutoDelete"); + }); modelBuilder.Entity("EllieBot.Db.Models.SarGroup", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("GroupNumber") - .HasColumnType("INTEGER"); + b.Property<int>("GroupNumber") + .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<bool>("IsExclusive") - .HasColumnType("INTEGER"); + b.Property<bool>("IsExclusive") + .HasColumnType("INTEGER"); - b.Property<string>("Name") - .HasMaxLength(100) - .HasColumnType("TEXT"); + b.Property<string>("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); - b.Property<ulong?>("RoleReq") - .HasColumnType("INTEGER"); + b.Property<ulong?>("RoleReq") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("GuildId", "GroupNumber"); + b.HasAlternateKey("GuildId", "GroupNumber"); - b.ToTable("SarGroup"); - }); + b.ToTable("SarGroup"); + }); modelBuilder.Entity("EllieBot.Db.Models.ShopEntry", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("AuthorId") - .HasColumnType("INTEGER"); + b.Property<ulong>("AuthorId") + .HasColumnType("INTEGER"); - b.Property<string>("Command") - .HasColumnType("TEXT"); + b.Property<string>("Command") + .HasColumnType("TEXT"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int>("Index") - .HasColumnType("INTEGER"); + b.Property<int>("Index") + .HasColumnType("INTEGER"); - b.Property<string>("Name") - .HasColumnType("TEXT"); + b.Property<string>("Name") + .HasColumnType("TEXT"); - b.Property<int>("Price") - .HasColumnType("INTEGER"); + b.Property<int>("Price") + .HasColumnType("INTEGER"); - b.Property<ulong>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("RoleId") + .HasColumnType("INTEGER"); - b.Property<string>("RoleName") - .HasColumnType("TEXT"); + b.Property<string>("RoleName") + .HasColumnType("TEXT"); - b.Property<ulong?>("RoleRequirement") - .HasColumnType("INTEGER"); + b.Property<ulong?>("RoleRequirement") + .HasColumnType("INTEGER"); - b.Property<int>("Type") - .HasColumnType("INTEGER"); + b.Property<int>("Type") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "Index") + .IsUnique(); - b.ToTable("ShopEntry"); - }); + b.ToTable("ShopEntry"); + }); modelBuilder.Entity("EllieBot.Db.Models.ShopEntryItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("ShopEntryId") - .HasColumnType("INTEGER"); + b.Property<int?>("ShopEntryId") + .HasColumnType("INTEGER"); - b.Property<string>("Text") - .HasColumnType("TEXT"); + b.Property<string>("Text") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("ShopEntryId"); + b.HasIndex("ShopEntryId"); - b.ToTable("ShopEntryItem"); - }); + b.ToTable("ShopEntryItem"); + }); modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredRole", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("RoleId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "RoleId") + .IsUnique(); - b.ToTable("SlowmodeIgnoredRole"); - }); + b.ToTable("SlowmodeIgnoredRole"); + }); modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); - b.ToTable("SlowmodeIgnoredUser"); - }); + b.ToTable("SlowmodeIgnoredUser"); + }); modelBuilder.Entity("EllieBot.Db.Models.StickyRole", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("RoleIds") - .HasColumnType("TEXT"); + b.Property<string>("RoleIds") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId", "UserId") - .IsUnique(); + b.HasIndex("GuildId", "UserId") + .IsUnique(); - b.ToTable("StickyRoles"); - }); + b.ToTable("StickyRoles"); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamOnlineMessage", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("MessageId") - .HasColumnType("INTEGER"); + b.Property<ulong>("MessageId") + .HasColumnType("INTEGER"); - b.Property<string>("Name") - .HasColumnType("TEXT"); + b.Property<string>("Name") + .HasColumnType("TEXT"); - b.Property<int>("Type") - .HasColumnType("INTEGER"); + b.Property<int>("Type") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("StreamOnlineMessages"); - }); + b.ToTable("StreamOnlineMessages"); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleBlacklistedUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("StreamRoleSettingsId") - .HasColumnType("INTEGER"); + b.Property<int>("StreamRoleSettingsId") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.Property<string>("Username") - .HasColumnType("TEXT"); + b.Property<string>("Username") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("StreamRoleSettingsId"); + b.HasIndex("StreamRoleSettingsId"); - b.ToTable("StreamRoleBlacklistedUser"); - }); + b.ToTable("StreamRoleBlacklistedUser"); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleSettings", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<ulong>("AddRoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("AddRoleId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<bool>("Enabled") - .HasColumnType("INTEGER"); + b.Property<bool>("Enabled") + .HasColumnType("INTEGER"); - b.Property<ulong>("FromRoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("FromRoleId") + .HasColumnType("INTEGER"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); - b.Property<string>("Keyword") - .HasColumnType("TEXT"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.Property<string>("Keyword") + .HasColumnType("TEXT"); - b.HasIndex("GuildConfigId") - .IsUnique(); + b.HasKey("Id"); - b.ToTable("StreamRoleSettings"); - }); + b.HasIndex("GuildId") + .IsUnique(); + + b.ToTable("StreamRoleSettings"); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleWhitelistedUser", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("StreamRoleSettingsId") - .HasColumnType("INTEGER"); + b.Property<int>("StreamRoleSettingsId") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.Property<string>("Username") - .HasColumnType("TEXT"); + b.Property<string>("Username") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("StreamRoleSettingsId"); + b.HasIndex("StreamRoleSettingsId"); - b.ToTable("StreamRoleWhitelistedUser"); - }); + b.ToTable("StreamRoleWhitelistedUser"); + }); modelBuilder.Entity("EllieBot.Db.Models.TempRole", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime>("ExpiresAt") - .HasColumnType("TEXT"); + b.Property<DateTime>("ExpiresAt") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<bool>("Remove") - .HasColumnType("INTEGER"); + b.Property<bool>("Remove") + .HasColumnType("INTEGER"); - b.Property<ulong>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("RoleId") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("GuildId", "UserId", "RoleId"); + b.HasAlternateKey("GuildId", "UserId", "RoleId"); - b.HasIndex("ExpiresAt"); + b.HasIndex("ExpiresAt"); - b.ToTable("TempRole"); - }); + b.ToTable("TempRole"); + }); modelBuilder.Entity("EllieBot.Db.Models.TodoModel", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int?>("ArchiveId") - .HasColumnType("INTEGER"); + b.Property<int?>("ArchiveId") + .HasColumnType("INTEGER"); - b.Property<DateTime>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime>("DateAdded") + .HasColumnType("TEXT"); - b.Property<bool>("IsDone") - .HasColumnType("INTEGER"); + b.Property<bool>("IsDone") + .HasColumnType("INTEGER"); - b.Property<string>("Todo") - .HasColumnType("TEXT"); + b.Property<string>("Todo") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("ArchiveId"); + b.HasIndex("ArchiveId"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.ToTable("Todos"); - }); + b.ToTable("Todos"); + }); modelBuilder.Entity("EllieBot.Db.Models.UnbanTimer", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<DateTime>("UnbanAt") - .HasColumnType("TEXT"); + b.Property<DateTime>("UnbanAt") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); - b.ToTable("UnbanTimer"); - }); + b.ToTable("UnbanTimer"); + }); modelBuilder.Entity("EllieBot.Db.Models.UnmuteTimer", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<DateTime>("UnmuteAt") - .HasColumnType("TEXT"); + b.Property<DateTime>("UnmuteAt") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); - b.ToTable("UnmuteTimer"); - }); + b.ToTable("UnmuteTimer"); + }); modelBuilder.Entity("EllieBot.Db.Models.UnroleTimer", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("RoleId") + .HasColumnType("INTEGER"); - b.Property<DateTime>("UnbanAt") - .HasColumnType("TEXT"); + b.Property<DateTime>("UnbanAt") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "UserId") + .IsUnique(); - b.ToTable("UnroleTimer"); - }); + b.ToTable("UnroleTimer"); + }); modelBuilder.Entity("EllieBot.Db.Models.UserXpStats", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.Property<long>("Xp") - .HasColumnType("INTEGER"); + b.Property<long>("Xp") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId"); + b.HasIndex("GuildId"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.HasIndex("Xp"); + b.HasIndex("Xp"); - b.HasIndex("UserId", "GuildId") - .IsUnique(); + b.HasIndex("UserId", "GuildId") + .IsUnique(); - b.ToTable("UserXpStats"); - }); + b.ToTable("UserXpStats"); + }); modelBuilder.Entity("EllieBot.Db.Models.VcRoleInfo", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<ulong>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("RoleId") + .HasColumnType("INTEGER"); - b.Property<ulong>("VoiceChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong>("VoiceChannelId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildConfigId"); + b.HasIndex("GuildId", "VoiceChannelId") + .IsUnique(); - b.ToTable("VcRoleInfo"); - }); + b.ToTable("VcRoleInfo"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuInfo", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int?>("AffinityId") - .HasColumnType("INTEGER"); + b.Property<int?>("AffinityId") + .HasColumnType("INTEGER"); - b.Property<int?>("ClaimerId") - .HasColumnType("INTEGER"); + b.Property<int?>("ClaimerId") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<long>("Price") - .HasColumnType("INTEGER"); + b.Property<long>("Price") + .HasColumnType("INTEGER"); - b.Property<int>("WaifuId") - .HasColumnType("INTEGER"); + b.Property<int>("WaifuId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("AffinityId"); + b.HasIndex("AffinityId"); - b.HasIndex("ClaimerId"); + b.HasIndex("ClaimerId"); - b.HasIndex("Price"); + b.HasIndex("Price"); - b.HasIndex("WaifuId") - .IsUnique(); + b.HasIndex("WaifuId") + .IsUnique(); - b.ToTable("WaifuInfo"); - }); + b.ToTable("WaifuInfo"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<string>("ItemEmoji") - .HasColumnType("TEXT"); + b.Property<string>("ItemEmoji") + .HasColumnType("TEXT"); - b.Property<string>("Name") - .HasColumnType("TEXT"); + b.Property<string>("Name") + .HasColumnType("TEXT"); - b.Property<int?>("WaifuInfoId") - .HasColumnType("INTEGER"); + b.Property<int?>("WaifuInfoId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("WaifuInfoId"); + b.HasIndex("WaifuInfoId"); - b.ToTable("WaifuItem"); - }); + b.ToTable("WaifuItem"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuUpdate", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int?>("NewId") - .HasColumnType("INTEGER"); + b.Property<int?>("NewId") + .HasColumnType("INTEGER"); - b.Property<int?>("OldId") - .HasColumnType("INTEGER"); + b.Property<int?>("OldId") + .HasColumnType("INTEGER"); - b.Property<int>("UpdateType") - .HasColumnType("INTEGER"); + b.Property<int>("UpdateType") + .HasColumnType("INTEGER"); - b.Property<int>("UserId") - .HasColumnType("INTEGER"); + b.Property<int>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("NewId"); + b.HasIndex("NewId"); - b.HasIndex("OldId"); + b.HasIndex("OldId"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.ToTable("WaifuUpdates"); - }); + b.ToTable("WaifuUpdates"); + }); modelBuilder.Entity("EllieBot.Db.Models.Warning", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<bool>("Forgiven") - .HasColumnType("INTEGER"); + b.Property<bool>("Forgiven") + .HasColumnType("INTEGER"); - b.Property<string>("ForgivenBy") - .HasColumnType("TEXT"); + b.Property<string>("ForgivenBy") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<string>("Moderator") - .HasColumnType("TEXT"); + b.Property<string>("Moderator") + .HasColumnType("TEXT"); - b.Property<string>("Reason") - .HasColumnType("TEXT"); + b.Property<string>("Reason") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.Property<long>("Weight") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(1L); + b.Property<long>("Weight") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(1L); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("DateAdded"); + b.HasIndex("DateAdded"); - b.HasIndex("GuildId"); + b.HasIndex("GuildId"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.ToTable("Warnings"); - }); + b.ToTable("Warnings"); + }); modelBuilder.Entity("EllieBot.Db.Models.WarningPunishment", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("Count") - .HasColumnType("INTEGER"); + b.Property<int>("Count") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<int>("Punishment") - .HasColumnType("INTEGER"); + b.Property<int>("Punishment") + .HasColumnType("INTEGER"); - b.Property<ulong?>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("RoleId") + .HasColumnType("INTEGER"); - b.Property<int>("Time") - .HasColumnType("INTEGER"); + b.Property<int>("Time") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("GuildId", "Count"); + b.HasAlternateKey("GuildId", "Count"); - b.ToTable("WarningPunishment"); - }); + b.ToTable("WarningPunishment"); + }); modelBuilder.Entity("EllieBot.Db.Models.XpCurrencyReward", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("Amount") - .HasColumnType("INTEGER"); + b.Property<int>("Amount") + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("Level") - .HasColumnType("INTEGER"); + b.Property<int>("Level") + .HasColumnType("INTEGER"); - b.Property<int>("XpSettingsId") - .HasColumnType("INTEGER"); + b.Property<int>("XpSettingsId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("XpSettingsId"); + b.HasIndex("XpSettingsId"); - b.ToTable("XpCurrencyReward"); - }); + b.HasIndex("Level", "XpSettingsId") + .IsUnique(); + + b.ToTable("XpCurrencyReward"); + }); modelBuilder.Entity("EllieBot.Db.Models.XpRoleReward", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("Level") - .HasColumnType("INTEGER"); + b.Property<int>("Level") + .HasColumnType("INTEGER"); - b.Property<bool>("Remove") - .HasColumnType("INTEGER"); + b.Property<bool>("Remove") + .HasColumnType("INTEGER"); - b.Property<ulong>("RoleId") - .HasColumnType("INTEGER"); + b.Property<ulong>("RoleId") + .HasColumnType("INTEGER"); - b.Property<int>("XpSettingsId") - .HasColumnType("INTEGER"); + b.Property<int>("XpSettingsId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("XpSettingsId", "Level") - .IsUnique(); + b.HasIndex("XpSettingsId", "Level") + .IsUnique(); - b.ToTable("XpRoleReward"); - }); + b.ToTable("XpRoleReward"); + }); modelBuilder.Entity("EllieBot.Db.Models.XpSettings", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); - b.Property<bool>("ServerExcluded") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.Property<bool>("ServerExcluded") + .HasColumnType("INTEGER"); - b.HasIndex("GuildConfigId") - .IsUnique(); + b.HasKey("Id"); - b.ToTable("XpSettings"); - }); + b.HasIndex("GuildId") + .IsUnique(); + + b.ToTable("XpSettings"); + }); modelBuilder.Entity("EllieBot.Db.Models.XpShopOwnedItem", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<DateTime?>("DateAdded") - .HasColumnType("TEXT"); + b.Property<DateTime?>("DateAdded") + .HasColumnType("TEXT"); - b.Property<bool>("IsUsing") - .HasColumnType("INTEGER"); + b.Property<bool>("IsUsing") + .HasColumnType("INTEGER"); - b.Property<string>("ItemKey") - .IsRequired() - .HasColumnType("TEXT"); + b.Property<string>("ItemKey") + .IsRequired() + .HasColumnType("TEXT"); - b.Property<int>("ItemType") - .HasColumnType("INTEGER"); + b.Property<int>("ItemType") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("UserId", "ItemType", "ItemKey") - .IsUnique(); + b.HasIndex("UserId", "ItemType", "ItemKey") + .IsUnique(); - b.ToTable("XpShopOwnedItem"); - }); + b.ToTable("XpShopOwnedItem"); + }); modelBuilder.Entity("EllieBot.Modules.Games.FishCatch", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("Count") - .HasColumnType("INTEGER"); + b.Property<int>("Count") + .HasColumnType("INTEGER"); - b.Property<int>("FishId") - .HasColumnType("INTEGER"); + b.Property<int>("FishId") + .HasColumnType("INTEGER"); - b.Property<int>("MaxStars") - .HasColumnType("INTEGER"); + b.Property<int>("MaxStars") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasAlternateKey("UserId", "FishId"); + b.HasAlternateKey("UserId", "FishId"); - b.ToTable("FishCatch"); - }); + b.ToTable("FishCatch"); + }); modelBuilder.Entity("EllieBot.Modules.Games.UserFishStats", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("Skill") - .HasColumnType("INTEGER"); + b.Property<int>("Skill") + .HasColumnType("INTEGER"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("UserId") - .IsUnique(); + b.HasIndex("UserId") + .IsUnique(); - b.ToTable("UserFishStats"); - }); + b.ToTable("UserFishStats"); + }); modelBuilder.Entity("EllieBot.Services.GreetSettings", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("AutoDeleteTimer") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(0); + b.Property<int>("AutoDeleteTimer") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0); - b.Property<ulong?>("ChannelId") - .HasColumnType("INTEGER"); + b.Property<ulong?>("ChannelId") + .HasColumnType("INTEGER"); - b.Property<int>("GreetType") - .HasColumnType("INTEGER"); + b.Property<int>("GreetType") + .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") - .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") + .HasColumnType("INTEGER"); - b.Property<bool>("IsEnabled") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER") - .HasDefaultValue(false); + b.Property<bool>("IsEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(false); - b.Property<string>("MessageText") - .HasColumnType("TEXT"); + b.Property<string>("MessageText") + .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("GuildId", "GreetType") - .IsUnique(); + b.HasIndex("GuildId", "GreetType") + .IsUnique(); - b.ToTable("GreetSettings"); - }); + b.ToTable("GreetSettings"); + }); modelBuilder.Entity("EllieBot.Services.Rakeback", b => - { - b.Property<ulong>("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<ulong>("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<decimal>("Amount") - .HasColumnType("TEXT"); + b.Property<decimal>("Amount") + .HasColumnType("TEXT"); - b.HasKey("UserId"); + b.HasKey("UserId"); - b.ToTable("Rakeback"); - }); + b.ToTable("Rakeback"); + }); modelBuilder.Entity("EllieBot.Services.UserBetStats", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property<int>("Game") - .HasColumnType("INTEGER"); + b.Property<int>("Game") + .HasColumnType("INTEGER"); - b.Property<long>("LoseCount") - .HasColumnType("INTEGER"); + b.Property<long>("LoseCount") + .HasColumnType("INTEGER"); - b.Property<long>("MaxBet") - .HasColumnType("INTEGER"); + b.Property<long>("MaxBet") + .HasColumnType("INTEGER"); - b.Property<long>("MaxWin") - .HasColumnType("INTEGER"); + b.Property<long>("MaxWin") + .HasColumnType("INTEGER"); - b.Property<decimal>("PaidOut") - .HasColumnType("TEXT"); + b.Property<decimal>("PaidOut") + .HasColumnType("TEXT"); - b.Property<decimal>("TotalBet") - .HasColumnType("TEXT"); + b.Property<decimal>("TotalBet") + .HasColumnType("TEXT"); - b.Property<ulong>("UserId") - .HasColumnType("INTEGER"); + b.Property<ulong>("UserId") + .HasColumnType("INTEGER"); - b.Property<long>("WinCount") - .HasColumnType("INTEGER"); + b.Property<long>("WinCount") + .HasColumnType("INTEGER"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("MaxWin"); + b.HasIndex("MaxWin"); - b.HasIndex("UserId", "Game") - .IsUnique(); + b.HasIndex("UserId", "Game") + .IsUnique(); - b.ToTable("UserBetStats"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.AntiAltSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiAltSetting") - .HasForeignKey("EllieBot.Db.Models.AntiAltSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("EllieBot.Db.Models.AntiRaidSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiRaidSetting") - .HasForeignKey("EllieBot.Db.Models.AntiRaidSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + b.ToTable("UserBetStats"); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamIgnore", b => - { - b.HasOne("EllieBot.Db.Models.AntiSpamSetting", null) - .WithMany("IgnoredChannels") - .HasForeignKey("AntiSpamSettingId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithOne("AntiSpamSetting") - .HasForeignKey("EllieBot.Db.Models.AntiSpamSetting", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + { + b.HasOne("EllieBot.Db.Models.AntiSpamSetting", null) + .WithMany("IgnoredChannels") + .HasForeignKey("AntiSpamSettingId") + .OnDelete(DeleteBehavior.Cascade); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateUser", b => - { - b.HasOne("EllieBot.Db.Models.AutoTranslateChannel", "Channel") - .WithMany("Users") - .HasForeignKey("ChannelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + { + b.HasOne("EllieBot.Db.Models.AutoTranslateChannel", "Channel") + .WithMany("Users") + .HasForeignKey("ChannelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("Channel"); - }); + b.Navigation("Channel"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubApplicants", b => - { - b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") - .WithMany("Applicants") - .HasForeignKey("ClubId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + { + b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") + .WithMany("Applicants") + .HasForeignKey("ClubId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.HasOne("EllieBot.Db.Models.DiscordUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.HasOne("EllieBot.Db.Models.DiscordUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("Club"); + b.Navigation("Club"); - b.Navigation("User"); - }); + b.Navigation("User"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubBans", b => - { - b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") - .WithMany("Bans") - .HasForeignKey("ClubId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + { + b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") + .WithMany("Bans") + .HasForeignKey("ClubId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.HasOne("EllieBot.Db.Models.DiscordUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.HasOne("EllieBot.Db.Models.DiscordUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("Club"); + b.Navigation("Club"); - b.Navigation("User"); - }); + b.Navigation("User"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubInfo", b => - { - b.HasOne("EllieBot.Db.Models.DiscordUser", "Owner") - .WithOne() - .HasForeignKey("EllieBot.Db.Models.ClubInfo", "OwnerId") - .OnDelete(DeleteBehavior.SetNull); + { + b.HasOne("EllieBot.Db.Models.DiscordUser", "Owner") + .WithOne() + .HasForeignKey("EllieBot.Db.Models.ClubInfo", "OwnerId") + .OnDelete(DeleteBehavior.SetNull); - b.Navigation("Owner"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.CommandAlias", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("CommandAliases") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.CommandCooldown", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("CommandCooldowns") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.DelMsgOnCmdChannel", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("DelMsgOnCmdChannels") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + b.Navigation("Owner"); + }); modelBuilder.Entity("EllieBot.Db.Models.DiscordUser", b => - { - b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") - .WithMany("Members") - .HasForeignKey("ClubId") - .OnDelete(DeleteBehavior.NoAction); + { + b.HasOne("EllieBot.Db.Models.ClubInfo", "Club") + .WithMany("Members") + .HasForeignKey("ClubId") + .OnDelete(DeleteBehavior.NoAction); - b.Navigation("Club"); - }); + b.Navigation("Club"); + }); modelBuilder.Entity("EllieBot.Db.Models.ExcludedItem", b => - { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") - .WithMany("ExclusionList") - .HasForeignKey("XpSettingsId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("XpSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.FeedSub", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithMany("FeedSubs") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("GuildConfig"); - }); + { + b.HasOne("EllieBot.Db.Models.XpSettings", null) + .WithMany("ExclusionList") + .HasForeignKey("XpSettingsId"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FilterInvitesChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); + { + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) + .WithMany("FilterInvitesChannelIds") + .HasForeignKey("GuildFilterConfigId"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterLinksChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FilterLinksChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); + { + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) + .WithMany("FilterLinksChannelIds") + .HasForeignKey("GuildFilterConfigId"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilterWordsChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FilterWordsChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); + { + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) + .WithMany("FilterWordsChannelIds") + .HasForeignKey("GuildFilterConfigId"); + }); modelBuilder.Entity("EllieBot.Db.Models.FilteredWord", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FilteredWords") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.FollowedStream", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("FollowedStreams") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.GCChannelId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithMany("GenerateCurrencyChannelIds") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - - b.Navigation("GuildConfig"); - }); + { + b.HasOne("EllieBot.Db.Models.GuildFilterConfig", null) + .WithMany("FilteredWords") + .HasForeignKey("GuildFilterConfigId"); + }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayUser", b => - { - b.HasOne("EllieBot.Db.Models.GiveawayModel", null) - .WithMany("Participants") - .HasForeignKey("GiveawayId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + { + b.HasOne("EllieBot.Db.Models.GiveawayModel", null) + .WithMany("Participants") + .HasForeignKey("GiveawayId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); modelBuilder.Entity("EllieBot.Db.Models.IgnoredLogItem", b => - { - b.HasOne("EllieBot.Db.Models.LogSetting", "LogSetting") - .WithMany("LogIgnores") - .HasForeignKey("LogSettingId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + { + b.HasOne("EllieBot.Db.Models.LogSetting", "LogSetting") + .WithMany("LogIgnores") + .HasForeignKey("LogSettingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("LogSetting"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.MutedUserId", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("MutedUsers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); + b.Navigation("LogSetting"); + }); modelBuilder.Entity("EllieBot.Db.Models.Permissionv2", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("Permissions") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); + { + b.HasOne("EllieBot.Db.Models.GuildConfig", null) + .WithMany("Permissions") + .HasForeignKey("GuildConfigId"); + }); modelBuilder.Entity("EllieBot.Db.Models.PlaylistSong", b => - { - b.HasOne("EllieBot.Db.Models.MusicPlaylist", null) - .WithMany("Songs") - .HasForeignKey("MusicPlaylistId") - .OnDelete(DeleteBehavior.Cascade); - }); + { + b.HasOne("EllieBot.Db.Models.MusicPlaylist", null) + .WithMany("Songs") + .HasForeignKey("MusicPlaylistId") + .OnDelete(DeleteBehavior.Cascade); + }); modelBuilder.Entity("EllieBot.Db.Models.Sar", b => - { - b.HasOne("EllieBot.Db.Models.SarGroup", null) - .WithMany("Roles") - .HasForeignKey("SarGroupId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("EllieBot.Db.Models.ShopEntry", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("ShopEntries") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); + { + b.HasOne("EllieBot.Db.Models.SarGroup", null) + .WithMany("Roles") + .HasForeignKey("SarGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); modelBuilder.Entity("EllieBot.Db.Models.ShopEntryItem", b => - { - b.HasOne("EllieBot.Db.Models.ShopEntry", null) - .WithMany("Items") - .HasForeignKey("ShopEntryId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredRole", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("SlowmodeIgnoredRoles") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.SlowmodeIgnoredUser", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("SlowmodeIgnoredUsers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); + { + b.HasOne("EllieBot.Db.Models.ShopEntry", null) + .WithMany("Items") + .HasForeignKey("ShopEntryId") + .OnDelete(DeleteBehavior.Cascade); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleBlacklistedUser", b => - { - b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") - .WithMany("Blacklist") - .HasForeignKey("StreamRoleSettingsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + { + b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") + .WithMany("Blacklist") + .HasForeignKey("StreamRoleSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("StreamRoleSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.StreamRoleSettings", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithOne("StreamRole") - .HasForeignKey("EllieBot.Db.Models.StreamRoleSettings", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("GuildConfig"); - }); + b.Navigation("StreamRoleSettings"); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleWhitelistedUser", b => - { - b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") - .WithMany("Whitelist") - .HasForeignKey("StreamRoleSettingsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + { + b.HasOne("EllieBot.Db.Models.StreamRoleSettings", "StreamRoleSettings") + .WithMany("Whitelist") + .HasForeignKey("StreamRoleSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("StreamRoleSettings"); - }); + b.Navigation("StreamRoleSettings"); + }); modelBuilder.Entity("EllieBot.Db.Models.TodoModel", b => - { - b.HasOne("EllieBot.Db.Models.ArchivedTodoListModel", null) - .WithMany("Items") - .HasForeignKey("ArchiveId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnbanTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnbanTimer") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnmuteTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnmuteTimers") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.UnroleTimer", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("UnroleTimer") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("EllieBot.Db.Models.VcRoleInfo", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", null) - .WithMany("VcRoleInfos") - .HasForeignKey("GuildConfigId") - .OnDelete(DeleteBehavior.Cascade); - }); + { + b.HasOne("EllieBot.Db.Models.ArchivedTodoListModel", null) + .WithMany("Items") + .HasForeignKey("ArchiveId") + .OnDelete(DeleteBehavior.Cascade); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuInfo", b => - { - b.HasOne("EllieBot.Db.Models.DiscordUser", "Affinity") - .WithMany() - .HasForeignKey("AffinityId"); + { + b.HasOne("EllieBot.Db.Models.DiscordUser", "Affinity") + .WithMany() + .HasForeignKey("AffinityId"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "Claimer") - .WithMany() - .HasForeignKey("ClaimerId"); + b.HasOne("EllieBot.Db.Models.DiscordUser", "Claimer") + .WithMany() + .HasForeignKey("ClaimerId"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "Waifu") - .WithOne() - .HasForeignKey("EllieBot.Db.Models.WaifuInfo", "WaifuId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.HasOne("EllieBot.Db.Models.DiscordUser", "Waifu") + .WithOne() + .HasForeignKey("EllieBot.Db.Models.WaifuInfo", "WaifuId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("Affinity"); + b.Navigation("Affinity"); - b.Navigation("Claimer"); + b.Navigation("Claimer"); - b.Navigation("Waifu"); - }); + b.Navigation("Waifu"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuItem", b => - { - b.HasOne("EllieBot.Db.Models.WaifuInfo", "WaifuInfo") - .WithMany("Items") - .HasForeignKey("WaifuInfoId"); + { + b.HasOne("EllieBot.Db.Models.WaifuInfo", "WaifuInfo") + .WithMany("Items") + .HasForeignKey("WaifuInfoId"); - b.Navigation("WaifuInfo"); - }); + b.Navigation("WaifuInfo"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuUpdate", b => - { - b.HasOne("EllieBot.Db.Models.DiscordUser", "New") - .WithMany() - .HasForeignKey("NewId"); + { + b.HasOne("EllieBot.Db.Models.DiscordUser", "New") + .WithMany() + .HasForeignKey("NewId"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "Old") - .WithMany() - .HasForeignKey("OldId"); + b.HasOne("EllieBot.Db.Models.DiscordUser", "Old") + .WithMany() + .HasForeignKey("OldId"); - b.HasOne("EllieBot.Db.Models.DiscordUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.HasOne("EllieBot.Db.Models.DiscordUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("New"); + b.Navigation("New"); - b.Navigation("Old"); + b.Navigation("Old"); - b.Navigation("User"); - }); + b.Navigation("User"); + }); modelBuilder.Entity("EllieBot.Db.Models.XpCurrencyReward", b => - { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") - .WithMany("CurrencyRewards") - .HasForeignKey("XpSettingsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("XpSettings"); - }); + { + b.HasOne("EllieBot.Db.Models.XpSettings", null) + .WithMany("CurrencyRewards") + .HasForeignKey("XpSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); modelBuilder.Entity("EllieBot.Db.Models.XpRoleReward", b => - { - b.HasOne("EllieBot.Db.Models.XpSettings", "XpSettings") - .WithMany("RoleRewards") - .HasForeignKey("XpSettingsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("XpSettings"); - }); - - modelBuilder.Entity("EllieBot.Db.Models.XpSettings", b => - { - b.HasOne("EllieBot.Db.Models.GuildConfig", "GuildConfig") - .WithOne("XpSettings") - .HasForeignKey("EllieBot.Db.Models.XpSettings", "GuildConfigId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("GuildConfig"); - }); + { + b.HasOne("EllieBot.Db.Models.XpSettings", null) + .WithMany("RoleRewards") + .HasForeignKey("XpSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); modelBuilder.Entity("EllieBot.Db.Models.AntiSpamSetting", b => - { - b.Navigation("IgnoredChannels"); - }); + { + b.Navigation("IgnoredChannels"); + }); modelBuilder.Entity("EllieBot.Db.Models.ArchivedTodoListModel", b => - { - b.Navigation("Items"); - }); + { + b.Navigation("Items"); + }); modelBuilder.Entity("EllieBot.Db.Models.AutoTranslateChannel", b => - { - b.Navigation("Users"); - }); + { + b.Navigation("Users"); + }); modelBuilder.Entity("EllieBot.Db.Models.ClubInfo", b => - { - b.Navigation("Applicants"); + { + b.Navigation("Applicants"); - b.Navigation("Bans"); + b.Navigation("Bans"); - b.Navigation("Members"); - }); + b.Navigation("Members"); + }); modelBuilder.Entity("EllieBot.Db.Models.GiveawayModel", b => - { - b.Navigation("Participants"); - }); + { + b.Navigation("Participants"); + }); modelBuilder.Entity("EllieBot.Db.Models.GuildConfig", b => - { - b.Navigation("AntiAltSetting"); + { + b.Navigation("Permissions"); + }); - b.Navigation("AntiRaidSetting"); + modelBuilder.Entity("EllieBot.Db.Models.GuildFilterConfig", b => + { + b.Navigation("FilterInvitesChannelIds"); - b.Navigation("AntiSpamSetting"); + b.Navigation("FilterLinksChannelIds"); - b.Navigation("CommandAliases"); + b.Navigation("FilterWordsChannelIds"); - b.Navigation("CommandCooldowns"); - - b.Navigation("DelMsgOnCmdChannels"); - - b.Navigation("FeedSubs"); - - b.Navigation("FilterInvitesChannelIds"); - - b.Navigation("FilterLinksChannelIds"); - - b.Navigation("FilterWordsChannelIds"); - - b.Navigation("FilteredWords"); - - b.Navigation("FollowedStreams"); - - b.Navigation("GenerateCurrencyChannelIds"); - - b.Navigation("MutedUsers"); - - b.Navigation("Permissions"); - - b.Navigation("ShopEntries"); - - b.Navigation("SlowmodeIgnoredRoles"); - - b.Navigation("SlowmodeIgnoredUsers"); - - b.Navigation("StreamRole"); - - b.Navigation("UnbanTimer"); - - b.Navigation("UnmuteTimers"); - - b.Navigation("UnroleTimer"); - - b.Navigation("VcRoleInfos"); - - b.Navigation("XpSettings"); - }); + b.Navigation("FilteredWords"); + }); modelBuilder.Entity("EllieBot.Db.Models.LogSetting", b => - { - b.Navigation("LogIgnores"); - }); + { + b.Navigation("LogIgnores"); + }); modelBuilder.Entity("EllieBot.Db.Models.MusicPlaylist", b => - { - b.Navigation("Songs"); - }); + { + b.Navigation("Songs"); + }); modelBuilder.Entity("EllieBot.Db.Models.SarGroup", b => - { - b.Navigation("Roles"); - }); + { + b.Navigation("Roles"); + }); modelBuilder.Entity("EllieBot.Db.Models.ShopEntry", b => - { - b.Navigation("Items"); - }); + { + b.Navigation("Items"); + }); modelBuilder.Entity("EllieBot.Db.Models.StreamRoleSettings", b => - { - b.Navigation("Blacklist"); + { + b.Navigation("Blacklist"); - b.Navigation("Whitelist"); - }); + b.Navigation("Whitelist"); + }); modelBuilder.Entity("EllieBot.Db.Models.WaifuInfo", b => - { - b.Navigation("Items"); - }); + { + b.Navigation("Items"); + }); modelBuilder.Entity("EllieBot.Db.Models.XpSettings", b => - { - b.Navigation("CurrencyRewards"); + { + b.Navigation("CurrencyRewards"); - b.Navigation("ExclusionList"); + b.Navigation("ExclusionList"); - b.Navigation("RoleRewards"); - }); + b.Navigation("RoleRewards"); + }); #pragma warning restore 612, 618 } } diff --git a/src/EllieBot/Modules/Administration/Administration.cs b/src/EllieBot/Modules/Administration/Administration.cs index b9332be..03baf19 100644 --- a/src/EllieBot/Modules/Administration/Administration.cs +++ b/src/EllieBot/Modules/Administration/Administration.cs @@ -94,7 +94,7 @@ public partial class Administration : EllieModule<AdministrationService> public async Task Delmsgoncmd(List _) { var guild = (SocketGuild)ctx.Guild; - var (enabled, channels) = _service.GetDelMsgOnCmdData(ctx.Guild.Id); + var (enabled, channels) = await _service.GetDelMsgOnCmdData(ctx.Guild.Id); var embed = CreateEmbed() .WithOkColor() @@ -124,14 +124,13 @@ public partial class Administration : EllieModule<AdministrationService> [Priority(1)] public async Task Delmsgoncmd(Server _ = Server.Server) { - if (_service.ToggleDeleteMessageOnCommand(ctx.Guild.Id)) + var enabled = await _service.ToggleDeleteMessageOnCommand(ctx.Guild.Id); + if (enabled) { - _service.DeleteMessagesOnCommand.Add(ctx.Guild.Id); await Response().Confirm(strs.delmsg_on).SendAsync(); } else { - _service.DeleteMessagesOnCommand.TryRemove(ctx.Guild.Id); await Response().Confirm(strs.delmsg_off).SendAsync(); } } diff --git a/src/EllieBot/Modules/Administration/AdministrationService.cs b/src/EllieBot/Modules/Administration/AdministrationService.cs index c354181..563f710 100644 --- a/src/EllieBot/Modules/Administration/AdministrationService.cs +++ b/src/EllieBot/Modules/Administration/AdministrationService.cs @@ -1,4 +1,6 @@ #nullable disable +using LinqToDB; +using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using EllieBot.Db.Models; using EllieBot.Modules.Administration._common.results; @@ -7,95 +9,130 @@ namespace EllieBot.Modules.Administration; public class AdministrationService : IEService { - public ConcurrentHashSet<ulong> DeleteMessagesOnCommand { get; } - public ConcurrentDictionary<ulong, bool> DeleteMessagesOnCommandChannels { get; } + private ConcurrentHashSet<ulong> deleteMessagesOnCommand; + private ConcurrentDictionary<ulong, bool> delMsgOnCmdChannels; private readonly DbService _db; private readonly IReplacementService _repSvc; private readonly ILogCommandService _logService; private readonly IHttpClientFactory _httpFactory; + private readonly ShardData _shardData; + private readonly CommandHandler _cmdHandler; public AdministrationService( - IBot bot, - CommandHandler cmdHandler, DbService db, IReplacementService repSvc, ILogCommandService logService, - IHttpClientFactory factory) + IHttpClientFactory factory, + ShardData shardData, + CommandHandler cmdHandler) { _db = db; + _shardData = shardData; _repSvc = repSvc; _logService = logService; _httpFactory = factory; - - DeleteMessagesOnCommand = new(bot.AllGuildConfigs.Where(g => g.DeleteMessageOnCommand).Select(g => g.GuildId)); - - DeleteMessagesOnCommandChannels = new(bot.AllGuildConfigs.SelectMany(x => x.DelMsgOnCmdChannels) - .ToDictionary(x => x.ChannelId, x => x.State) - .ToConcurrent()); - - cmdHandler.CommandExecuted += DelMsgOnCmd_Handler; + _cmdHandler = cmdHandler; } - public (bool DelMsgOnCmd, IEnumerable<DelMsgOnCmdChannel> channels) GetDelMsgOnCmdData(ulong guildId) + public async Task ReadyAsync() + { + await using var uow = _db.GetDbContext(); + deleteMessagesOnCommand = new(await uow.GetTable<GuildConfig>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId) && x.DeleteMessageOnCommand) + .Select(x => x.GuildId) + .ToListAsyncLinqToDB()); + + delMsgOnCmdChannels = (await uow.GetTable<DelMsgOnCmdChannel>() + .Where(x => deleteMessagesOnCommand.Contains(x.GuildId)) + .ToDictionaryAsyncLinqToDB(x => x.ChannelId, x => x.State)) + .ToConcurrent(); + + _cmdHandler.CommandExecuted += DelMsgOnCmd_Handler; + } + + public async Task<(bool DelMsgOnCmd, IEnumerable<DelMsgOnCmdChannel> channels)> GetDelMsgOnCmdData(ulong guildId) { using var uow = _db.GetDbContext(); - var conf = uow.GuildConfigsForId(guildId, set => set.Include(x => x.DelMsgOnCmdChannels)); - return (conf.DeleteMessageOnCommand, conf.DelMsgOnCmdChannels); + var conf = await uow.GetTable<GuildConfig>() + .Where(x => x.GuildId == guildId) + .Select(x => x.DeleteMessageOnCommand) + .FirstOrDefaultAsyncLinqToDB(); + + var channels = await uow.GetTable<DelMsgOnCmdChannel>() + .Where(x => x.GuildId == guildId) + .ToListAsyncLinqToDB(); + + return (conf, channels); } private Task DelMsgOnCmd_Handler(IUserMessage msg, CommandInfo cmd) { if (msg.Channel is not ITextChannel channel) return Task.CompletedTask; - + _ = Task.Run(async () => { //wat ?! - if (DeleteMessagesOnCommandChannels.TryGetValue(channel.Id, out var state)) + if (delMsgOnCmdChannels.TryGetValue(channel.Id, out var state)) { if (state && cmd.Name != "prune" && cmd.Name != "pick") { _logService.AddDeleteIgnore(msg.Id); - try { await msg.DeleteAsync(); } + try + { await msg.DeleteAsync(); } catch { } } //if state is false, that means do not do it } - else if (DeleteMessagesOnCommand.Contains(channel.Guild.Id) && cmd.Name != "prune" && cmd.Name != "pick") + else if (deleteMessagesOnCommand.Contains(channel.Guild.Id) && cmd.Name != "prune" && cmd.Name != "pick") { _logService.AddDeleteIgnore(msg.Id); - try { await msg.DeleteAsync(); } + try + { await msg.DeleteAsync(); } catch { } } }); return Task.CompletedTask; } - public bool ToggleDeleteMessageOnCommand(ulong guildId) + public async Task<bool> ToggleDeleteMessageOnCommand(ulong guildId) { - bool enabled; using var uow = _db.GetDbContext(); - var conf = uow.GuildConfigsForId(guildId, set => set); - enabled = conf.DeleteMessageOnCommand = !conf.DeleteMessageOnCommand; - uow.SaveChanges(); - return enabled; + var conf = await uow.GetTable<GuildConfig>() + .Where(x => x.GuildId == guildId) + .UpdateWithOutputAsync(x => new() + { + DeleteMessageOnCommand = !x.DeleteMessageOnCommand + }); + + if (conf.Length == 0) + return false; + + var val = conf[0].Inserted.DeleteMessageOnCommand; + + if (val) + deleteMessagesOnCommand.Add(guildId); + else + deleteMessagesOnCommand.TryRemove(guildId); + + return val; } public async Task SetDelMsgOnCmdState(ulong guildId, ulong chId, Administration.State newState) { await using (var uow = _db.GetDbContext()) { - var conf = uow.GuildConfigsForId(guildId, set => set.Include(x => x.DelMsgOnCmdChannels)); + var old = await uow.GetTable<DelMsgOnCmdChannel>() + .Where(x => x.GuildId == guildId && x.ChannelId == chId) + .FirstOrDefaultAsyncLinqToDB(); - var old = conf.DelMsgOnCmdChannels.FirstOrDefault(x => x.ChannelId == chId); if (newState == Administration.State.Inherit) { if (old is not null) { - conf.DelMsgOnCmdChannels.Remove(old); uow.Remove(old); } } @@ -103,15 +140,17 @@ public class AdministrationService : IEService { if (old is null) { - old = new() + old = new DelMsgOnCmdChannel { - ChannelId = chId + GuildId = guildId, + ChannelId = chId, + State = newState == Administration.State.Enable }; - conf.DelMsgOnCmdChannels.Add(old); + uow.Add(old); } old.State = newState == Administration.State.Enable; - DeleteMessagesOnCommandChannels[chId] = newState == Administration.State.Enable; + delMsgOnCmdChannels[chId] = newState == Administration.State.Enable; } await uow.SaveChangesAsync(); @@ -121,9 +160,13 @@ public class AdministrationService : IEService { } else if (newState == Administration.State.Enable) - DeleteMessagesOnCommandChannels[chId] = true; + { + delMsgOnCmdChannels[chId] = true; + } else - DeleteMessagesOnCommandChannels.TryRemove(chId, out _); + { + delMsgOnCmdChannels.TryRemove(chId, out _); + } } public async Task DeafenUsers(bool value, params IGuildUser[] users) @@ -164,20 +207,22 @@ public class AdministrationService : IEService public async Task<SetServerBannerResult> SetServerBannerAsync(IGuild guild, string img) { - if (!IsValidUri(img)) return SetServerBannerResult.InvalidURL; - + if (!IsValidUri(img)) + return SetServerBannerResult.InvalidURL; + var uri = new Uri(img); using var http = _httpFactory.CreateClient(); using var sr = await http.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead); - - if (!sr.IsImage()) return SetServerBannerResult.InvalidFileType; + + if (!sr.IsImage()) + return SetServerBannerResult.InvalidFileType; if (sr.GetContentLength() > 8.Megabytes()) { return SetServerBannerResult.Toolarge; } - + await using var imageStream = await sr.Content.ReadAsStreamAsync(); await guild.ModifyAsync(x => x.Banner = new Image(imageStream)); @@ -186,20 +231,22 @@ public class AdministrationService : IEService public async Task<SetServerIconResult> SetServerIconAsync(IGuild guild, string img) { - if (!IsValidUri(img)) return SetServerIconResult.InvalidURL; - + if (!IsValidUri(img)) + return SetServerIconResult.InvalidURL; + var uri = new Uri(img); using var http = _httpFactory.CreateClient(); using var sr = await http.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead); - - if (!sr.IsImage()) return SetServerIconResult.InvalidFileType; - + + if (!sr.IsImage()) + return SetServerIconResult.InvalidFileType; + await using var imageStream = await sr.Content.ReadAsStreamAsync(); await guild.ModifyAsync(x => x.Icon = new Image(imageStream)); return SetServerIconResult.Success; } - + private bool IsValidUri(string img) => !string.IsNullOrWhiteSpace(img) && Uri.IsWellFormedUriString(img, UriKind.Absolute); } \ No newline at end of file diff --git a/src/EllieBot/Modules/Administration/AutoAssignableRoles/AutoAssignRoleService.cs b/src/EllieBot/Modules/Administration/AutoAssignableRoles/AutoAssignRoleService.cs index 5e232f8..3a51f7e 100644 --- a/src/EllieBot/Modules/Administration/AutoAssignableRoles/AutoAssignRoleService.cs +++ b/src/EllieBot/Modules/Administration/AutoAssignableRoles/AutoAssignRoleService.cs @@ -3,6 +3,7 @@ using EllieBot.Db.Models; using System.Net; using System.Threading.Channels; using LinqToDB; +using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; namespace EllieBot.Modules.Administration.Services; @@ -11,9 +12,10 @@ public sealed class AutoAssignRoleService : IEService { private readonly DiscordSocketClient _client; private readonly DbService _db; + private readonly ShardData _shardData; //guildid/roleid - private readonly ConcurrentDictionary<ulong, IReadOnlyList<ulong>> _autoAssignableRoles; + private ConcurrentDictionary<ulong, IReadOnlyList<ulong>> _autoAssignableRoles; private readonly Channel<SocketGuildUser> _assignQueue = Channel.CreateBounded<SocketGuildUser>( new BoundedChannelOptions(100) @@ -23,63 +25,78 @@ public sealed class AutoAssignRoleService : IEService SingleWriter = false }); - public AutoAssignRoleService(DiscordSocketClient client, IBot bot, DbService db) + public AutoAssignRoleService( + DiscordSocketClient client, + IBot bot, + DbService db, + ShardData shardData) { _client = client; + _shardData = shardData; _db = db; + } - _autoAssignableRoles = bot.AllGuildConfigs.Where(x => !string.IsNullOrWhiteSpace(x.AutoAssignRoleIds)) - .ToDictionary<GuildConfig, ulong, IReadOnlyList<ulong>>(k => k.GuildId, - v => v.GetAutoAssignableRoles()) - .ToConcurrent(); - - _ = Task.Run(async () => + public async Task OnReadyAsync() + { + await using (var uow = _db.GetDbContext()) { - while (true) + _autoAssignableRoles = await uow.GetTable<GuildConfig>() + .Where(x => Queries.GuildOnShard(x.GuildId, + _shardData.TotalShards, + _shardData.ShardId)) + .Where(x => x.AutoAssignRoleIds != null) + .ToListAsyncLinqToDB() + .Fmap(x => x + .ToDictionary<GuildConfig, ulong, IReadOnlyList<ulong>>( + k => k.GuildId, + v => v.GetAutoAssignableRoles()) + .ToConcurrent()); + } + + _client.UserJoined += OnClientOnUserJoined; + _client.RoleDeleted += OnClientRoleDeleted; + + while (true) + { + var user = await _assignQueue.Reader.ReadAsync(); + if (!_autoAssignableRoles.TryGetValue(user.Guild.Id, out var savedRoleIds)) + continue; + + try { - var user = await _assignQueue.Reader.ReadAsync(); - if (!_autoAssignableRoles.TryGetValue(user.Guild.Id, out var savedRoleIds)) - continue; + var roleIds = savedRoleIds.Select(roleId => user.Guild.GetRole(roleId)) + .Where(x => x is not null) + .ToList(); - try + if (roleIds.Any()) { - var roleIds = savedRoleIds.Select(roleId => user.Guild.GetRole(roleId)) - .Where(x => x is not null) - .ToList(); - - if (roleIds.Any()) - { - await user.AddRolesAsync(roleIds); - await Task.Delay(250); - } - else - { - Log.Warning( - "Disabled 'Auto assign role' feature on {GuildName} [{GuildId}] server the roles dont exist", - user.Guild.Name, - user.Guild.Id); - - await DisableAarAsync(user.Guild.Id); - } + await user.AddRolesAsync(roleIds); + await Task.Delay(250); } - catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.Forbidden) + else { Log.Warning( - "Disabled 'Auto assign role' feature on {GuildName} [{GuildId}] server because I don't have role management permissions", + "Disabled 'Auto assign role' feature on {GuildName} [{GuildId}] server the roles dont exist", user.Guild.Name, user.Guild.Id); await DisableAarAsync(user.Guild.Id); } - catch (Exception ex) - { - Log.Warning(ex, "Error in aar. Probably one of the roles doesn't exist"); - } } - }); + catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.Forbidden) + { + Log.Warning( + "Disabled 'Auto assign role' feature on {GuildName} [{GuildId}] server because I don't have role management permissions", + user.Guild.Name, + user.Guild.Id); - _client.UserJoined += OnClientOnUserJoined; - _client.RoleDeleted += OnClientRoleDeleted; + await DisableAarAsync(user.Guild.Id); + } + catch (Exception ex) + { + Log.Warning(ex, "Error in aar. Probably one of the roles doesn't exist"); + } + } } private async Task OnClientRoleDeleted(SocketRole role) @@ -117,7 +134,8 @@ public sealed class AutoAssignRoleService : IEService { await using var uow = _db.GetDbContext(); - await uow.Set<GuildConfig>().AsNoTracking() + await uow.Set<GuildConfig>() + .AsNoTracking() .Where(x => x.GuildId == guildId) .UpdateAsync(_ => new() { diff --git a/src/EllieBot/Modules/Administration/AutoPublishService.cs b/src/EllieBot/Modules/Administration/AutoPublishService.cs index 2e877bb..791bd31 100644 --- a/src/EllieBot/Modules/Administration/AutoPublishService.cs +++ b/src/EllieBot/Modules/Administration/AutoPublishService.cs @@ -42,7 +42,7 @@ public class AutoPublishService : IExecNoCommand, IReadyExecutor, IEService await using var ctx = _db.GetDbContext(); var items = await ctx.GetTable<AutoPublishChannel>() - .Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId, creds.TotalShards, _client.ShardId)) + .Where(x => Queries.GuildOnShard(x.GuildId, creds.TotalShards, _client.ShardId)) .ToListAsyncLinqToDB(); _enabled = items diff --git a/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelCommands.cs b/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelCommands.cs index 8099573..34e28de 100644 --- a/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelCommands.cs +++ b/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelCommands.cs @@ -25,10 +25,11 @@ public partial class Administration var id = _service.ToggleGameVoiceChannel(ctx.Guild.Id, vch.Id); if (id is null) + { await Response().Confirm(strs.gvc_disabled).SendAsync(); + } else { - _service.GameVoiceChannels.Add(vch.Id); await Response().Confirm(strs.gvc_enabled(Format.Bold(vch.Name))).SendAsync(); } } diff --git a/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs b/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs index e83e5a3..0d7dfe6 100644 --- a/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs +++ b/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs @@ -1,9 +1,12 @@ #nullable disable +using LinqToDB.EntityFrameworkCore; +using EllieBot.Db.Models; + namespace EllieBot.Modules.Administration.Services; public class GameVoiceChannelService : IEService { - public ConcurrentHashSet<ulong> GameVoiceChannels { get; } + private ConcurrentHashSet<ulong> _gameVoiceChannels = new(); private readonly DbService _db; private readonly DiscordSocketClient _client; @@ -12,10 +15,16 @@ public class GameVoiceChannelService : IEService { _db = db; _client = client; + } - GameVoiceChannels = new(bot.AllGuildConfigs - .Where(gc => gc.GameVoiceChannel is not null) - .Select(gc => gc.GameVoiceChannel!.Value)); + public async Task InitializeAsync() + { + await using var uow = _db.GetDbContext(); + _gameVoiceChannels = new(await uow.Set<GuildConfig>() + .Where(gc => gc.GameVoiceChannel != null) + .Select(gc => gc.GameVoiceChannel) + .ToListAsyncLinqToDB() + .Fmap(u => new ConcurrentHashSet<ulong>(u.Select(x => x.Value)))); _client.UserVoiceStateUpdated += OnUserVoiceStateUpdated; _client.PresenceUpdated += OnPresenceUpdate; @@ -32,14 +41,14 @@ public class GameVoiceChannelService : IEService // if the user is in the voice channel and that voice channel is gvc if (newUser.VoiceChannel is not { } vc - || !GameVoiceChannels.Contains(vc.Id)) + || !_gameVoiceChannels.Contains(vc.Id)) return; //if the activity has changed, and is a playi1ng activity foreach (var activity in after.Activities) { if (activity is { Type: ActivityType.Playing }) - //trigger gvc + //trigger gvc { if (await TriggerGvc(newUser, activity.Name)) return; @@ -58,18 +67,19 @@ public class GameVoiceChannelService : IEService { ulong? id; using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set); + var gc = uow.GuildConfigsForId(guildId); + if (gc.GameVoiceChannel == vchId) { - GameVoiceChannels.TryRemove(vchId); + _gameVoiceChannels.TryRemove(vchId); id = gc.GameVoiceChannel = null; } else { if (gc.GameVoiceChannel is not null) - GameVoiceChannels.TryRemove(gc.GameVoiceChannel.Value); - GameVoiceChannels.Add(vchId); + _gameVoiceChannels.TryRemove(gc.GameVoiceChannel.Value); + _gameVoiceChannels.Add(vchId); id = gc.GameVoiceChannel = vchId; } @@ -89,7 +99,7 @@ public class GameVoiceChannelService : IEService if (newState.VoiceChannel is null) return; - if (!GameVoiceChannels.Contains(newState.VoiceChannel.Id)) + if (!_gameVoiceChannels.Contains(newState.VoiceChannel.Id)) return; foreach (var game in gUser.Activities.Select(x => x.Name)) diff --git a/src/EllieBot/Modules/Administration/Mute/MuteService.cs b/src/EllieBot/Modules/Administration/Mute/MuteService.cs index cb74059..d061be5 100644 --- a/src/EllieBot/Modules/Administration/Mute/MuteService.cs +++ b/src/EllieBot/Modules/Administration/Mute/MuteService.cs @@ -1,5 +1,7 @@ #nullable disable -using Microsoft.EntityFrameworkCore; +using LinqToDB; +using LinqToDB.EntityFrameworkCore; +using EllieBot.Common.ModuleBehaviors; using EllieBot.Db.Models; namespace EllieBot.Modules.Administration.Services; @@ -11,7 +13,7 @@ public enum MuteType All } -public class MuteService : IEService +public class MuteService : IEService, IReadyExecutor { public enum TimerType { Mute, Ban, AddRole } @@ -23,90 +25,23 @@ public class MuteService : IEService public event Action<IGuildUser, IUser, MuteType, string> UserMuted = delegate { }; public event Action<IGuildUser, IUser, MuteType, string> UserUnmuted = delegate { }; - public ConcurrentDictionary<ulong, string> GuildMuteRoles { get; } - public ConcurrentDictionary<ulong, ConcurrentHashSet<ulong>> MutedUsers { get; } + private ConcurrentDictionary<ulong, string> _guildMuteRoles = new(); + private ConcurrentDictionary<ulong, ConcurrentHashSet<ulong>> _mutedUsers = new(); public ConcurrentDictionary<ulong, ConcurrentDictionary<(ulong, TimerType), Timer>> UnTimers { get; } = new(); private readonly DiscordSocketClient _client; private readonly DbService _db; private readonly IMessageSenderService _sender; + private readonly ShardData _shardData; - public MuteService(DiscordSocketClient client, DbService db, IMessageSenderService sender) + public MuteService(DiscordSocketClient client, DbService db, IMessageSenderService sender, ShardData shardData) { _client = client; _db = db; _sender = sender; + _shardData = shardData; - using (var uow = db.GetDbContext()) - { - var guildIds = client.Guilds.Select(x => x.Id).ToList(); - var configs = uow.Set<GuildConfig>() - .AsNoTracking() - .AsSplitQuery() - .Include(x => x.MutedUsers) - .Include(x => x.UnbanTimer) - .Include(x => x.UnmuteTimers) - .Include(x => x.UnroleTimer) - .Where(x => guildIds.Contains(x.GuildId)) - .ToList(); - - GuildMuteRoles = configs.Where(c => !string.IsNullOrWhiteSpace(c.MuteRoleName)) - .ToDictionary(c => c.GuildId, c => c.MuteRoleName) - .ToConcurrent(); - - MutedUsers = new(configs.ToDictionary(k => k.GuildId, - v => new ConcurrentHashSet<ulong>(v.MutedUsers.Select(m => m.UserId)))); - - var max = TimeSpan.FromDays(49); - - foreach (var conf in configs) - { - foreach (var x in conf.UnmuteTimers) - { - TimeSpan after; - if (x.UnmuteAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow) - after = TimeSpan.FromMinutes(2); - else - { - var unmute = x.UnmuteAt - DateTime.UtcNow; - after = unmute > max ? max : unmute; - } - - StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.Mute); - } - - foreach (var x in conf.UnbanTimer) - { - TimeSpan after; - if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow) - after = TimeSpan.FromMinutes(2); - else - { - var unban = x.UnbanAt - DateTime.UtcNow; - after = unban > max ? max : unban; - } - - StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.Ban); - } - - foreach (var x in conf.UnroleTimer) - { - TimeSpan after; - if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow) - after = TimeSpan.FromMinutes(2); - else - { - var unban = x.UnbanAt - DateTime.UtcNow; - after = unban > max ? max : unban; - } - - StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.AddRole, x.RoleId); - } - } - - _client.UserJoined += Client_UserJoined; - } UserMuted += OnUserMuted; UserUnmuted += OnUserUnmuted; @@ -123,10 +58,10 @@ public class MuteService : IEService _ = Task.Run(() => _sender.Response(user) .Embed(_sender.CreateEmbed(user?.GuildId) - .WithDescription($"You've been muted in {user.Guild} server") - .AddField("Mute Type", type.ToString()) - .AddField("Moderator", mod.ToString()) - .AddField("Reason", reason)) + .WithDescription($"You've been muted in {user.Guild} server") + .AddField("Mute Type", type.ToString()) + .AddField("Moderator", mod.ToString()) + .AddField("Reason", reason)) .SendAsync()); } @@ -141,10 +76,10 @@ public class MuteService : IEService _ = Task.Run(() => _sender.Response(user) .Embed(_sender.CreateEmbed(user.GuildId) - .WithDescription($"You've been unmuted in {user.Guild} server") - .AddField("Unmute Type", type.ToString()) - .AddField("Moderator", mod.ToString()) - .AddField("Reason", reason)) + .WithDescription($"You've been unmuted in {user.Guild} server") + .AddField("Unmute Type", type.ToString()) + .AddField("Moderator", mod.ToString()) + .AddField("Reason", reason)) .SendAsync()); } @@ -152,7 +87,7 @@ public class MuteService : IEService { try { - MutedUsers.TryGetValue(usr.Guild.Id, out var muted); + _mutedUsers.TryGetValue(usr.Guild.Id, out var muted); if (muted is null || !muted.Contains(usr.Id)) return Task.CompletedTask; @@ -169,9 +104,11 @@ public class MuteService : IEService public async Task SetMuteRoleAsync(ulong guildId, string name) { await using var uow = _db.GetDbContext(); - var config = uow.GuildConfigsForId(guildId, set => set); + var config = uow.GetTable<GuildConfig>() + .Where(x => x.GuildId == guildId) + .FirstOrDefault(); config.MuteRoleName = name; - GuildMuteRoles.AddOrUpdate(guildId, name, (_, _) => name); + _guildMuteRoles.AddOrUpdate(guildId, name, (_, _) => name); await uow.SaveChangesAsync(); } @@ -183,7 +120,8 @@ public class MuteService : IEService { if (type == MuteType.All) { - try { await usr.ModifyAsync(x => x.Mute = true); } + try + { await usr.ModifyAsync(x => x.Mute = true); } catch { } var muteRole = await GetMuteRole(usr.Guild); @@ -192,16 +130,23 @@ public class MuteService : IEService StopTimer(usr.GuildId, usr.Id, TimerType.Mute); await using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigsForId(usr.Guild.Id, - set => set.Include(gc => gc.MutedUsers).Include(gc => gc.UnmuteTimers)); - config.MutedUsers.Add(new() - { - UserId = usr.Id - }); - if (MutedUsers.TryGetValue(usr.Guild.Id, out var muted)) - muted.Add(usr.Id); + await uow.GetTable<MutedUserId>() + .InsertOrUpdateAsync(() => new() + { + GuildId = usr.GuildId, + UserId = usr.Id + }, + (_) => new() + { + }, + () => new() + { + GuildId = usr.GuildId, + UserId = usr.Id + }); - config.UnmuteTimers.RemoveWhere(x => x.UserId == usr.Id); + if (_mutedUsers.TryGetValue(usr.Guild.Id, out var muted)) + muted.Add(usr.Id); await uow.SaveChangesAsync(); } @@ -237,29 +182,26 @@ public class MuteService : IEService StopTimer(guildId, usrId, TimerType.Mute); await using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigsForId(guildId, - set => set.Include(gc => gc.MutedUsers).Include(gc => gc.UnmuteTimers)); - var match = new MutedUserId - { - UserId = usrId - }; - var toRemove = config.MutedUsers.FirstOrDefault(x => x.Equals(match)); - if (toRemove is not null) - uow.Remove(toRemove); - if (MutedUsers.TryGetValue(guildId, out var muted)) + await uow.GetTable<MutedUserId>() + .Where(x => x.GuildId == guildId && x.UserId == usrId) + .DeleteAsync(); + + await uow.GetTable<UnmuteTimer>() + .Where(x => x.GuildId == guildId && x.UserId == usrId) + .DeleteAsync(); + + if (_mutedUsers.TryGetValue(guildId, out var muted)) muted.TryRemove(usrId); - - config.UnmuteTimers.RemoveWhere(x => x.UserId == usrId); - - await uow.SaveChangesAsync(); } if (usr is not null) { - try { await usr.ModifyAsync(x => x.Mute = false); } + try + { await usr.ModifyAsync(x => x.Mute = false); } catch { } - try { await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild)); } + try + { await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild)); } catch { /*ignore*/ @@ -272,12 +214,9 @@ public class MuteService : IEService { if (usr is null) return; - try - { - await usr.ModifyAsync(x => x.Mute = false); - UserUnmuted(usr, mod, MuteType.Voice, reason); - } - catch { } + + await usr.ModifyAsync(x => x.Mute = false); + UserUnmuted(usr, mod, MuteType.Voice, reason); } else if (type == MuteType.Chat) { @@ -292,15 +231,16 @@ public class MuteService : IEService { ArgumentNullException.ThrowIfNull(guild); - const string defaultMuteRoleName = "ellie-mute"; + const string defaultMuteRoleName = "nadeko-mute"; - var muteRoleName = GuildMuteRoles.GetOrAdd(guild.Id, defaultMuteRoleName); + var muteRoleName = _guildMuteRoles.GetOrAdd(guild.Id, defaultMuteRoleName); var muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName); if (muteRole is null) - //if it doesn't exist, create it + //if it doesn't exist, create it { - try { muteRole = await guild.CreateRoleAsync(muteRoleName, isMentionable: false); } + try + { muteRole = await guild.CreateRoleAsync(muteRoleName, isMentionable: false); } catch { //if creations fails, maybe the name is not correct, find default one, if doesn't work, create default one @@ -340,13 +280,14 @@ public class MuteService : IEService await MuteUser(user, mod, muteType, reason); // mute the user. This will also remove any previous unmute timers await using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigsForId(user.GuildId, set => set.Include(x => x.UnmuteTimers)); - config.UnmuteTimers.Add(new() - { - UserId = user.Id, - UnmuteAt = DateTime.UtcNow + after - }); // add teh unmute timer to the database - uow.SaveChanges(); + var unmuteAt = DateTime.UtcNow + after; + await uow.GetTable<UnmuteTimer>() + .InsertAsync(() => new() + { + GuildId = user.GuildId, + UserId = user.Id, + UnmuteAt = unmuteAt + }); } StartUn_Timer(user.GuildId, user.Id, after, TimerType.Mute); // start the timer @@ -362,39 +303,20 @@ public class MuteService : IEService await guild.AddBanAsync(userId, pruneDays, reason); await using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigsForId(guild.Id, set => set.Include(x => x.UnbanTimer)); - config.UnbanTimer.Add(new() - { - UserId = userId, - UnbanAt = DateTime.UtcNow + after - }); // add teh unmute timer to the database - await uow.SaveChangesAsync(); + var unbanAt = DateTime.UtcNow + after; + await uow.GetTable<UnbanTimer>() + .InsertAsync(() => new() + { + GuildId = guild.Id, + UserId = userId, + UnbanAt = unbanAt + }); } StartUn_Timer(guild.Id, userId, after, TimerType.Ban); // start the timer } - public async Task TimedRole( - IGuildUser user, - TimeSpan after, - string reason, - IRole role) - { - await user.AddRoleAsync(role); - await using (var uow = _db.GetDbContext()) - { - var config = uow.GuildConfigsForId(user.GuildId, set => set.Include(x => x.UnroleTimer)); - config.UnroleTimer.Add(new() - { - UserId = user.Id, - UnbanAt = DateTime.UtcNow + after, - RoleId = role.Id - }); // add teh unmute timer to the database - uow.SaveChanges(); - } - - StartUn_Timer(user.GuildId, user.Id, after, TimerType.AddRole, role.Id); // start the timer - } + // todo unrole timers -> temprole public void StartUn_Timer( ulong guildId, @@ -408,56 +330,56 @@ public class MuteService : IEService //unmute timer to be added var toAdd = new Timer(async _ => + { + if (type == TimerType.Ban) { - if (type == TimerType.Ban) + try { - try - { - RemoveTimerFromDb(guildId, userId, type); - StopTimer(guildId, userId, type); - var guild = _client.GetGuild(guildId); // load the guild - if (guild is not null) - await guild.RemoveBanAsync(userId); - } - catch (Exception ex) - { - Log.Warning(ex, "Couldn't unban user {UserId} in guild {GuildId}", userId, guildId); - } + await RemoveTimerFromDb(guildId, userId, type); + StopTimer(guildId, userId, type); + var guild = _client.GetGuild(guildId); // load the guild + if (guild is not null) + await guild.RemoveBanAsync(userId); } - else if (type == TimerType.AddRole) + catch (Exception ex) { - try - { - if (roleId is null) - return; + Log.Warning(ex, "Couldn't unban user {UserId} in guild {GuildId}", userId, guildId); + } + } + else if (type == TimerType.AddRole) + { + try + { + if (roleId is null) + return; - RemoveTimerFromDb(guildId, userId, type); - StopTimer(guildId, userId, type); - var guild = _client.GetGuild(guildId); - var user = guild?.GetUser(userId); - var role = guild?.GetRole(roleId.Value); - if (guild is not null && user is not null && user.Roles.Contains(role)) - await user.RemoveRoleAsync(role); - } - catch (Exception ex) - { - Log.Warning(ex, "Couldn't remove role from user {UserId} in guild {GuildId}", userId, guildId); - } + await RemoveTimerFromDb(guildId, userId, type); + StopTimer(guildId, userId, type); + var guild = _client.GetGuild(guildId); + var user = guild?.GetUser(userId); + var role = guild?.GetRole(roleId.Value); + if (guild is not null && user is not null && user.Roles.Contains(role)) + await user.RemoveRoleAsync(role); } - else + catch (Exception ex) { - try - { - // unmute the user, this will also remove the timer from the db - await UnmuteUser(guildId, userId, _client.CurrentUser, reason: "Timed mute expired"); - } - catch (Exception ex) - { - RemoveTimerFromDb(guildId, userId, type); // if unmute errored, just remove unmute from db - Log.Warning(ex, "Couldn't unmute user {UserId} in guild {GuildId}", userId, guildId); - } + Log.Warning(ex, "Couldn't remove role from user {UserId} in guild {GuildId}", userId, guildId); } - }, + } + else + { + try + { + // unmute the user, this will also remove the timer from the db + await UnmuteUser(guildId, userId, _client.CurrentUser, reason: "Timed mute expired"); + } + catch (Exception ex) + { + await RemoveTimerFromDb(guildId, userId, type); // if unmute errored, just remove unmute from db + Log.Warning(ex, "Couldn't unmute user {UserId} in guild {GuildId}", userId, guildId); + } + } + }, null, after, Timeout.InfiniteTimeSpan); @@ -481,23 +403,97 @@ public class MuteService : IEService removed.Change(Timeout.Infinite, Timeout.Infinite); } - private void RemoveTimerFromDb(ulong guildId, ulong userId, TimerType type) + private async Task RemoveTimerFromDb(ulong guildId, ulong userId, TimerType type) { using var uow = _db.GetDbContext(); - object toDelete; - if (type == TimerType.Mute) + await using var ctx = _db.GetDbContext(); + } + + + // todo update to new way of tracking expiries + public async Task OnReadyAsync() + { + await using var uow = _db.GetDbContext(); + var configs = await uow.Set<GuildConfig>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB(); + + _guildMuteRoles = configs.Where(c => !string.IsNullOrWhiteSpace(c.MuteRoleName)) + .ToDictionary(c => c.GuildId, c => c.MuteRoleName) + .ToConcurrent(); + + _mutedUsers = await uow.GetTable<MutedUserId>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB() + .Fmap(x => x.GroupBy(x => x.GuildId) + .ToDictionary(g => g.Key, g => new ConcurrentHashSet<ulong>(g.Select(x => x.UserId))) + .ToConcurrent()); + + var max = TimeSpan.FromDays(49); + + var unmuteTimers = await uow.GetTable<UnmuteTimer>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB(); + + var unbanTimers = await uow.GetTable<UnbanTimer>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB(); + + var unroleTimers = await uow.GetTable<UnroleTimer>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB(); + + foreach (var conf in configs) { - var config = uow.GuildConfigsForId(guildId, set => set.Include(x => x.UnmuteTimers)); - toDelete = config.UnmuteTimers.FirstOrDefault(x => x.UserId == userId); - } - else - { - var config = uow.GuildConfigsForId(guildId, set => set.Include(x => x.UnbanTimer)); - toDelete = config.UnbanTimer.FirstOrDefault(x => x.UserId == userId); + foreach (var x in unmuteTimers) + { + TimeSpan after; + if (x.UnmuteAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow) + { + after = TimeSpan.FromMinutes(2); + } + else + { + var unmute = x.UnmuteAt - DateTime.UtcNow; + after = unmute > max ? max : unmute; + } + + StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.Mute); + } + + foreach (var x in unbanTimers) + { + TimeSpan after; + if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow) + { + after = TimeSpan.FromMinutes(2); + } + else + { + var unban = x.UnbanAt - DateTime.UtcNow; + after = unban > max ? max : unban; + } + + StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.Ban); + } + + foreach (var x in unroleTimers) + { + TimeSpan after; + if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow) + { + after = TimeSpan.FromMinutes(2); + } + else + { + var unban = x.UnbanAt - DateTime.UtcNow; + after = unban > max ? max : unban; + } + + StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.AddRole, x.RoleId); + } } - if (toDelete is not null) - uow.Remove(toDelete); - uow.SaveChanges(); + _client.UserJoined += Client_UserJoined; } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Administration/Notify/NotifyService.cs b/src/EllieBot/Modules/Administration/Notify/NotifyService.cs index fe81104..4509552 100644 --- a/src/EllieBot/Modules/Administration/Notify/NotifyService.cs +++ b/src/EllieBot/Modules/Administration/Notify/NotifyService.cs @@ -36,7 +36,7 @@ public sealed class NotifyService : IReadyExecutor, INotifySubscriber, IEService { await using var uow = _db.GetDbContext(); _events = (await uow.GetTable<Notify>() - .Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId, + .Where(x => Queries.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) .ToListAsyncLinqToDB()) @@ -224,4 +224,4 @@ public sealed class NotifyService : IReadyExecutor, INotifySubscriber, IEService .Where(x => x.GuildId == guildId && x.Type == nType) .FirstOrDefaultAsyncLinqToDB(); } -} +} \ No newline at end of file diff --git a/src/EllieBot/Modules/Administration/Protection/ProtectionCommands.cs b/src/EllieBot/Modules/Administration/Protection/ProtectionCommands.cs index d06d8d4..d0f8d7e 100644 --- a/src/EllieBot/Modules/Administration/Protection/ProtectionCommands.cs +++ b/src/EllieBot/Modules/Administration/Protection/ProtectionCommands.cs @@ -15,7 +15,7 @@ public partial class Administration [UserPerm(GuildPerm.Administrator)] public async Task AntiAlt() { - if (await _service.TryStopAntiAlt(ctx.Guild.Id)) + if (await _service.TryStopAntiAltAsync(ctx.Guild.Id)) { await Response().Confirm(strs.prot_disable("Anti-Alt")).SendAsync(); return; @@ -71,11 +71,15 @@ public partial class Administration [Cmd] [RequireContext(ContextType.Guild)] [UserPerm(GuildPerm.Administrator)] - public Task AntiRaid() + public async Task AntiRaid() { - if (_service.TryStopAntiRaid(ctx.Guild.Id)) - return Response().Confirm(strs.prot_disable("Anti-Raid")).SendAsync(); - return Response().Pending(strs.protection_not_running("Anti-Raid")).SendAsync(); + if (await _service.TryStopAntiRaidAsync(ctx.Guild.Id)) + { + await Response().Confirm(strs.prot_disable("Anti-Raid")).SendAsync(); + return; + } + + await Response().Pending(strs.protection_not_running("Anti-Raid")).SendAsync(); } [Cmd] @@ -147,11 +151,15 @@ public partial class Administration [Cmd] [RequireContext(ContextType.Guild)] [UserPerm(GuildPerm.Administrator)] - public Task AntiSpam() + public async Task AntiSpam() { - if (_service.TryStopAntiSpam(ctx.Guild.Id)) - return Response().Confirm(strs.prot_disable("Anti-Spam")).SendAsync(); - return Response().Pending(strs.protection_not_running("Anti-Spam")).SendAsync(); + if (await _service.TryStopAntiSpamAsync(ctx.Guild.Id)) + { + await Response().Confirm(strs.prot_disable("Anti-Spam")).SendAsync(); + return; + } + + await Response().Pending(strs.protection_not_running("Anti-Spam")).SendAsync(); } [Cmd] diff --git a/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs b/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs index b43f128..fb965b0 100644 --- a/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs +++ b/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs @@ -1,11 +1,15 @@ #nullable disable +using LinqToDB; +using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; +using EllieBot.Common.ModuleBehaviors; using EllieBot.Db.Models; +using EllieBot.Migrations; using System.Threading.Channels; namespace EllieBot.Modules.Administration.Services; -public class ProtectionService : IEService +public class ProtectionService : IReadyExecutor, IEService { public event Func<PunishmentAction, ProtectionType, IGuildUser[], Task> OnAntiProtectionTriggered = delegate { @@ -23,7 +27,7 @@ public class ProtectionService : IEService private readonly DbService _db; private readonly UserPunishService _punishService; private readonly INotifySubscriber _notifySub; - + private readonly ShardData _shardData; private readonly Channel<PunishQueueItem> _punishUserQueue = Channel.CreateUnbounded<PunishQueueItem>(new() { @@ -33,41 +37,23 @@ public class ProtectionService : IEService public ProtectionService( DiscordSocketClient client, - IBot bot, MuteService mute, DbService db, UserPunishService punishService, - INotifySubscriber notifySub) + INotifySubscriber notifySub, + ShardData shardData) { _client = client; _mute = mute; _db = db; _punishService = punishService; _notifySub = notifySub; - - var ids = client.GetGuildIds(); - using (var uow = db.GetDbContext()) - { - var configs = uow.Set<GuildConfig>() - .AsQueryable() - .Include(x => x.AntiRaidSetting) - .Include(x => x.AntiSpamSetting) - .ThenInclude(x => x.IgnoredChannels) - .Include(x => x.AntiAltSetting) - .Where(x => ids.Contains(x.GuildId)) - .ToList(); - - foreach (var gc in configs) - Initialize(gc); - } + _shardData = shardData; _client.MessageReceived += HandleAntiSpam; _client.UserJoined += HandleUserJoined; - bot.JoinedGuild += _bot_JoinedGuild; _client.LeftGuild += _client_LeftGuild; - - _ = Task.Run(RunQueue); } private async Task RunQueue() @@ -103,53 +89,13 @@ public class ProtectionService : IEService { _ = Task.Run(async () => { - TryStopAntiRaid(guild.Id); - TryStopAntiSpam(guild.Id); - await TryStopAntiAlt(guild.Id); + await TryStopAntiRaidAsync(guild.Id); + await TryStopAntiSpamAsync(guild.Id); + await TryStopAntiAltAsync(guild.Id); }); return Task.CompletedTask; } - private Task _bot_JoinedGuild(GuildConfig gc) - { - using var uow = _db.GetDbContext(); - var gcWithData = uow.GuildConfigsForId(gc.GuildId, - set => set.Include(x => x.AntiRaidSetting) - .Include(x => x.AntiAltSetting) - .Include(x => x.AntiSpamSetting) - .ThenInclude(x => x.IgnoredChannels)); - - Initialize(gcWithData); - return Task.CompletedTask; - } - - private void Initialize(GuildConfig gc) - { - var raid = gc.AntiRaidSetting; - var spam = gc.AntiSpamSetting; - - if (raid is not null) - { - var raidStats = new AntiRaidStats - { - AntiRaidSettings = raid - }; - _antiRaidGuilds[gc.GuildId] = raidStats; - } - - if (spam is not null) - { - _antiSpamGuilds[gc.GuildId] = new() - { - AntiSpamSettings = spam - }; - } - - var alt = gc.AntiAltSetting; - if (alt is not null) - _antiAltGuilds[gc.GuildId] = new(alt); - } - private Task HandleUserJoined(SocketGuildUser user) { if (user.IsBot) @@ -201,7 +147,8 @@ public class ProtectionService : IEService await PunishUsers(settings.Action, ProtectionType.Raiding, settings.PunishDuration, null, users); await _notifySub.NotifyAsync( - new ProtectionNotifyModel(user.Guild.Id, ProtectionType.Raiding, users[0].Id)); + new ProtectionNotifyModel(user.Guild.Id, ProtectionType.Raiding, users[0].Id) + ); } await Task.Delay(1000 * stats.AntiRaidSettings.Seconds); @@ -327,39 +274,36 @@ public class ProtectionService : IEService _antiRaidGuilds.AddOrUpdate(guildId, stats, (_, _) => stats); await using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiRaidSetting)); - gc.AntiRaidSetting = stats.AntiRaidSettings; - await uow.SaveChangesAsync(); + // todo finish this return stats; } - public bool TryStopAntiRaid(ulong guildId) + public async Task<bool> TryStopAntiRaidAsync(ulong guildId) { if (_antiRaidGuilds.TryRemove(guildId, out _)) { using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiRaidSetting)); + await uow.GetTable<AntiRaidSetting>() + .Where(x => x.GuildId == guildId) + .DeleteAsync(); - gc.AntiRaidSetting = null; - uow.SaveChanges(); return true; } return false; } - public bool TryStopAntiSpam(ulong guildId) + public async Task<bool> TryStopAntiSpamAsync(ulong guildId) { if (_antiSpamGuilds.TryRemove(guildId, out _)) { using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, - set => set.Include(x => x.AntiSpamSetting).ThenInclude(x => x.IgnoredChannels)); + await uow.GetTable<AntiSpamSetting>() + .Where(x => x.GuildId == guildId) + .DeleteAsync(); - gc.AntiSpamSetting = null; - uow.SaveChanges(); return true; } @@ -399,19 +343,26 @@ public class ProtectionService : IEService }); await using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiSpamSetting)); + await uow.GetTable<AntiSpamSetting>() + .InsertOrUpdateAsync(() => new() + { + GuildId = guildId, + Action = stats.AntiSpamSettings.Action, + MessageThreshold = stats.AntiSpamSettings.MessageThreshold, + MuteTime = stats.AntiSpamSettings.MuteTime, + RoleId = stats.AntiSpamSettings.RoleId + }, (old) => new() + { + GuildId = guildId, + Action = stats.AntiSpamSettings.Action, + MessageThreshold = stats.AntiSpamSettings.MessageThreshold, + MuteTime = stats.AntiSpamSettings.MuteTime, + RoleId = stats.AntiSpamSettings.RoleId + }, () => new() + { + GuildId = guildId + }); - if (gc.AntiSpamSetting is not null) - { - gc.AntiSpamSetting.Action = stats.AntiSpamSettings.Action; - gc.AntiSpamSetting.MessageThreshold = stats.AntiSpamSettings.MessageThreshold; - gc.AntiSpamSetting.MuteTime = stats.AntiSpamSettings.MuteTime; - gc.AntiSpamSetting.RoleId = stats.AntiSpamSettings.RoleId; - } - else - gc.AntiSpamSetting = stats.AntiSpamSettings; - - await uow.SaveChangesAsync(); return stats; } @@ -421,15 +372,16 @@ public class ProtectionService : IEService { ChannelId = channelId }; - bool added; await using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, - set => set.Include(x => x.AntiSpamSetting).ThenInclude(x => x.IgnoredChannels)); - var spam = gc.AntiSpamSetting; + var spam = await uow.GetTable<AntiSpamSetting>() + .Include(x => x.IgnoredChannels) + .Where(x => x.GuildId == guildId) + .FirstOrDefaultAsyncEF(); if (spam is null) return null; - if (spam.IgnoredChannels.Add(obj)) // if adding to db is successful + var added = false; + if (!spam.IgnoredChannels.Any(x => x.ChannelId == channelId)) { if (_antiSpamGuilds.TryGetValue(guildId, out var temp)) temp.AntiSpamSettings.IgnoredChannels.Add(obj); // add to local cache @@ -439,7 +391,9 @@ public class ProtectionService : IEService else { var toRemove = spam.IgnoredChannels.First(x => x.ChannelId == channelId); - uow.Set<AntiSpamIgnore>().Remove(toRemove); // remove from db + + uow.Set<AntiSpamIgnore>().Remove(toRemove); + if (_antiSpamGuilds.TryGetValue(guildId, out var temp)) temp.AntiSpamSettings.IgnoredChannels.Remove(toRemove); // remove from local cache @@ -483,28 +437,83 @@ public class ProtectionService : IEService ulong? roleId = null) { await using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiAltSetting)); - gc.AntiAltSetting = new() + + await uow.GetTable<AntiAltSetting>() + .InsertOrUpdateAsync(() => new() + { + GuildId = guildId, + Action = action, + ActionDurationMinutes = actionDurationMinutes, + MinAge = TimeSpan.FromMinutes(minAgeMinutes), + RoleId = roleId + }, _ => new() + { + Action = action, + ActionDurationMinutes = actionDurationMinutes, + MinAge = TimeSpan.FromMinutes(minAgeMinutes), + RoleId = roleId + }, () => new() + { + GuildId = guildId + }); + + _antiAltGuilds[guildId] = new(new() { + GuildId = guildId, Action = action, ActionDurationMinutes = actionDurationMinutes, MinAge = TimeSpan.FromMinutes(minAgeMinutes), RoleId = roleId - }; - - await uow.SaveChangesAsync(); - _antiAltGuilds[guildId] = new(gc.AntiAltSetting); + }); } - public async Task<bool> TryStopAntiAlt(ulong guildId) + public async Task<bool> TryStopAntiAltAsync(ulong guildId) { if (!_antiAltGuilds.TryRemove(guildId, out _)) return false; await using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.AntiAltSetting)); - gc.AntiAltSetting = null; - await uow.SaveChangesAsync(); + await uow.GetTable<AntiAltSetting>() + .Where(x => x.GuildId == guildId) + .DeleteAsync(); return true; } + + public async Task OnReadyAsync() + { + await using var uow = _db.GetDbContext(); + + var configs = await uow.GetTable<AntiAltSetting>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB(); + + foreach (var config in configs) + _antiAltGuilds[config.GuildId] = new(config); + + var raidConfigs = await uow.GetTable<AntiRaidSetting>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB(); + + foreach (var config in raidConfigs) + { + _antiRaidGuilds[config.GuildId] = new() + { + AntiRaidSettings = config, + }; + } + + var spamConfigs = await uow.GetTable<AntiSpamSetting>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB(); + + foreach (var config in spamConfigs) + { + _antiSpamGuilds[config.GuildId] = new() + { + AntiSpamSettings = config, + }; + } + + await RunQueue(); + } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Administration/Role/ReactionRolesService.cs b/src/EllieBot/Modules/Administration/Role/ReactionRolesService.cs index 87d4568..389b2bc 100644 --- a/src/EllieBot/Modules/Administration/Role/ReactionRolesService.cs +++ b/src/EllieBot/Modules/Administration/Role/ReactionRolesService.cs @@ -33,7 +33,7 @@ public sealed class ReactionRolesService : IReadyExecutor, IEService, IReactionR await using var uow = _db.GetDbContext(); var reros = await uow.GetTable<ReactionRoleV2>() .Where( - x => Linq2DbExpressions.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) + x => Queries.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) .ToListAsyncLinqToDB(); foreach (var group in reros.GroupBy(x => x.MessageId)) diff --git a/src/EllieBot/Modules/Administration/Role/RoleCommands.cs b/src/EllieBot/Modules/Administration/Role/RoleCommands.cs index 32d5692..b6b0eb0 100644 --- a/src/EllieBot/Modules/Administration/Role/RoleCommands.cs +++ b/src/EllieBot/Modules/Administration/Role/RoleCommands.cs @@ -221,7 +221,7 @@ public partial class Administration [RequireContext(ContextType.Guild)] [UserPerm(GuildPerm.Administrator)] [BotPerm(GuildPerm.ManageRoles)] - public async Task TempRole(ParsedTimespan timespan, IUser user, [Leftover] IRole role) + public async Task TempRole(ParsedTimespan timespan, IGuildUser user, [Leftover] IRole role) { if (!await CheckRoleHierarchy(role)) { @@ -231,6 +231,7 @@ public partial class Administration return; } + await user.AddRoleAsync(role); await _tempRoleService.AddTempRoleAsync(ctx.Guild.Id, role.Id, user.Id, timespan.Time); diff --git a/src/EllieBot/Modules/Administration/Role/StickyRolesService.cs b/src/EllieBot/Modules/Administration/Role/StickyRolesService.cs index 5147daf..ff01c91 100644 --- a/src/EllieBot/Modules/Administration/Role/StickyRolesService.cs +++ b/src/EllieBot/Modules/Administration/Role/StickyRolesService.cs @@ -31,7 +31,7 @@ public sealed class StickyRolesService : IEService, IReadyExecutor _stickyRoles = (await ctx .Set<GuildConfig>() .ToLinqToDBTable() - .Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId, + .Where(x => Queries.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) .Where(x => x.StickyRoles) diff --git a/src/EllieBot/Modules/Administration/Role/TempRoleService.cs b/src/EllieBot/Modules/Administration/Role/TempRoleService.cs index aee948a..9adfe9b 100644 --- a/src/EllieBot/Modules/Administration/Role/TempRoleService.cs +++ b/src/EllieBot/Modules/Administration/Role/TempRoleService.cs @@ -72,7 +72,7 @@ public class TempRoleService : IReadyExecutor, IEService _tcs = new(TaskCreationOptions.RunContinuationsAsynchronously); var latest = await _db.GetDbContext() .GetTable<TempRole>() - .Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId, + .Where(x => Queries.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) .OrderBy(x => x.ExpiresAt) @@ -93,7 +93,7 @@ public class TempRoleService : IReadyExecutor, IEService var deleted = await _db.GetDbContext() .GetTable<TempRole>() - .Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId, + .Where(x => Queries.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId) && x.ExpiresAt <= now) diff --git a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs index db6153b..73b93aa 100644 --- a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs +++ b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs @@ -216,7 +216,8 @@ public class SelfAssignedRolesService : IEService, IReadyExecutor { await using var uow = _db.GetDbContext(); var guilds = await uow.GetTable<SarAutoDelete>() - .Where(x => x.IsEnabled && Linq2DbExpressions.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) + .Where(x => x.IsEnabled + && Queries.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) .Select(x => x.GuildId) .ToListAsyncLinqToDB(); @@ -309,7 +310,6 @@ public sealed class SarAssignerService : IEService, IReadyExecutor { await _channel.Writer.WriteAsync(item); } - } public sealed class SarAssignerDataItem diff --git a/src/EllieBot/Modules/Administration/Timezone/GuildTimezoneService.cs b/src/EllieBot/Modules/Administration/Timezone/GuildTimezoneService.cs index f36d7af..9776c07 100644 --- a/src/EllieBot/Modules/Administration/Timezone/GuildTimezoneService.cs +++ b/src/EllieBot/Modules/Administration/Timezone/GuildTimezoneService.cs @@ -1,4 +1,5 @@ #nullable disable +using LinqToDB.EntityFrameworkCore; using EllieBot.Db.Models; using EllieBot.Common.ModuleBehaviors; @@ -6,40 +7,30 @@ namespace EllieBot.Modules.Administration.Services; public sealed class GuildTimezoneService : ITimezoneService, IReadyExecutor, IEService { - private readonly ConcurrentDictionary<ulong, TimeZoneInfo> _timezones; + private ConcurrentDictionary<ulong, TimeZoneInfo> _timezones; private readonly DbService _db; private readonly IReplacementPatternStore _repStore; + private readonly ShardData _shardData; + private readonly DiscordSocketClient _client; - public GuildTimezoneService(IBot bot, DbService db, IReplacementPatternStore repStore) + public GuildTimezoneService( + DbService db, + IReplacementPatternStore repStore, + ShardData shardData, + DiscordSocketClient client) { - _timezones = bot.AllGuildConfigs.Select(GetTimzezoneTuple) - .Where(x => x.Timezone is not null) - .ToDictionary(x => x.GuildId, x => x.Timezone) - .ToConcurrent(); - _db = db; _repStore = repStore; - - bot.JoinedGuild += Bot_JoinedGuild; + _shardData = shardData; + _client = client; } - private Task Bot_JoinedGuild(GuildConfig arg) - { - var (guildId, tz) = GetTimzezoneTuple(arg); - if (tz is not null) - _timezones.TryAdd(guildId, tz); - return Task.CompletedTask; - } - - private static (ulong GuildId, TimeZoneInfo Timezone) GetTimzezoneTuple(GuildConfig x) + private static (ulong GuildId, TimeZoneInfo Timezone) GetTimezoneTuple(GuildConfig x) { TimeZoneInfo tz; try { - if (x.TimeZoneId is null) - tz = null; - else - tz = TimeZoneInfo.FindSystemTimeZoneById(x.TimeZoneId); + tz = x.TimeZoneId is null ? null : TimeZoneInfo.FindSystemTimeZoneById(x.TimeZoneId); } catch { @@ -74,9 +65,18 @@ public sealed class GuildTimezoneService : ITimezoneService, IReadyExecutor, IES public TimeZoneInfo GetTimeZoneOrUtc(ulong? guildId) => GetTimeZoneOrDefault(guildId) ?? TimeZoneInfo.Utc; - public Task OnReadyAsync() + public async Task OnReadyAsync() { - _repStore.Register("%server.time%", + await using var uow = _db.GetDbContext(); + _timezones = await uow.GetTable<GuildConfig>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB() + .Fmap(x => x + .Select(GetTimezoneTuple) + .ToDictionary(x => x.GuildId, x => x.Timezone) + .ToConcurrent()); + + await _repStore.Register("%server.time%", (IGuild g) => { var to = TimeZoneInfo.Local; @@ -88,7 +88,5 @@ public sealed class GuildTimezoneService : ITimezoneService, IReadyExecutor, IES return TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.Utc, to).ToString("HH:mm ") + to.StandardName.GetInitials(); }); - - return Task.CompletedTask; } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs b/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs index 7b31658..5ed1bc2 100644 --- a/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs +++ b/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs @@ -16,6 +16,7 @@ public class UserPunishService : IEService, IReadyExecutor private readonly BotConfigService _bcs; private readonly DiscordSocketClient _client; private readonly IReplacementService _repSvc; + private readonly TempRoleService _tempRoleService; public event Func<Warning, Task> OnUserWarned = static delegate { return Task.CompletedTask; }; @@ -25,7 +26,8 @@ public class UserPunishService : IEService, IReadyExecutor BlacklistService blacklistService, BotConfigService bcs, DiscordSocketClient client, - IReplacementService repSvc) + IReplacementService repSvc, + TempRoleService tempRoleService) { _mute = mute; _db = db; @@ -33,6 +35,7 @@ public class UserPunishService : IEService, IReadyExecutor _bcs = bcs; _client = client; _repSvc = repSvc; + _tempRoleService = tempRoleService; } public async Task OnReadyAsync() @@ -188,10 +191,14 @@ public class UserPunishService : IEService, IReadyExecutor var role = guild.GetRole(roleId.Value); if (role is not null) { - if (minutes == 0) - await user.AddRoleAsync(role); - else - await _mute.TimedRole(user, TimeSpan.FromMinutes(minutes), reason, role); + await user.AddRoleAsync(role); + if (minutes != 0) + { + await _tempRoleService.AddTempRoleAsync(guild.Id, + role.Id, + user.Id, + TimeSpan.FromMinutes(minutes)); + } } else { @@ -233,7 +240,7 @@ public class UserPunishService : IEService, IReadyExecutor case PunishmentAction.RemoveRoles: return botUser.GuildPermissions.ManageRoles; case PunishmentAction.ChatMute: - return botUser.GuildPermissions.ManageRoles; // adds ellie-mute role + return botUser.GuildPermissions.ManageRoles; // adds nadeko-mute role case PunishmentAction.VoiceMute: return botUser.GuildPermissions.MuteMembers; case PunishmentAction.AddRole: diff --git a/src/EllieBot/Modules/Administration/VcRole/VcRoleService.cs b/src/EllieBot/Modules/Administration/VcRole/VcRoleService.cs index 0ba9feb..400b114 100644 --- a/src/EllieBot/Modules/Administration/VcRole/VcRoleService.cs +++ b/src/EllieBot/Modules/Administration/VcRole/VcRoleService.cs @@ -1,109 +1,95 @@ #nullable disable +using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; +using EllieBot.Common.ModuleBehaviors; using EllieBot.Db.Models; namespace EllieBot.Modules.Administration.Services; -public class VcRoleService : IEService +public class VcRoleService : IEService, IReadyExecutor { public ConcurrentDictionary<ulong, ConcurrentDictionary<ulong, IRole>> VcRoles { get; } public ConcurrentDictionary<ulong, System.Collections.Concurrent.ConcurrentQueue<(bool, IGuildUser, IRole)>> ToAssign { get; } private readonly DbService _db; private readonly DiscordSocketClient _client; + private readonly IBot _bot; + private readonly ShardData _shardData; - public VcRoleService(DiscordSocketClient client, IBot bot, DbService db) + public VcRoleService(DiscordSocketClient client, IBot bot, DbService db, ShardData shardData) { _db = db; _client = client; + _bot = bot; + _shardData = shardData; - _client.UserVoiceStateUpdated += ClientOnUserVoiceStateUpdated; VcRoles = new(); ToAssign = new(); - - using (var uow = db.GetDbContext()) - { - var guildIds = client.Guilds.Select(x => x.Id).ToList(); - uow.Set<GuildConfig>() - .AsQueryable() - .Include(x => x.VcRoleInfos) - .Where(x => guildIds.Contains(x.GuildId)) - .AsEnumerable() - .Select(InitializeVcRole) - .WhenAll(); - } - - Task.Run(async () => - { - while (true) - { - Task Selector(System.Collections.Concurrent.ConcurrentQueue<(bool, IGuildUser, IRole)> queue) - { - return Task.Run(async () => - { - while (queue.TryDequeue(out var item)) - { - var (add, user, role) = item; - - try - { - if (add) - { - if (!user.RoleIds.Contains(role.Id)) - await user.AddRoleAsync(role); - } - else - { - if (user.RoleIds.Contains(role.Id)) - await user.RemoveRoleAsync(role); - } - } - catch - { - } - - await Task.Delay(250); - } - }); - } - - await ToAssign.Values.Select(Selector).Append(Task.Delay(1000)).WhenAll(); - } - }); - - _client.LeftGuild += _client_LeftGuild; - bot.JoinedGuild += Bot_JoinedGuild; } - private Task Bot_JoinedGuild(GuildConfig arg) + public async Task OnReadyAsync() { - // includeall no longer loads vcrole - // need to load new guildconfig with vc role included + IEnumerable<IGrouping<ulong, VcRoleInfo>> vcRoles; using (var uow = _db.GetDbContext()) { - var configWithVcRole = uow.GuildConfigsForId(arg.GuildId, set => set.Include(x => x.VcRoleInfos)); - _ = InitializeVcRole(configWithVcRole); + vcRoles = await uow.GetTable<VcRoleInfo>() + .AsQueryable() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsync() + .Fmap(x => x.GroupBy(x => x.GuildId)); } - return Task.CompletedTask; + await vcRoles.Select(x => InitializeVcRole(x.Key, x.ToList())).WhenAll(); + + + _client.UserVoiceStateUpdated += ClientOnUserVoiceStateUpdated; + + while (true) + { + Task Selector(System.Collections.Concurrent.ConcurrentQueue<(bool, IGuildUser, IRole)> queue) + { + return Task.Run(async () => + { + while (queue.TryDequeue(out var item)) + { + var (add, user, role) = item; + + try + { + if (add) + { + if (!user.RoleIds.Contains(role.Id)) + await user.AddRoleAsync(role); + } + else + { + if (user.RoleIds.Contains(role.Id)) + await user.RemoveRoleAsync(role); + } + } + catch + { + } + + await Task.Delay(250); + } + }); + } + + await ToAssign.Values.Select(Selector).Append(Task.Delay(1000)).WhenAll(); + } } - private Task _client_LeftGuild(SocketGuild arg) + private async Task InitializeVcRole(ulong guildId, IReadOnlyList<VcRoleInfo> confs) { - VcRoles.TryRemove(arg.Id, out _); - ToAssign.TryRemove(arg.Id, out _); - return Task.CompletedTask; - } - - private async Task InitializeVcRole(GuildConfig gconf) - { - var g = _client.GetGuild(gconf.GuildId); + var g = _client.GetGuild(guildId); if (g is null) return; var infos = new ConcurrentDictionary<ulong, IRole>(); var missingRoles = new List<VcRoleInfo>(); - VcRoles.AddOrUpdate(gconf.GuildId, infos, delegate { return infos; }); - foreach (var ri in gconf.VcRoleInfos) + VcRoles.AddOrUpdate(guildId, infos, delegate + { return infos; }); + foreach (var ri in confs) { var role = g.GetRole(ri.RoleId); if (role is null) @@ -120,7 +106,7 @@ public class VcRoleService : IEService await using var uow = _db.GetDbContext(); uow.RemoveRange(missingRoles); await uow.SaveChangesAsync(); - + Log.Warning("Removed {MissingRoleCount} missing roles from {ServiceName}", missingRoles.Count, nameof(VcRoleService)); @@ -135,11 +121,11 @@ public class VcRoleService : IEService guildVcRoles.AddOrUpdate(vcId, role, (_, _) => role); using var uow = _db.GetDbContext(); - var conf = uow.GuildConfigsForId(guildId, set => set.Include(x => x.VcRoleInfos)); - var toDelete = conf.VcRoleInfos.FirstOrDefault(x => x.VoiceChannelId == vcId); // remove old one + var toDelete = uow.Set<VcRoleInfo>() + .FirstOrDefault(x => x.VoiceChannelId == vcId); // remove old one if (toDelete is not null) uow.Remove(toDelete); - conf.VcRoleInfos.Add(new() + uow.Set<VcRoleInfo>().Add(new() { VoiceChannelId = vcId, RoleId = role.Id @@ -156,8 +142,7 @@ public class VcRoleService : IEService return false; using var uow = _db.GetDbContext(); - var conf = uow.GuildConfigsForId(guildId, set => set.Include(x => x.VcRoleInfos)); - var toRemove = conf.VcRoleInfos.Where(x => x.VoiceChannelId == vcId).ToList(); + var toRemove = uow.Set<VcRoleInfo>().Where(x => x.VoiceChannelId == vcId).ToList(); uow.RemoveRange(toRemove); uow.SaveChanges(); diff --git a/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs b/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs index 5e3561d..96d97e6 100644 --- a/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs +++ b/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs @@ -77,6 +77,7 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor private bool ready; private ConcurrentHashSet<ulong> _disabledGlobalExpressionGuilds; private readonly PermissionService _pc; + private readonly ShardData _shardData; public EllieExpressionsService( DbService db, @@ -87,7 +88,8 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor IMessageSenderService sender, IReplacementService repSvc, IPermissionChecker permChecker, - PermissionService pc) + PermissionService pc, + ShardData shardData) { _db = db; _client = client; @@ -98,6 +100,7 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor _repSvc = repSvc; _permChecker = permChecker; _pc = pc; + _shardData = shardData; _rng = new EllieRandom(); _pubSub.Sub(_exprsReloadedKey, OnExprsShouldReload); @@ -105,26 +108,28 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor pubSub.Sub(_gexprDeletedkey, OnGexprDeleted); pubSub.Sub(_gexprEditedKey, OnGexprEdited); - bot.JoinedGuild += OnJoinedGuild; - _client.LeftGuild += OnLeftGuild; + _client.JoinedGuild += OnJoinedGuild; } - private async Task ReloadInternal(IReadOnlyList<ulong> allGuildIds) + private async Task ReloadInternal() { await using var uow = _db.GetDbContext(); - var guildItems = await uow.Set<EllieExpression>() + var guildItems = await uow.GetTable<EllieExpression>() .AsNoTracking() - .Where(x => allGuildIds.Contains(x.GuildId.Value)) - .ToListAsync(); + .Where(x => x.GuildId != null + && Queries.GuildOnShard(x.GuildId.Value, + _shardData.TotalShards, + _shardData.ShardId)) + .ToListAsyncLinqToDB(); newguildExpressions = guildItems.GroupBy(k => k.GuildId!.Value) .ToDictionary(g => g.Key, g => g.Select(x => - { - x.Trigger = x.Trigger.Replace(MENTION_PH, - _client.CurrentUser.Mention); - return x; - }) + { + x.Trigger = x.Trigger.Replace(MENTION_PH, + _client.CurrentUser.Mention); + return x; + }) .ToArray()) .ToConcurrent(); @@ -635,10 +640,12 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor #region Event Handlers public async Task OnReadyAsync() - => await OnExprsShouldReload(true); + { + await OnExprsShouldReload(true); + } private ValueTask OnExprsShouldReload(bool _) - => new(ReloadInternal(_bot.GetCurrentGuildIds())); + => new(ReloadInternal()); private ValueTask OnGexprAdded(EllieExpression c) { @@ -692,21 +699,13 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor #region Client Event Handlers - private Task OnLeftGuild(SocketGuild arg) + private Task OnJoinedGuild(SocketGuild g) { - newguildExpressions.TryRemove(arg.Id, out _); + newguildExpressions[g.Id] = []; return Task.CompletedTask; } - private async Task OnJoinedGuild(GuildConfig gc) - { - await using var uow = _db.GetDbContext(); - var exprs = await uow.Set<EllieExpression>().AsNoTracking().Where(x => x.GuildId == gc.GuildId).ToArrayAsync(); - - newguildExpressions[gc.GuildId] = exprs; - } - #endregion #region Basic Operations diff --git a/src/EllieBot/Modules/Gambling/PlantPick/PlantAndPickCommands.cs b/src/EllieBot/Modules/Gambling/PlantPick/PlantAndPickCommands.cs index 909de44..cfed9b2 100644 --- a/src/EllieBot/Modules/Gambling/PlantPick/PlantAndPickCommands.cs +++ b/src/EllieBot/Modules/Gambling/PlantPick/PlantAndPickCommands.cs @@ -77,7 +77,7 @@ public partial class Gambling #endif public async Task GenCurrency() { - var enabled = _service.ToggleCurrencyGeneration(ctx.Guild.Id, ctx.Channel.Id); + var enabled = await _service.ToggleCurrencyGeneration(ctx.Guild.Id, ctx.Channel.Id); if (enabled) await Response().Confirm(strs.curgen_enabled).SendAsync(); else @@ -88,14 +88,14 @@ public partial class Gambling [RequireContext(ContextType.Guild)] [UserPerm(GuildPerm.ManageMessages)] [OwnerOnly] - public Task GenCurList(int page = 1) + public async Task GenCurList(int page = 1) { if (--page < 0) - return Task.CompletedTask; + return; - var enabledIn = _service.GetAllGeneratingChannels(); + var enabledIn = await _service.GetAllGeneratingChannels(); - return Response() + await Response() .Paginated() .Items(enabledIn.ToList()) .PageSize(9) diff --git a/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs b/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs index 27c59d8..08e4587 100644 --- a/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs +++ b/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs @@ -15,7 +15,7 @@ using Image = SixLabors.ImageSharp.Image; namespace EllieBot.Modules.Gambling.Services; -public class PlantPickService : IEService, IExecNoCommand +public class PlantPickService : IEService, IExecNoCommand, IReadyExecutor { //channelId/last generation public ConcurrentDictionary<ulong, long> LastGenerations { get; } = new(); @@ -30,7 +30,7 @@ public class PlantPickService : IEService, IExecNoCommand private readonly GamblingConfigService _gss; private readonly GamblingService _gs; - private readonly ConcurrentHashSet<ulong> _generationChannels; + private ConcurrentHashSet<ulong> _generationChannels; private readonly SemaphoreSlim _pickLock = new(1, 1); public PlantPickService( @@ -57,13 +57,6 @@ public class PlantPickService : IEService, IExecNoCommand using var uow = db.GetDbContext(); var guildIds = client.Guilds.Select(x => x.Id).ToList(); - var configs = uow.Set<GuildConfig>() - .AsQueryable() - .Include(x => x.GenerateCurrencyChannelIds) - .Where(x => guildIds.Contains(x.GuildId)) - .ToList(); - - _generationChannels = new(configs.SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj => obj.ChannelId))); } public Task ExecOnNoCommandAsync(IGuild guild, IUserMessage msg) @@ -72,41 +65,49 @@ public class PlantPickService : IEService, IExecNoCommand private string GetText(ulong gid, LocStr str) => _strings.GetText(str, gid); - public bool ToggleCurrencyGeneration(ulong gid, ulong cid) + public async Task<bool> ToggleCurrencyGeneration(ulong gid, ulong cid) { bool enabled; - using var uow = _db.GetDbContext(); - var guildConfig = uow.GuildConfigsForId(gid, set => set.Include(gc => gc.GenerateCurrencyChannelIds)); + await using var uow = _db.GetDbContext(); - var toAdd = new GCChannelId + if (_generationChannels.Add(cid)) { - ChannelId = cid - }; - if (!guildConfig.GenerateCurrencyChannelIds.Contains(toAdd)) - { - guildConfig.GenerateCurrencyChannelIds.Add(toAdd); + await uow.GetTable<GCChannelId>() + .InsertOrUpdateAsync(() => new() + { + ChannelId = cid, + GuildId = gid + }, (x) => new() + { + ChannelId = cid, + GuildId = gid + }, () => new() + { + ChannelId = cid, + GuildId = gid + }); + _generationChannels.Add(cid); enabled = true; } else { - var toDelete = guildConfig.GenerateCurrencyChannelIds.FirstOrDefault(x => x.Equals(toAdd)); - if (toDelete is not null) - uow.Remove(toDelete); + await uow.GetTable<GCChannelId>() + .Where(x => x.ChannelId == cid && x.GuildId == gid) + .DeleteAsync(); _generationChannels.TryRemove(cid); enabled = false; } - uow.SaveChanges(); return enabled; } - public IEnumerable<GuildConfigExtensions.GeneratingChannel> GetAllGeneratingChannels() + public async Task<IReadOnlyCollection<GCChannelId>> GetAllGeneratingChannels() { - using var uow = _db.GetDbContext(); - var chs = uow.Set<GuildConfig>().GetGeneratingChannels(); - return chs; + await using var uow = _db.GetDbContext(); + return await uow.GetTable<GCChannelId>() + .ToListAsyncLinqToDB(); } /// <summary> @@ -412,4 +413,16 @@ public class PlantPickService : IEService, IExecNoCommand return (totalDeletedAmount + amount, deleted.Select(x => x.MessageId).ToArray()); } + + public async Task OnReadyAsync() + { + + await using var uow = _db.GetDbContext(); + _generationChannels = (await uow.GetTable<GCChannelId>() + .Select(x => x.ChannelId) + .ToListAsyncLinqToDB()) + .ToHashSet() + .ToConcurrentSet(); + + } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Gambling/Shop/ShopCommands.cs b/src/EllieBot/Modules/Gambling/Shop/ShopCommands.cs index 4935658..8d028d5 100644 --- a/src/EllieBot/Modules/Gambling/Shop/ShopCommands.cs +++ b/src/EllieBot/Modules/Gambling/Shop/ShopCommands.cs @@ -4,6 +4,7 @@ using EllieBot.Modules.Gambling.Common; using EllieBot.Modules.Gambling.Services; using EllieBot.Db.Models; using EllieBot.Modules.Administration; +using LinqToDB.EntityFrameworkCore; namespace EllieBot.Modules.Gambling; @@ -30,25 +31,28 @@ public partial class Gambling private readonly DbService _db; private readonly ICurrencyService _cs; + private readonly EllieRandom _rng; public ShopCommands(DbService db, ICurrencyService cs, GamblingConfigService gamblingConf) : base(gamblingConf) { _db = db; _cs = cs; + _rng = new EllieRandom(); } - private Task ShopInternalAsync(int page = 0) + private async Task ShopInternalAsync(int page = 0) { if (page < 0) throw new ArgumentOutOfRangeException(nameof(page)); - using var uow = _db.GetDbContext(); - var entries = uow.GuildConfigsForId(ctx.Guild.Id, - set => set.Include(x => x.ShopEntries).ThenInclude(x => x.Items)) - .ShopEntries.ToIndexed(); + await using var uow = _db.GetDbContext(); + var entries = await uow.Set<ShopEntry>() + .Where(x => x.GuildId == ctx.Guild.Id) + .Include(x => x.Items) + .ToListAsyncEF(); - return Response() + await Response() .Paginated() .Items(entries.ToList()) .PageSize(9) @@ -92,13 +96,15 @@ public partial class Gambling ShopEntry entry; await using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigsForId(ctx.Guild.Id, - set => set.Include(x => x.ShopEntries).ThenInclude(x => x.Items)); - var entries = new IndexedCollection<ShopEntry>(config.ShopEntries); - entry = entries.ElementAtOrDefault(index); - uow.SaveChanges(); + entry = await uow.Set<ShopEntry>() + .Where(x => x.GuildId == ctx.Guild.Id) + .Include(x => x.Items) + .OrderBy(x => x.Id) + .Skip(index) + .FirstOrDefaultAsync(); } + if (entry is null) { await Response().Error(strs.shop_item_not_found).SendAsync(); @@ -174,7 +180,7 @@ public partial class Gambling return; } - var item = entry.Items.ToArray()[new EllieRandom().Next(0, entry.Items.Count)]; + var item = entry.Items.ToArray()[_rng.Next(0, entry.Items.Count)]; if (await _cs.RemoveAsync(ctx.User.Id, entry.Price, new("shop", "buy", entry.Type.ToString()))) { @@ -205,15 +211,15 @@ public partial class Gambling await _cs.AddAsync(ctx.User.Id, entry.Price, new("shop", "error-refund", entry.Name)); await using (var uow = _db.GetDbContext()) { - var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id, - set => set.Include(x => x.ShopEntries) - .ThenInclude(x => x.Items)) - .ShopEntries); + var entries = new IndexedCollection<ShopEntry>(await uow.Set<ShopEntry>() + .Where(x => x.GuildId == ctx.Guild.Id) + .Include(x => x.Items) + .ToListAsyncEF()); entry = entries.ElementAtOrDefault(index); if (entry is not null) { if (entry.Items.Add(item)) - uow.SaveChanges(); + await uow.SaveChangesAsync(); } } @@ -224,7 +230,9 @@ public partial class Gambling await Response().Confirm(strs.shop_item_purchase).SendAsync(); } else + { await Response().Error(strs.not_enough(CurrencySign)).SendAsync(); + } } else if (entry.Type == ShopEntryType.Command) { @@ -253,7 +261,7 @@ public partial class Gambling .Replace("%you.username%", buyer.Username) .Replace("%you.name%", buyer.GlobalName ?? buyer.Username) .Replace("%you.nick%", buyer.DisplayName); - + var eb = CreateEmbed() .WithPendingColor() .WithTitle("Executing shop command") @@ -328,15 +336,14 @@ public partial class Gambling }; await using (var uow = _db.GetDbContext()) { - var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id, - set => set.Include(x => x.ShopEntries) - .ThenInclude(x => x.Items)) - .ShopEntries) + var entries = new IndexedCollection<ShopEntry>(await uow.Set<ShopEntry>() + .Where(x => x.GuildId == ctx.Guild.Id) + .Include(x => x.Items) + .ToListAsyncEF()) { entry }; - uow.GuildConfigsForId(ctx.Guild.Id, set => set).ShopEntries = entries; - uow.SaveChanges(); + await uow.SaveChangesAsync(); } await Response().Embed(EntryToEmbed(entry).WithTitle(GetText(strs.shop_item_add))).SendAsync(); @@ -360,15 +367,16 @@ public partial class Gambling }; await using (var uow = _db.GetDbContext()) { - var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id, - set => set.Include(x => x.ShopEntries) - .ThenInclude(x => x.Items)) - .ShopEntries) - { - entry - }; - uow.GuildConfigsForId(ctx.Guild.Id, set => set).ShopEntries = entries; - uow.SaveChanges(); + var entries = await uow.Set<ShopEntry>() + .Where(x => x.GuildId == ctx.Guild.Id) + .ToListAsyncEF(); + + var indexed = new IndexedCollection<ShopEntry>(entries); + indexed.Add(entry); + + uow.Add(entry); + await uow.SaveChangesAsync(); + } await Response().Embed(EntryToEmbed(entry).WithTitle(GetText(strs.shop_item_add))).SendAsync(); @@ -391,11 +399,13 @@ public partial class Gambling var added = false; await using (var uow = _db.GetDbContext()) { - var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id, - set => set.Include(x => x.ShopEntries) - .ThenInclude(x => x.Items)) - .ShopEntries); - entry = entries.ElementAtOrDefault(index); + var entries = await uow.Set<ShopEntry>() + .Where(x => x.GuildId == ctx.Guild.Id) + .Include(x => x.Items) + .ToListAsyncEF(); + + var indexed = new IndexedCollection<ShopEntry>(entries); + entry = indexed.ElementAtOrDefault(index); if (entry is not null && (rightType = entry.Type == ShopEntryType.List)) { if (entry.Items.Add(item)) @@ -427,10 +437,12 @@ public partial class Gambling ShopEntry removed; await using (var uow = _db.GetDbContext()) { - var config = uow.GuildConfigsForId(ctx.Guild.Id, - set => set.Include(x => x.ShopEntries).ThenInclude(x => x.Items)); + var items = await uow.Set<ShopEntry>() + .Where(x => x.GuildId == ctx.Guild.Id) + .Include(x => x.Items) + .ToListAsyncLinqToDB(); - var entries = new IndexedCollection<ShopEntry>(config.ShopEntries); + var entries = new IndexedCollection<ShopEntry>(items); removed = entries.ElementAtOrDefault(index); if (removed is not null) { diff --git a/src/EllieBot/Modules/Gambling/Shop/ShopService.cs b/src/EllieBot/Modules/Gambling/Shop/ShopService.cs index 9e46aa0..b936897 100644 --- a/src/EllieBot/Modules/Gambling/Shop/ShopService.cs +++ b/src/EllieBot/Modules/Gambling/Shop/ShopService.cs @@ -1,4 +1,6 @@ #nullable disable +using LinqToDB; +using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using EllieBot.Db.Models; @@ -11,11 +13,14 @@ public class ShopService : IShopService, IEService public ShopService(DbService db) => _db = db; - private IndexedCollection<ShopEntry> GetEntriesInternal(DbContext uow, ulong guildId) - => uow.GuildConfigsForId(guildId, - set => set.Include(x => x.ShopEntries) - .ThenInclude(x => x.Items)) - .ShopEntries.ToIndexed(); + private async Task<IndexedCollection<ShopEntry>> GetEntriesInternal(DbContext uow, ulong guildId) + { + var items = await uow.GetTable<ShopEntry>() + .Where(x => x.GuildId == guildId) + .ToListAsyncLinqToDB(); + + return items.ToIndexed(); + } public async Task<bool> ChangeEntryPriceAsync(ulong guildId, int index, int newPrice) { @@ -23,32 +28,33 @@ public class ShopService : IShopService, IEService ArgumentOutOfRangeException.ThrowIfNegativeOrZero(newPrice); await using var uow = _db.GetDbContext(); - var entries = GetEntriesInternal(uow, guildId); - if (index >= entries.Count) - return false; + var changed = await uow.GetTable<ShopEntry>() + .Where(x => x.GuildId == guildId && x.Index == index) + .UpdateAsync(x => new ShopEntry() + { + Price = newPrice, + }); - entries[index].Price = newPrice; - await uow.SaveChangesAsync(); - return true; + return changed > 0; } public async Task<bool> ChangeEntryNameAsync(ulong guildId, int index, string newName) { ArgumentOutOfRangeException.ThrowIfNegative(index); - + if (string.IsNullOrWhiteSpace(newName)) throw new ArgumentNullException(nameof(newName)); await using var uow = _db.GetDbContext(); - var entries = GetEntriesInternal(uow, guildId); - if (index >= entries.Count) - return false; - - entries[index].Name = newName.TrimTo(100); - await uow.SaveChangesAsync(); - return true; + var changed = await uow.GetTable<ShopEntry>() + .Where(x => x.GuildId == guildId && x.Index == index) + .UpdateAsync(x => new ShopEntry() + { + Name = newName, + }); + return changed > 0; } public async Task<bool> SwapEntriesAsync(ulong guildId, int index1, int index2) @@ -57,7 +63,7 @@ public class ShopService : IShopService, IEService ArgumentOutOfRangeException.ThrowIfNegative(index2); await using var uow = _db.GetDbContext(); - var entries = GetEntriesInternal(uow, guildId); + var entries = await GetEntriesInternal(uow, guildId); if (index1 >= entries.Count || index2 >= entries.Count || index1 == index2) return false; @@ -65,7 +71,14 @@ public class ShopService : IShopService, IEService entries[index1].Index = index2; entries[index2].Index = index1; - await uow.SaveChangesAsync(); + // todo fix swap + await uow.GetTable<ShopEntry>() + .Where(x => x.GuildId == guildId) + .UpdateAsync(x => new ShopEntry() + { + Index = x.Index == index1 ? index2 : x.Index == index2 ? index1 : x.Index, + }); + return true; } @@ -77,49 +90,38 @@ public class ShopService : IShopService, IEService await using var uow = _db.GetDbContext(); var entries = GetEntriesInternal(uow, guildId); - if (fromIndex >= entries.Count || toIndex >= entries.Count || fromIndex == toIndex) - return false; - - var entry = entries[fromIndex]; - entries.RemoveAt(fromIndex); - entries.Insert(toIndex, entry); - - await uow.SaveChangesAsync(); + // todo move return true; } public async Task<bool> SetItemRoleRequirementAsync(ulong guildId, int index, ulong? roleId) { await using var uow = _db.GetDbContext(); - var entries = GetEntriesInternal(uow, guildId); - if (index >= entries.Count) - return false; - - var entry = entries[index]; - - entry.RoleRequirement = roleId; - - await uow.SaveChangesAsync(); - return true; + var changes = await uow.GetTable<ShopEntry>() + .Where(x => x.GuildId == guildId && x.Index == index) + .UpdateAsync(x => new ShopEntry() + { + RoleRequirement = roleId, + }); + return changes > 0; } - public async Task<ShopEntry> AddShopCommandAsync(ulong guildId, ulong userId, int price, string command) + public async Task<ShopEntry> AddShopCommandAsync( + ulong guildId, + ulong userId, + int price, + string command) { await using var uow = _db.GetDbContext(); - - var entries = GetEntriesInternal(uow, guildId); - var entry = new ShopEntry() - { - AuthorId = userId, - Command = command, - Type = ShopEntryType.Command, - Price = price, - }; - entries.Add(entry); - uow.GuildConfigsForId(guildId, set => set).ShopEntries = entries; - - await uow.SaveChangesAsync(); + var entry = await uow.GetTable<ShopEntry>() + .InsertWithOutputAsync(() => new() + { + AuthorId = userId, + Command = command, + Type = ShopEntryType.Command, + Price = price, + }); return entry; } diff --git a/src/EllieBot/Modules/Games/ChatterBot/ChatterBotService.cs b/src/EllieBot/Modules/Games/ChatterBot/ChatterBotService.cs index 0d2c841..4c444a8 100644 --- a/src/EllieBot/Modules/Games/ChatterBot/ChatterBotService.cs +++ b/src/EllieBot/Modules/Games/ChatterBot/ChatterBotService.cs @@ -1,6 +1,7 @@ #nullable disable using LinqToDB; using LinqToDB.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; using EllieBot.Db.Models; using EllieBot.Modules.Games.Common; @@ -10,9 +11,9 @@ using EllieBot.Modules.Permissions; namespace EllieBot.Modules.Games.Services; -public class ChatterBotService : IExecOnMessage +public class ChatterBotService : IExecOnMessage, IReadyExecutor { - private ConcurrentDictionary<ulong, Lazy<IChatterBotSession>> ChatterBotGuilds { get; } + private ConcurrentDictionary<ulong, Lazy<IChatterBotSession>> _chatterBotGuilds; public int Priority => 1; @@ -29,7 +30,6 @@ public class ChatterBotService : IExecOnMessage public ChatterBotService( DiscordSocketClient client, IPermissionChecker perms, - IBot bot, IPatronageService ps, IHttpClientFactory factory, IBotCreds creds, @@ -46,11 +46,6 @@ public class ChatterBotService : IExecOnMessage _perms = perms; _gcs = gcs; _ps = ps; - - ChatterBotGuilds = new(bot.AllGuildConfigs - .Where(gc => gc.CleverbotEnabled) - .ToDictionary(gc => gc.GuildId, - _ => new Lazy<IChatterBotSession>(() => CreateSession(), true))); } public IChatterBotSession CreateSession() @@ -86,25 +81,25 @@ public class ChatterBotService : IExecOnMessage public IChatterBotSession GetOrCreateSession(ulong guildId) { - if (ChatterBotGuilds.TryGetValue(guildId, out var lazyChatBot)) + if (_chatterBotGuilds.TryGetValue(guildId, out var lazyChatBot)) return lazyChatBot.Value; lazyChatBot = new(() => CreateSession(), true); - ChatterBotGuilds.TryAdd(guildId, lazyChatBot); + _chatterBotGuilds.TryAdd(guildId, lazyChatBot); return lazyChatBot.Value; } public string PrepareMessage(IUserMessage msg) { - var ellieId = _client.CurrentUser.Id; - var normalMention = $"<@{ellieId}> "; - var nickMention = $"<@!{ellieId}> "; + var nadekoId = _client.CurrentUser.Id; + var normalMention = $"<@{nadekoId}> "; + var nickMention = $"<@!{nadekoId}> "; string message; if (msg.Content.StartsWith(normalMention, StringComparison.InvariantCulture)) message = msg.Content[normalMention.Length..].Trim(); else if (msg.Content.StartsWith(nickMention, StringComparison.InvariantCulture)) message = msg.Content[nickMention.Length..].Trim(); - else if (msg.ReferencedMessage?.Author.Id == ellieId) + else if (msg.ReferencedMessage?.Author.Id == nadekoId) message = msg.Content; else return null; @@ -121,7 +116,7 @@ public class ChatterBotService : IExecOnMessage if (channel is null) return false; - if (!ChatterBotGuilds.TryGetValue(channel.Guild.Id, out var lazyChatBot)) + if (!_chatterBotGuilds.TryGetValue(channel.Guild.Id, out var lazyChatBot)) return false; var chatBot = lazyChatBot.Value; @@ -205,7 +200,7 @@ public class ChatterBotService : IExecOnMessage public async Task<bool> ToggleChatterBotAsync(ulong guildId) { - if (ChatterBotGuilds.TryRemove(guildId, out _)) + if (_chatterBotGuilds.TryRemove(guildId, out _)) { await using var uow = _db.GetDbContext(); await uow.Set<GuildConfig>() @@ -219,7 +214,7 @@ public class ChatterBotService : IExecOnMessage return false; } - ChatterBotGuilds.TryAdd(guildId, new(() => CreateSession(), true)); + _chatterBotGuilds.TryAdd(guildId, new(() => CreateSession(), true)); await using (var uow = _db.GetDbContext()) { @@ -236,4 +231,16 @@ public class ChatterBotService : IExecOnMessage return true; } + + public async Task OnReadyAsync() + { + await using var uow = _db.GetDbContext(); + _chatterBotGuilds = uow.GuildConfigs + .AsNoTracking() + .Where(gc => gc.CleverbotEnabled) + .AsEnumerable() + .ToDictionary(gc => gc.GuildId, + _ => new Lazy<IChatterBotSession>(() => CreateSession(), true)) + .ToConcurrent(); + } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdService.cs b/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdService.cs index 55eb64d..a615729 100644 --- a/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdService.cs +++ b/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdService.cs @@ -1,28 +1,28 @@ -using Microsoft.EntityFrameworkCore; +using LinqToDB; +using LinqToDB.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; +using EllieBot.Db.Models; namespace EllieBot.Modules.Permissions.Services; public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, IEService { private readonly DbService _db; - private readonly ConcurrentDictionary<ulong, ConcurrentDictionary<string, int>> _settings = new(); + private ConcurrentDictionary<ulong, ConcurrentDictionary<string, int>> _settings = new(); private readonly ConcurrentDictionary<(ulong, string), ConcurrentDictionary<ulong, DateTime>> _activeCooldowns = new(); - public int Priority => 0; + public int Priority + => 0; - public CmdCdService(IBot bot, DbService db) + private readonly ShardData _shardData; + + public CmdCdService(DbService db, ShardData shardData) { _db = db; - _settings = bot - .AllGuildConfigs - .ToDictionary(x => x.GuildId, x => x.CommandCooldowns - .DistinctBy(x => x.CommandName.ToLowerInvariant()) - .ToDictionary(c => c.CommandName, c => c.Seconds) - .ToConcurrent()) - .ToConcurrent(); + _shardData = shardData; } public Task<bool> ExecPreCommandAsync(ICommandContext context, string moduleName, CommandInfo command) @@ -32,7 +32,7 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, IEService { if (guild is null) return Task.FromResult(false); - + if (!_settings.TryGetValue(guild.Id, out var cooldownSettings)) return Task.FromResult(false); @@ -66,8 +66,23 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, IEService public async Task OnReadyAsync() { - using var timer = new PeriodicTimer(TimeSpan.FromHours(1)); + await using (var uow = _db.GetDbContext()) + { + _settings = await uow.GetTable<CommandCooldown>() + .Where( + x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB() + .Fmap(cmdcds => cmdcds + .GroupBy(x => x.GuildId) + .ToDictionary(x => x.Key, + x => x + .DistinctBy(x => x.CommandName.ToLower()) + .ToDictionary(y => y.CommandName, y => y.Seconds) + .ToConcurrent()) + .ToConcurrent()); + } + using var timer = new PeriodicTimer(TimeSpan.FromHours(1)); while (await timer.WaitForNextTickAsync()) { // once per hour delete expired entries @@ -81,7 +96,7 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, IEService _activeCooldowns.Remove((guildId, commandName), out _); continue; } - + Cleanup(dict, cdSeconds); } } @@ -96,20 +111,20 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, IEService } } - public void ClearCooldowns(ulong guildId, string cmdName) + public async Task ClearCooldowns(ulong guildId, string cmdName) { if (_settings.TryGetValue(guildId, out var dict)) dict.TryRemove(cmdName, out _); _activeCooldowns.TryRemove((guildId, cmdName), out _); - - using var ctx = _db.GetDbContext(); - var gc = ctx.GuildConfigsForId(guildId, x => x.Include(x => x.CommandCooldowns)); - gc.CommandCooldowns.RemoveWhere(x => x.CommandName == cmdName); - ctx.SaveChanges(); + + await using var ctx = _db.GetDbContext(); + await ctx.GetTable<CommandCooldown>() + .Where(x => x.GuildId == guildId && x.CommandName == cmdName) + .DeleteAsync(); } - public void AddCooldown(ulong guildId, string name, int secs) + public async Task AddCooldown(ulong guildId, string name, int secs) { ArgumentOutOfRangeException.ThrowIfNegativeOrZero(secs); @@ -119,16 +134,24 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, IEService // force cleanup if (_activeCooldowns.TryGetValue((guildId, name), out var dict)) Cleanup(dict, secs); - - using var ctx = _db.GetDbContext(); - var gc = ctx.GuildConfigsForId(guildId, x => x.Include(x => x.CommandCooldowns)); - gc.CommandCooldowns.RemoveWhere(x => x.CommandName == name); - gc.CommandCooldowns.Add(new() - { - Seconds = secs, - CommandName = name - }); - ctx.SaveChanges(); + + await using var ctx = _db.GetDbContext(); + await ctx.GetTable<CommandCooldown>() + .InsertOrUpdateAsync(() => new() + { + GuildId = guildId, + CommandName = name, + Seconds = secs + }, + (old) => new() + { + Seconds = secs + }, + () => new() + { + GuildId = guildId, + CommandName = name, + }); } public IReadOnlyCollection<(string CommandName, int Seconds)> GetCommandCooldowns(ulong guildId) diff --git a/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdsCommands.cs b/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdsCommands.cs index 8d7a414..317333b 100644 --- a/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdsCommands.cs +++ b/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdsCommands.cs @@ -22,7 +22,6 @@ public partial class Permissions private async Task CmdCooldownInternal(string cmdName, int secs) { - var channel = (ITextChannel)ctx.Channel; if (secs is < 0 or > 3600) { await Response().Error(strs.invalid_second_param_between(0, 3600)).SendAsync(); @@ -30,34 +29,17 @@ public partial class Permissions } var name = cmdName.ToLowerInvariant(); - await using (var uow = _db.GetDbContext()) - { - var config = uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.CommandCooldowns)); - - var toDelete = config.CommandCooldowns.FirstOrDefault(cc => cc.CommandName == name); - if (toDelete is not null) - uow.Set<CommandCooldown>().Remove(toDelete); - if (secs != 0) - { - var cc = new CommandCooldown - { - CommandName = name, - Seconds = secs - }; - config.CommandCooldowns.Add(cc); - _service.AddCooldown(channel.Guild.Id, name, secs); - } - - await uow.SaveChangesAsync(); - } + await _service.AddCooldown(ctx.Guild.Id, name, secs); if (secs == 0) { - _service.ClearCooldowns(ctx.Guild.Id, cmdName); + await _service.ClearCooldowns(ctx.Guild.Id, cmdName); await Response().Confirm(strs.cmdcd_cleared(Format.Bold(name))).SendAsync(); } else + { await Response().Confirm(strs.cmdcd_add(Format.Bold(name), Format.Bold(secs.ToString()))).SendAsync(); + } } [Cmd] diff --git a/src/EllieBot/Modules/Permissions/Filter/FilterCommands.cs b/src/EllieBot/Modules/Permissions/Filter/FilterCommands.cs index 87de574..6044195 100644 --- a/src/EllieBot/Modules/Permissions/Filter/FilterCommands.cs +++ b/src/EllieBot/Modules/Permissions/Filter/FilterCommands.cs @@ -20,7 +20,7 @@ public partial class Permissions [UserPerm(GuildPerm.Administrator)] public async Task FwClear() { - _service.ClearFilteredWords(ctx.Guild.Id); + await _service.ClearFilteredWords(ctx.Guild.Id); await Response().Confirm(strs.fw_cleared).SendAsync(); } @@ -71,22 +71,14 @@ public partial class Permissions { var channel = (ITextChannel)ctx.Channel; - bool enabled; - await using (var uow = _db.GetDbContext()) - { - var config = uow.GuildConfigsForId(channel.Guild.Id, set => set); - enabled = config.FilterInvites = !config.FilterInvites; - await uow.SaveChangesAsync(); - } + var enabled = await _service.ToggleServerInviteFilteringAsync(channel.Guild.Id); if (enabled) { - _service.InviteFilteringServers.Add(channel.Guild.Id); await Response().Confirm(strs.invite_filter_server_on).SendAsync(); } else { - _service.InviteFilteringServers.TryRemove(channel.Guild.Id); await Response().Confirm(strs.invite_filter_server_off).SendAsync(); } } @@ -97,32 +89,14 @@ public partial class Permissions { var channel = (ITextChannel)ctx.Channel; - FilterChannelId removed; - await using (var uow = _db.GetDbContext()) - { - var config = uow.GuildConfigsForId(channel.Guild.Id, - set => set.Include(gc => gc.FilterInvitesChannelIds)); - var match = new FilterChannelId - { - ChannelId = channel.Id - }; - removed = config.FilterInvitesChannelIds.FirstOrDefault(fc => fc.Equals(match)); + var enabled = await _service.ToggleChannelInviteFilteringAsync(channel.Guild.Id, channel.Id); - if (removed is null) - config.FilterInvitesChannelIds.Add(match); - else - uow.Remove(removed); - await uow.SaveChangesAsync(); - } - - if (removed is null) + if (enabled) { - _service.InviteFilteringChannels.Add(channel.Id); await Response().Confirm(strs.invite_filter_channel_on).SendAsync(); } else { - _service.InviteFilteringChannels.TryRemove(channel.Id); await Response().Confirm(strs.invite_filter_channel_off).SendAsync(); } } @@ -133,22 +107,14 @@ public partial class Permissions { var channel = (ITextChannel)ctx.Channel; - bool enabled; - await using (var uow = _db.GetDbContext()) - { - var config = uow.GuildConfigsForId(channel.Guild.Id, set => set); - enabled = config.FilterLinks = !config.FilterLinks; - await uow.SaveChangesAsync(); - } + var enabled = await _service.ToggleServerLinkFilteringAsync(channel.Guild.Id); if (enabled) { - _service.LinkFilteringServers.Add(channel.Guild.Id); await Response().Confirm(strs.link_filter_server_on).SendAsync(); } else { - _service.LinkFilteringServers.TryRemove(channel.Guild.Id); await Response().Confirm(strs.link_filter_server_off).SendAsync(); } } @@ -159,32 +125,14 @@ public partial class Permissions { var channel = (ITextChannel)ctx.Channel; - FilterLinksChannelId removed; - await using (var uow = _db.GetDbContext()) - { - var config = - uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterLinksChannelIds)); - var match = new FilterLinksChannelId - { - ChannelId = channel.Id - }; - removed = config.FilterLinksChannelIds.FirstOrDefault(fc => fc.Equals(match)); + var enabled = await _service.ToggleChannelLinkFilteringAsync(channel.Guild.Id, channel.Id); - if (removed is null) - config.FilterLinksChannelIds.Add(match); - else - uow.Remove(removed); - await uow.SaveChangesAsync(); - } - - if (removed is null) + if (enabled) { - _service.LinkFilteringChannels.Add(channel.Id); await Response().Confirm(strs.link_filter_channel_on).SendAsync(); } else { - _service.LinkFilteringChannels.TryRemove(channel.Id); await Response().Confirm(strs.link_filter_channel_off).SendAsync(); } } @@ -195,22 +143,14 @@ public partial class Permissions { var channel = (ITextChannel)ctx.Channel; - bool enabled; - await using (var uow = _db.GetDbContext()) - { - var config = uow.GuildConfigsForId(channel.Guild.Id, set => set); - enabled = config.FilterWords = !config.FilterWords; - await uow.SaveChangesAsync(); - } + var enabled = await _service.ToggleServerWordFilteringAsync(channel.Guild.Id); if (enabled) { - _service.WordFilteringServers.Add(channel.Guild.Id); await Response().Confirm(strs.word_filter_server_on).SendAsync(); } else { - _service.WordFilteringServers.TryRemove(channel.Guild.Id); await Response().Confirm(strs.word_filter_server_off).SendAsync(); } } @@ -221,32 +161,14 @@ public partial class Permissions { var channel = (ITextChannel)ctx.Channel; - FilterWordsChannelId removed; - await using (var uow = _db.GetDbContext()) - { - var config = - uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterWordsChannelIds)); + var enabled = await _service.ToggleChannelWordFilteringAsync(channel.Guild.Id, channel.Id); - var match = new FilterWordsChannelId - { - ChannelId = channel.Id - }; - removed = config.FilterWordsChannelIds.FirstOrDefault(fc => fc.Equals(match)); - if (removed is null) - config.FilterWordsChannelIds.Add(match); - else - uow.Remove(removed); - await uow.SaveChangesAsync(); - } - - if (removed is null) + if (enabled) { - _service.WordFilteringChannels.Add(channel.Id); await Response().Confirm(strs.word_filter_channel_on).SendAsync(); } else { - _service.WordFilteringChannels.TryRemove(channel.Id); await Response().Confirm(strs.word_filter_channel_off).SendAsync(); } } @@ -255,44 +177,17 @@ public partial class Permissions [RequireContext(ContextType.Guild)] public async Task FilterWord([Leftover] string word) { - var channel = (ITextChannel)ctx.Channel; - - word = word?.Trim().ToLowerInvariant(); - if (string.IsNullOrWhiteSpace(word)) return; - FilteredWord removed; - await using (var uow = _db.GetDbContext()) + var enabled = await _service.ToggleFilteredWordAsync(ctx.Guild.Id, word); + + if (enabled) { - var config = uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilteredWords)); - - removed = config.FilteredWords.FirstOrDefault(fw => fw.Word.Trim().ToLowerInvariant() == word); - - if (removed is null) - { - config.FilteredWords.Add(new() - { - Word = word - }); - } - else - uow.Remove(removed); - - await uow.SaveChangesAsync(); - } - - var filteredWords = - _service.ServerFilteredWords.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<string>()); - - if (removed is null) - { - filteredWords.Add(word); await Response().Confirm(strs.filter_word_add(Format.Code(word))).SendAsync(); } else { - filteredWords.TryRemove(word); await Response().Confirm(strs.filter_word_remove(Format.Code(word))).SendAsync(); } } @@ -305,11 +200,7 @@ public partial class Permissions if (page < 0) return; - var channel = (ITextChannel)ctx.Channel; - - _service.ServerFilteredWords.TryGetValue(channel.Guild.Id, out var fwHash); - - var fws = fwHash.ToArray(); + var fws = _service.FilteredWordsForServer(ctx.Guild.Id); await Response() .Paginated() diff --git a/src/EllieBot/Modules/Permissions/Filter/FilterService.cs b/src/EllieBot/Modules/Permissions/Filter/FilterService.cs index dd5fbc0..67dbff0 100644 --- a/src/EllieBot/Modules/Permissions/Filter/FilterService.cs +++ b/src/EllieBot/Modules/Permissions/Filter/FilterService.cs @@ -1,11 +1,13 @@ #nullable disable +using LinqToDB; +using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; using EllieBot.Db.Models; namespace EllieBot.Modules.Permissions.Services; -public sealed class FilterService : IExecOnMessage +public sealed class FilterService : IExecOnMessage, IReadyExecutor { public ConcurrentHashSet<ulong> InviteFilteringChannels { get; } public ConcurrentHashSet<ulong> InviteFilteringServers { get; } @@ -23,40 +25,20 @@ public sealed class FilterService : IExecOnMessage => int.MaxValue - 1; private readonly DbService _db; + private readonly ShardData _shardData; - public FilterService(DiscordSocketClient client, DbService db) + public FilterService(DiscordSocketClient client, DbService db, ShardData shardData) { _db = db; + _shardData = shardData; using (var uow = db.GetDbContext()) { var ids = client.GetGuildIds(); var configs = uow.Set<GuildConfig>() - .AsQueryable() - .Include(x => x.FilteredWords) - .Include(x => x.FilterLinksChannelIds) - .Include(x => x.FilterWordsChannelIds) - .Include(x => x.FilterInvitesChannelIds) - .Where(gc => ids.Contains(gc.GuildId)) - .ToList(); - - InviteFilteringServers = new(configs.Where(gc => gc.FilterInvites).Select(gc => gc.GuildId)); - InviteFilteringChannels = - new(configs.SelectMany(gc => gc.FilterInvitesChannelIds.Select(fci => fci.ChannelId))); - - LinkFilteringServers = new(configs.Where(gc => gc.FilterLinks).Select(gc => gc.GuildId)); - LinkFilteringChannels = - new(configs.SelectMany(gc => gc.FilterLinksChannelIds.Select(fci => fci.ChannelId))); - - var dict = configs.ToDictionary(gc => gc.GuildId, - gc => new ConcurrentHashSet<string>(gc.FilteredWords.Select(fw => fw.Word).Distinct())); - - ServerFilteredWords = new(dict); - - var serverFiltering = configs.Where(gc => gc.FilterWords); - WordFilteringServers = new(serverFiltering.Select(gc => gc.GuildId)); - WordFilteringChannels = - new(configs.SelectMany(gc => gc.FilterWordsChannelIds.Select(fwci => fwci.ChannelId))); + .AsQueryable() + .Where(gc => ids.Contains(gc.GuildId)) + .ToList(); } client.MessageUpdated += (oldData, newMsg, channel) => @@ -74,6 +56,43 @@ public sealed class FilterService : IExecOnMessage }; } + public async Task OnReadyAsync() + { + await using var uow = _db.GetDbContext(); + + var confs = await uow.GetTable<GuildFilterConfig>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .LoadWith(x => x.FilterInvitesChannelIds) + .LoadWith(x => x.FilterWordsChannelIds) + .LoadWith(x => x.FilterLinksChannelIds) + .LoadWith(x => x.FilteredWords) + .ToListAsyncLinqToDB(); + + foreach (var conf in confs) + { + foreach (var c in conf.FilterInvitesChannelIds) + InviteFilteringChannels.Add(c.ChannelId); + + foreach (var c in conf.FilterWordsChannelIds) + WordFilteringChannels.Add(c.ChannelId); + + foreach (var c in conf.FilterLinksChannelIds) + LinkFilteringChannels.Add(c.ChannelId); + + if (conf.FilterInvites) + InviteFilteringServers.Add(conf.GuildId); + + if (conf.FilterWords) + WordFilteringServers.Add(conf.GuildId); + + if (conf.FilterLinks) + LinkFilteringServers.Add(conf.GuildId); + + foreach (var word in conf.FilteredWords) + ServerFilteredWords.GetOrAdd(conf.GuildId, new ConcurrentHashSet<string>()).Add(word.Word); + } + } + public ConcurrentHashSet<string> FilteredWordsForChannel(ulong channelId, ulong guildId) { var words = new ConcurrentHashSet<string>(); @@ -82,23 +101,24 @@ public sealed class FilterService : IExecOnMessage return words; } - public void ClearFilteredWords(ulong guildId) + public async Task ClearFilteredWords(ulong guildId) { - using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, - set => set.Include(x => x.FilteredWords).Include(x => x.FilterWordsChannelIds)); + await using var uow = _db.GetDbContext(); + var fc = uow.FilterConfigForId(guildId, + set => set.Include(x => x.FilteredWords) + .Include(x => x.FilterWordsChannelIds)); WordFilteringServers.TryRemove(guildId); ServerFilteredWords.TryRemove(guildId, out _); - foreach (var c in gc.FilterWordsChannelIds) + foreach (var c in fc.FilterWordsChannelIds) WordFilteringChannels.TryRemove(c.ChannelId); - gc.FilterWords = false; - gc.FilteredWords.Clear(); - gc.FilterWordsChannelIds.Clear(); + fc.FilterWords = false; + fc.FilteredWords.Clear(); + fc.FilterWordsChannelIds.Clear(); - uow.SaveChanges(); + await uow.SaveChangesAsync(); } public ConcurrentHashSet<string> FilteredWordsForServer(ulong guildId) @@ -170,7 +190,7 @@ public sealed class FilterService : IExecOnMessage // if user has manage messages perm, don't filter if (usrMsg.Channel is ITextChannel ch && usrMsg.Author is IGuildUser gu && gu.GetPermissions(ch).ManageMessages) return false; - + if ((InviteFilteringChannels.Contains(usrMsg.Channel.Id) || InviteFilteringServers.Contains(guild.Id)) && usrMsg.Content.IsDiscordInvite()) { @@ -206,7 +226,7 @@ public sealed class FilterService : IExecOnMessage // if user has manage messages perm, don't filter if (usrMsg.Channel is ITextChannel ch && usrMsg.Author is IGuildUser gu && gu.GetPermissions(ch).ManageMessages) return false; - + if ((LinkFilteringChannels.Contains(usrMsg.Channel.Id) || LinkFilteringServers.Contains(guild.Id)) && usrMsg.Content.TryGetUrlPath(out _)) { @@ -233,17 +253,162 @@ public sealed class FilterService : IExecOnMessage public async Task<ServerFilterSettings> GetFilterSettings(ulong guildId) { await using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, - set => set - .Include(x => x.FilterInvitesChannelIds) - .Include(x => x.FilterLinksChannelIds)); + + var conf = await uow.GetTable<GuildFilterConfig>() + .Where(fi => fi.GuildId == guildId) + .LoadWith(x => x.FilterInvitesChannelIds) + .LoadWith(x => x.FilterLinksChannelIds) + .FirstOrDefaultAsyncLinqToDB(); return new() { - FilterInvitesChannels = gc.FilterInvitesChannelIds.Map(x => x.ChannelId), - FilterLinksChannels = gc.FilterLinksChannelIds.Map(x => x.ChannelId), - FilterInvitesEnabled = gc.FilterInvites, - FilterLinksEnabled = gc.FilterLinks, + FilterInvitesChannels = conf?.FilterInvitesChannelIds.Select(x => x.ChannelId).ToArray() ?? [], + FilterLinksChannels = conf?.FilterLinksChannelIds.Select(x => x.ChannelId).ToArray() ?? [], + FilterInvitesEnabled = false, + FilterLinksEnabled = false, }; } + + public async Task<bool> ToggleServerLinkFilteringAsync(ulong guildId) + { + await using var uow = _db.GetDbContext(); + + var fc = uow.FilterConfigForId(guildId); + if (LinkFilteringServers.Add(guildId)) + { + fc.FilterLinks = true; + } + else + { + fc.FilterLinks = false; + } + + await uow.SaveChangesAsync(); + return fc.FilterLinks; + } + + public async Task<bool> ToggleChannelLinkFilteringAsync(ulong guildId, ulong channelId) + { + await using var uow = _db.GetDbContext(); + + var fc = uow.FilterConfigForId(guildId, set => set.Include(x => x.FilterLinksChannelIds)); + + if (LinkFilteringChannels.Add(channelId)) + { + fc.FilterLinksChannelIds.Add(new FilterLinksChannelId + { + ChannelId = channelId + }); + + await uow.SaveChangesAsync(); + return true; + } + + LinkFilteringChannels.TryRemove(channelId); + fc.FilterLinksChannelIds.RemoveWhere(x => x.ChannelId == channelId); + await uow.SaveChangesAsync(); + return false; + } + + public async Task<bool> ToggleServerInviteFilteringAsync(ulong guildId) + { + await using var uow = _db.GetDbContext(); + var fc = uow.FilterConfigForId(guildId); + + if (InviteFilteringServers.Add(guildId)) + { + fc.FilterInvites = true; + await uow.SaveChangesAsync(); + return true; + } + + fc.FilterInvites = false; + await uow.SaveChangesAsync(); + return false; + } + + public async Task<bool> ToggleChannelInviteFilteringAsync(ulong guildId, ulong channelId) + { + await using var uow = _db.GetDbContext(); + var fc = uow.FilterConfigForId(guildId, set => set.Include(x => x.FilterInvitesChannelIds)); + + if (InviteFilteringChannels.Add(channelId)) + { + fc.FilterInvitesChannelIds.Add(new FilterChannelId() + { + ChannelId = channelId + }); + + await uow.SaveChangesAsync(); + return true; + } + + InviteFilteringChannels.TryRemove(channelId); + fc.FilterInvitesChannelIds.RemoveWhere(x => x.ChannelId == channelId); + await uow.SaveChangesAsync(); + return false; + } + + public async Task<bool> ToggleServerWordFilteringAsync(ulong guildId) + { + await using var uow = _db.GetDbContext(); + var fc = uow.FilterConfigForId(guildId); + + if (WordFilteringServers.Add(guildId)) + { + fc.FilterWords = true; + await uow.SaveChangesAsync(); + return true; + } + + fc.FilterWords = false; + await uow.SaveChangesAsync(); + return false; + } + + public async Task<bool> ToggleChannelWordFilteringAsync(ulong guildId, ulong channelId) + { + await using var uow = _db.GetDbContext(); + var fc = uow.FilterConfigForId(guildId, set => set.Include(x => x.FilterWordsChannelIds)); + + if (WordFilteringChannels.Add(channelId)) + { + fc.FilterWordsChannelIds.Add(new FilterWordsChannelId() + { + ChannelId = channelId + }); + + await uow.SaveChangesAsync(); + return true; + } + + WordFilteringChannels.TryRemove(channelId); + fc.FilterWordsChannelIds.RemoveWhere(x => x.ChannelId == channelId); + await uow.SaveChangesAsync(); + return false; + } + + public async Task<bool> ToggleFilteredWordAsync(ulong guildId, string word) + { + word = word?.Trim().ToLowerInvariant(); + + await using var uow = _db.GetDbContext(); + var fc = uow.FilterConfigForId(guildId, set => set.Include(x => x.FilteredWords)); + var sfw = ServerFilteredWords.GetOrAdd(guildId, []); + if (sfw.Add(word)) + { + fc.FilteredWords.Add(new FilteredWord() + { + Word = word + }); + + await uow.SaveChangesAsync(); + } + + sfw.TryRemove(word); + fc.FilteredWords.RemoveWhere(x => x.Word == word); + await uow.SaveChangesAsync(); + + return true; + } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Searches/Feeds/FeedsService.cs b/src/EllieBot/Modules/Searches/Feeds/FeedsService.cs index d08ec0a..a3d9db2 100644 --- a/src/EllieBot/Modules/Searches/Feeds/FeedsService.cs +++ b/src/EllieBot/Modules/Searches/Feeds/FeedsService.cs @@ -4,46 +4,52 @@ using CodeHollow.FeedReader.Feeds; using LinqToDB; using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; +using EllieBot.Common.ModuleBehaviors; using EllieBot.Db.Models; +using System.Collections.Concurrent; namespace EllieBot.Modules.Searches.Services; -public class FeedsService : IEService +public class FeedsService : IEService, IReadyExecutor { private readonly DbService _db; - private readonly ConcurrentDictionary<string, List<FeedSub>> _subs; + private NonBlocking.ConcurrentDictionary<string, List<FeedSub>> _subs; private readonly DiscordSocketClient _client; private readonly IMessageSenderService _sender; + private readonly ShardData _shardData; - private readonly ConcurrentDictionary<string, DateTime> _lastPosts = new(); + private readonly NonBlocking.ConcurrentDictionary<string, DateTime> _lastPosts = new(); private readonly Dictionary<string, uint> _errorCounters = new(); public FeedsService( - IBot bot, DbService db, DiscordSocketClient client, - IMessageSenderService sender) + IMessageSenderService sender, + ShardData shardData) { _db = db; - using (var uow = db.GetDbContext()) - { - var guildConfigIds = bot.AllGuildConfigs.Select(x => x.Id).ToList(); - _subs = uow.Set<GuildConfig>() - .AsQueryable() - .Where(x => guildConfigIds.Contains(x.Id)) - .Include(x => x.FeedSubs) - .ToList() - .SelectMany(x => x.FeedSubs) - .GroupBy(x => x.Url.ToLower()) - .ToDictionary(x => x.Key, x => x.ToList()) - .ToConcurrent(); - } _client = client; _sender = sender; + _shardData = shardData; + } - _ = Task.Run(TrackFeeds); + public async Task OnReadyAsync() + { + await using (var uow = _db.GetDbContext()) + { + var subs = await uow.Set<FeedSub>() + .AsQueryable() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .ToListAsyncLinqToDB(); + _subs = subs + .GroupBy(x => x.Url.ToLower()) + .ToDictionary(x => x.Key, x => x.ToList()) + .ToConcurrent(); + } + + await TrackFeeds(); } private void ClearErrors(string url) @@ -116,7 +122,7 @@ public class FeedsService : IEService if (items.Count > 2) break; } - + if (items.Count == 0) continue; @@ -189,7 +195,7 @@ public class FeedsService : IEService foreach (var val in kvp.Value) { - var ch = _client.GetGuild(val.GuildConfig.GuildId).GetTextChannel(val.ChannelId); + var ch = _client.GetGuild(val.GuildId).GetTextChannel(val.ChannelId); if (ch is null) continue; @@ -228,8 +234,10 @@ public class FeedsService : IEService public List<FeedSub> GetFeeds(ulong guildId) { using var uow = _db.GetDbContext(); - return uow.GuildConfigsForId(guildId, set => set.Include(x => x.FeedSubs)) - .FeedSubs.OrderBy(x => x.Id) + + return uow.GetTable<FeedSub>() + .Where(x => x.GuildId == guildId) + .OrderBy(x => x.Id) .ToList(); } @@ -249,26 +257,21 @@ public class FeedsService : IEService }; using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.FeedSubs)); + var feeds = uow.GetTable<FeedSub>() + .Where(x => x.GuildId == guildId) + .ToArray(); - if (gc.FeedSubs.Any(x => x.Url.ToLower() == fs.Url.ToLower())) + if (feeds.Any(x => x.Url.ToLower() == fs.Url.ToLower())) return FeedAddResult.Duplicate; - if (gc.FeedSubs.Count >= 10) + if (feeds.Length >= 10) return FeedAddResult.LimitReached; - gc.FeedSubs.Add(fs); + uow.Add(fs); uow.SaveChanges(); - //adding all, in case bot wasn't on this guild when it started - foreach (var feed in gc.FeedSubs) - { - _subs.AddOrUpdate(feed.Url.ToLower(), - [feed], - (_, old) => - { - old.Add(feed); - return old; - }); - } + + _subs.AddOrUpdate(fs.Url.ToLower(), + [fs], + (_, old) => old.Append(fs).ToList()); return FeedAddResult.Success; } @@ -279,19 +282,20 @@ public class FeedsService : IEService return false; using var uow = _db.GetDbContext(); - var items = uow.GuildConfigsForId(guildId, set => set.Include(x => x.FeedSubs)) - .FeedSubs.OrderBy(x => x.Id) - .ToList(); + var items = uow.Set<FeedSub>() + .Where(x => x.GuildId == guildId) + .OrderBy(x => x.Id) + .ToList(); if (items.Count <= index) return false; + var toRemove = items[index]; _subs.AddOrUpdate(toRemove.Url.ToLower(), [], (_, old) => { - old.Remove(toRemove); - return old; + return old.Where(x => x.Id != toRemove.Id).ToList(); }); uow.Remove(toRemove); uow.SaveChanges(); diff --git a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs index a10c38c..20051ce 100644 --- a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs +++ b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs @@ -1,6 +1,4 @@ #nullable disable -using Microsoft.EntityFrameworkCore; -using EllieBot.Db.Models; using EllieBot.Modules.Searches.Services; namespace EllieBot.Modules.Searches; @@ -100,7 +98,7 @@ public partial class Searches [UserPerm(GuildPerm.ManageMessages)] public async Task StreamOffline() { - var newValue = _service.ToggleStreamOffline(ctx.Guild.Id); + var newValue = await _service.ToggleStreamOffline(ctx.Guild.Id); if (newValue) await Response().Confirm(strs.stream_off_enabled).SendAsync(); else @@ -112,7 +110,7 @@ public partial class Searches [UserPerm(GuildPerm.ManageMessages)] public async Task StreamOnlineDelete() { - var newValue = _service.ToggleStreamOnlineDelete(ctx.Guild.Id); + var newValue = await _service.ToggleStreamOnlineDelete(ctx.Guild.Id); if (newValue) await Response().Confirm(strs.stream_online_delete_enabled).SendAsync(); else @@ -151,7 +149,7 @@ public partial class Searches var canMentionEveryone = (ctx.User as IGuildUser)?.GuildPermissions.MentionEveryone ?? true; if (!canMentionEveryone) message = message?.SanitizeAllMentions(); - + var count = _service.SetStreamMessageForAll(ctx.Guild.Id, message); if (count == 0) diff --git a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationService.cs b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationService.cs index 24178c0..d8d074d 100644 --- a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationService.cs +++ b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationService.cs @@ -1,5 +1,6 @@ #nullable disable -using Microsoft.EntityFrameworkCore; +using LinqToDB; +using LinqToDB.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; using EllieBot.Db.Models; using EllieBot.Modules.Searches.Common; @@ -17,16 +18,17 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor private readonly object _shardLock = new(); - private readonly Dictionary<StreamDataKey, HashSet<ulong>> _trackCounter = new(); + private Dictionary<StreamDataKey, HashSet<ulong>> _trackCounter = new(); - private readonly Dictionary<StreamDataKey, Dictionary<ulong, HashSet<FollowedStream>>> _shardTrackedStreams; - private readonly ConcurrentHashSet<ulong> _offlineNotificationServers; - private readonly ConcurrentHashSet<ulong> _deleteOnOfflineServers; + private Dictionary<StreamDataKey, Dictionary<ulong, HashSet<FollowedStream>>> _shardTrackedStreams; + private readonly ConcurrentHashSet<ulong> _offlineNotificationServers = []; + private readonly ConcurrentHashSet<ulong> _deleteOnOfflineServers = []; private readonly IPubSub _pubSub; private readonly IMessageSenderService _sender; private readonly SearchesConfigService _config; private readonly IReplacementService _repSvc; + private readonly ShardData _shardData; public TypedKey<List<StreamData>> StreamsOnlineKey { get; } public TypedKey<List<StreamData>> StreamsOfflineKey { get; } @@ -46,10 +48,10 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor IBotStrings strings, IBotCredsProvider creds, IHttpClientFactory httpFactory, - IBot bot, IPubSub pubSub, IMessageSenderService sender, SearchesConfigService config, + ShardData shardData, IReplacementService repSvc) { _db = db; @@ -59,6 +61,7 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor _sender = sender; _config = config; _repSvc = repSvc; + _shardData = shardData; _streamTracker = new(httpFactory, creds); @@ -68,56 +71,6 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor _streamFollowKey = new("stream.follow"); _streamUnfollowKey = new("stream.unfollow"); - using (var uow = db.GetDbContext()) - { - var ids = client.GetGuildIds(); - var guildConfigs = uow.Set<GuildConfig>() - .AsQueryable() - .Include(x => x.FollowedStreams) - .Where(x => ids.Contains(x.GuildId)) - .ToList(); - - _offlineNotificationServers = new(guildConfigs - .Where(gc => gc.NotifyStreamOffline) - .Select(x => x.GuildId) - .ToList()); - - _deleteOnOfflineServers = new(guildConfigs - .Where(gc => gc.DeleteStreamOnlineMessage) - .Select(x => x.GuildId) - .ToList()); - - var followedStreams = guildConfigs.SelectMany(x => x.FollowedStreams).ToList(); - - _shardTrackedStreams = followedStreams.GroupBy(x => new - { - x.Type, - Name = x.Username.ToLower() - }) - .ToList() - .ToDictionary( - x => new StreamDataKey(x.Key.Type, x.Key.Name.ToLower()), - x => x.GroupBy(y => y.GuildId) - .ToDictionary(y => y.Key, - y => y.AsEnumerable().ToHashSet())); - - // shard 0 will keep track of when there are no more guilds which track a stream - if (client.ShardId == 0) - { - var allFollowedStreams = uow.Set<FollowedStream>().AsQueryable().ToList(); - - foreach (var fs in allFollowedStreams) - _streamTracker.AddLastData(fs.CreateKey(), null, false); - - _trackCounter = allFollowedStreams.GroupBy(x => new - { - x.Type, - Name = x.Username.ToLower() - }) - .ToDictionary(x => new StreamDataKey(x.Key.Type, x.Key.Name), - x => x.Select(fs => fs.GuildId).ToHashSet()); - } - } _pubSub.Sub(StreamsOfflineKey, HandleStreamsOffline); _pubSub.Sub(StreamsOnlineKey, HandleStreamsOnline); @@ -134,15 +87,76 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor _pubSub.Sub(_streamUnfollowKey, HandleUnfollowStream); } - bot.JoinedGuild += ClientOnJoinedGuild; + client.JoinedGuild += ClientOnJoinedGuild; client.LeftGuild += ClientOnLeftGuild; } + private async Task InitStateAsync() + { + await using var uow = _db.GetDbContext(); + // todo check all guilds on shard for correct param order + var notifyOffline = await uow.GetTable<GuildConfig>() + .Where(gc => gc.NotifyStreamOffline) + .Select(x => x.GuildId) + .ToListAsyncLinqToDB(); + + foreach (var guildId in notifyOffline) + _offlineNotificationServers.Add(guildId); + + var deleteOnOffline = await uow.GetTable<GuildConfig>() + .Where(gc => Queries.GuildOnShard(gc.GuildId, + _shardData.TotalShards, + _shardData.ShardId)) + .Where(gc => gc.DeleteStreamOnlineMessage) + .Select(x => x.GuildId) + .ToListAsyncLinqToDB(); + + foreach (var guildId in deleteOnOffline) + _deleteOnOfflineServers.Add(guildId); + + var followedStreams = await uow.GetTable<FollowedStream>() + .Where(x => Queries.GuildOnShard(x.GuildId, + _shardData.TotalShards, + _shardData.ShardId)) + .ToListAsyncLinqToDB(); + + _shardTrackedStreams = followedStreams.GroupBy(x => new + { + x.Type, + Name = x.Username.ToLower() + }) + .ToList() + .ToDictionary( + x => new StreamDataKey(x.Key.Type, x.Key.Name.ToLower()), + x => x.GroupBy(y => y.GuildId) + .ToDictionary(y => y.Key, + y => y.AsEnumerable().ToHashSet())); + + // shard 0 will keep track of when there are no more guilds which track a stream + if (_client.ShardId == 0) + { + var allFollowedStreams = uow.Set<FollowedStream>().AsQueryable().ToList(); + + foreach (var fs in allFollowedStreams) + _streamTracker.AddLastData(fs.CreateKey(), null, false); + + _trackCounter = allFollowedStreams.GroupBy(x => new + { + x.Type, + Name = x.Username.ToLower() + }) + .ToDictionary(x => new StreamDataKey(x.Key.Type, x.Key.Name), + x => x.Select(fs => fs.GuildId).ToHashSet()); + } + } + public async Task OnReadyAsync() { if (_client.ShardId != 0) return; + await InitStateAsync(); + using var timer = new PeriodicTimer(TimeSpan.FromMinutes(30)); while (await timer.WaitForNextTickAsync()) { @@ -198,7 +212,9 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor { var key = info.Key; if (_trackCounter.ContainsKey(key)) + { _trackCounter[key].Add(info.GuildId); + } else { _trackCounter[key] = [info.GuildId]; @@ -332,65 +348,67 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor private Task OnStreamsOffline(List<StreamData> data) => _pubSub.Pub(StreamsOfflineKey, data); - private Task ClientOnJoinedGuild(GuildConfig guildConfig) + private async Task ClientOnJoinedGuild(SocketGuild guild) { - using (var uow = _db.GetDbContext()) + await using (var uow = _db.GetDbContext()) { - var gc = uow.Set<GuildConfig>() - .AsQueryable() - .Include(x => x.FollowedStreams) - .FirstOrDefault(x => x.GuildId == guildConfig.GuildId); + var fs = await uow.Set<FollowedStream>() + .Where(x => x.GuildId == guild.Id) + .ToListAsyncLinqToDB(); - if (gc is null) - return Task.CompletedTask; + var notifyOffline = await uow.GetTable<GuildConfig>() + .Where(x => x.GuildId == guild.Id) + .Select(x => x.NotifyStreamOffline) + .FirstOrDefaultAsyncLinqToDB(); - if (gc.NotifyStreamOffline) - _offlineNotificationServers.Add(gc.GuildId); + // todo hashset + if (notifyOffline) + _offlineNotificationServers.Add(guild.Id); - foreach (var followedStream in gc.FollowedStreams) + foreach (var followedStream in fs) { var key = followedStream.CreateKey(); - var streams = GetLocalGuildStreams(key, gc.GuildId); + var streams = GetLocalGuildStreams(key, guild.Id); streams.Add(followedStream); PublishFollowStream(followedStream); } } - - return Task.CompletedTask; } - private Task ClientOnLeftGuild(SocketGuild guild) + private async Task ClientOnLeftGuild(SocketGuild guild) { - using (var uow = _db.GetDbContext()) + await using var uow = _db.GetDbContext(); + var followedStreams = await uow.Set<FollowedStream>() + .Where(x => x.GuildId == guild.Id) + .ToListAsyncLinqToDB(); + + _offlineNotificationServers.TryRemove(guild.Id); + + foreach (var followedStream in followedStreams) { - var gc = uow.GuildConfigsForId(guild.Id, set => set.Include(x => x.FollowedStreams)); + var streams = GetLocalGuildStreams(followedStream.CreateKey(), guild.Id); + streams.Remove(followedStream); - _offlineNotificationServers.TryRemove(gc.GuildId); - - foreach (var followedStream in gc.FollowedStreams) - { - var streams = GetLocalGuildStreams(followedStream.CreateKey(), guild.Id); - streams.Remove(followedStream); - - PublishUnfollowStream(followedStream); - } + await PublishUnfollowStream(followedStream); } - - return Task.CompletedTask; } public async Task<int> ClearAllStreams(ulong guildId) { await using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.FollowedStreams)); - uow.RemoveRange(gc.FollowedStreams); - foreach (var s in gc.FollowedStreams) + var followedStreams = await uow.Set<FollowedStream>() + .Where(x => x.GuildId == guildId) + .ToListAsyncEF(); + + uow.RemoveRange(followedStreams); + + foreach (var s in followedStreams) await PublishUnfollowStream(s); - uow.SaveChanges(); + await uow.SaveChangesAsync(); - return gc.FollowedStreams.Count; + return followedStreams.Count; } public async Task<FollowedStream> UnfollowStreamAsync(ulong guildId, int index) @@ -398,11 +416,11 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor FollowedStream fs; await using (var uow = _db.GetDbContext()) { - var fss = uow.Set<FollowedStream>() - .AsQueryable() - .Where(x => x.GuildId == guildId) - .OrderBy(x => x.Id) - .ToList(); + var fss = await uow.Set<FollowedStream>() + .AsQueryable() + .Where(x => x.GuildId == guildId) + .OrderBy(x => x.Id) + .ToListAsyncEF(); // out of range if (fss.Count <= index) @@ -454,7 +472,9 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor FollowedStream fs; await using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.FollowedStreams)); + var followedStreams = await uow.Set<FollowedStream>() + .Where(x => x.GuildId == guildId) + .ToListAsyncEF(); // add it to the database fs = new() @@ -467,10 +487,10 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor var config = _config.Data; if (config.FollowedStreams.MaxCount is not -1 - && gc.FollowedStreams.Count >= config.FollowedStreams.MaxCount) + && followedStreams.Count >= config.FollowedStreams.MaxCount) return null; - gc.FollowedStreams.Add(fs); + uow.Add(fs); await uow.SaveChangesAsync(); // add it to the local cache of tracked streams @@ -529,13 +549,27 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor private string GetText(ulong guildId, LocStr str) => _strings.GetText(str, guildId); - public bool ToggleStreamOffline(ulong guildId) + public async Task<bool> ToggleStreamOffline(ulong guildId) { - bool newValue; - using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set); - newValue = gc.NotifyStreamOffline = !gc.NotifyStreamOffline; - uow.SaveChanges(); + await using var uow = _db.GetDbContext(); + await uow.GetTable<GuildConfig>() + .InsertOrUpdateAsync(() => new() + { + GuildId = guildId, + }, + (old) => new() + { + NotifyStreamOffline = !old.NotifyStreamOffline + }, + () => new() + { + GuildId = guildId + }); + + var newValue = await uow.GetTable<GuildConfig>() + .Where(x => x.GuildId == guildId) + .Select(x => x.NotifyStreamOffline) + .FirstOrDefaultAsyncLinqToDB(); if (newValue) _offlineNotificationServers.Add(guildId); @@ -545,12 +579,27 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor return newValue; } - public bool ToggleStreamOnlineDelete(ulong guildId) + public async Task<bool> ToggleStreamOnlineDelete(ulong guildId) { - using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set); - var newValue = gc.DeleteStreamOnlineMessage = !gc.DeleteStreamOnlineMessage; - uow.SaveChanges(); + await using var uow = _db.GetDbContext(); + await uow.GetTable<GuildConfig>() + .InsertOrUpdateAsync(() => new() + { + GuildId = guildId, + }, + (old) => new() + { + DeleteStreamOnlineMessage = !old.DeleteStreamOnlineMessage + }, + () => new() + { + GuildId = guildId + }); + + var newValue = await uow.GetTable<GuildConfig>() + .Where(x => x.GuildId == guildId) + .Select(x => x.DeleteStreamOnlineMessage) + .FirstOrDefaultAsyncLinqToDB(); if (newValue) _deleteOnOfflineServers.Add(guildId); @@ -650,13 +699,13 @@ public sealed class StreamNotificationService : IEService, IReadyExecutor public async Task<List<FollowedStream>> GetAllStreamsAsync(SocketGuild guild) { - var allStreams = new List<FollowedStream>(); await using var uow = _db.GetDbContext(); - var all = uow.GuildConfigsForId(guild.Id, set => set.Include(gc => gc.FollowedStreams)) - .FollowedStreams - .OrderBy(x => x.Id) - .ToList(); + var all = await uow.Set<FollowedStream>() + .Where(x => x.GuildId == guild.Id) + .OrderBy(x => x.Id) + .ToListAsyncEF(); + var allStreams = new List<FollowedStream>(); for (var index = all.Count - 1; index >= 0; index--) { var fs = all[index]; diff --git a/src/EllieBot/Modules/Searches/Translate/FlagTranslateService.cs b/src/EllieBot/Modules/Searches/Translate/FlagTranslateService.cs index 68249e8..1695e68 100644 --- a/src/EllieBot/Modules/Searches/Translate/FlagTranslateService.cs +++ b/src/EllieBot/Modules/Searches/Translate/FlagTranslateService.cs @@ -48,7 +48,7 @@ public sealed partial class FlagTranslateService : IReadyExecutor, IEService await using (var uow = _db.GetDbContext()) { _enabledChannels = (await uow.GetTable<FlagTranslateChannel>() - .Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId, + .Where(x => Queries.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) .Select(x => new diff --git a/src/EllieBot/Modules/Searches/Translate/TranslateService.cs b/src/EllieBot/Modules/Searches/Translate/TranslateService.cs index bfc413f..2627e02 100644 --- a/src/EllieBot/Modules/Searches/Translate/TranslateService.cs +++ b/src/EllieBot/Modules/Searches/Translate/TranslateService.cs @@ -35,7 +35,9 @@ public sealed class TranslateService : ITranslateService, IExecNoCommand, IReady List<AutoTranslateChannel> cs; await using (var ctx = _db.GetDbContext()) { - var guilds = _bot.AllGuildConfigs.Select(x => x.GuildId).ToList(); + var guilds = await ctx.GetTable<GuildConfig>() + .Select(x => x.GuildId) + .ToListAsyncLinqToDB(); cs = await ctx.Set<AutoTranslateChannel>().Include(x => x.Users) .Where(x => guilds.Contains(x.GuildId)) .ToListAsyncEF(); @@ -106,8 +108,8 @@ public sealed class TranslateService : ITranslateService, IExecNoCommand, IReady { await using var ctx = _db.GetDbContext(); - var old = await ctx.Set<AutoTranslateChannel>().ToLinqToDBTable() - .FirstOrDefaultAsyncLinqToDB(x => x.ChannelId == channelId); + var old = await ctx.Set<AutoTranslateChannel>() + .FirstOrDefaultAsyncEF(x => x.ChannelId == channelId); if (old is null) { diff --git a/src/EllieBot/Modules/Searches/_common/StreamNotifications/Models/StreamDataKey.cs b/src/EllieBot/Modules/Searches/_common/StreamNotifications/Models/StreamDataKey.cs index e946185..c385556 100644 --- a/src/EllieBot/Modules/Searches/_common/StreamNotifications/Models/StreamDataKey.cs +++ b/src/EllieBot/Modules/Searches/_common/StreamNotifications/Models/StreamDataKey.cs @@ -3,7 +3,7 @@ using EllieBot.Db.Models; namespace EllieBot.Modules.Searches.Common; -public readonly struct StreamDataKey +public readonly record struct StreamDataKey { public FollowedStream.FType Type { get; init; } public string Name { get; init; } diff --git a/src/EllieBot/Modules/Utility/Alias/AliasCommands.cs b/src/EllieBot/Modules/Utility/Alias/AliasCommands.cs index 23724d1..8532699 100644 --- a/src/EllieBot/Modules/Utility/Alias/AliasCommands.cs +++ b/src/EllieBot/Modules/Utility/Alias/AliasCommands.cs @@ -24,7 +24,7 @@ public partial class Utility [UserPerm(GuildPerm.Administrator)] public async Task AliasesClear() { - var count = _service.ClearAliases(ctx.Guild.Id); + var count = await _service.ClearAliases(ctx.Guild.Id); await Response().Confirm(strs.aliases_cleared(count)).SendAsync(); } @@ -40,64 +40,17 @@ public partial class Utility if (string.IsNullOrWhiteSpace(mapping)) { - if (!_service.AliasMaps.TryGetValue(ctx.Guild.Id, out var maps) || !maps.TryRemove(trigger, out _)) + if (!await _service.RemoveAliasAsync(ctx.Guild.Id, trigger)) { await Response().Error(strs.alias_remove_fail(Format.Code(trigger))).SendAsync(); return; } - await using (var uow = _db.GetDbContext()) - { - var config = uow.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases)); - var tr = config.CommandAliases.FirstOrDefault(x => x.Trigger == trigger); - if (tr is not null) - uow.Set<CommandAlias>().Remove(tr); - uow.SaveChanges(); - } - await Response().Confirm(strs.alias_removed(Format.Code(trigger))).SendAsync(); return; } - _service.AliasMaps.AddOrUpdate(ctx.Guild.Id, - _ => - { - using (var uow = _db.GetDbContext()) - { - var config = uow.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases)); - config.CommandAliases.Add(new() - { - Mapping = mapping, - Trigger = trigger - }); - uow.SaveChanges(); - } - - return new(new Dictionary<string, string> - { - { trigger.Trim().ToLowerInvariant(), mapping.ToLowerInvariant() } - }); - }, - (_, map) => - { - using (var uow = _db.GetDbContext()) - { - var config = uow.GuildConfigsForId(ctx.Guild.Id, set => set.Include(x => x.CommandAliases)); - var toAdd = new CommandAlias - { - Mapping = mapping, - Trigger = trigger - }; - var toRemove = config.CommandAliases.Where(x => x.Trigger == trigger).ToArray(); - if (toRemove.Any()) - uow.RemoveRange(toRemove); - config.CommandAliases.Add(toAdd); - uow.SaveChanges(); - } - - map.AddOrUpdate(trigger, mapping, (_, _) => mapping); - return map; - }); + await _service.AddAliasAsync(ctx.Guild.Id, trigger, mapping); await Response().Confirm(strs.alias_added(Format.Code(trigger), Format.Code(mapping))).SendAsync(); } @@ -112,13 +65,14 @@ public partial class Utility if (page < 0) return; - if (!_service.AliasMaps.TryGetValue(ctx.Guild.Id, out var maps) || !maps.Any()) + var aliases = await _service.GetAliasesAsync(ctx.Guild.Id); + if (aliases is null || aliases.Count == 0) { await Response().Error(strs.aliases_none).SendAsync(); return; } - var arr = maps.ToArray(); + var arr = aliases.Select(x => (Trigger: x.Key, Mapping: x.Value)).ToArray(); await Response() .Paginated() @@ -130,7 +84,7 @@ public partial class Utility return CreateEmbed() .WithOkColor() .WithTitle(GetText(strs.alias_list)) - .WithDescription(string.Join("\n", items.Select(x => $"`{x.Key}` => `{x.Value}`"))); + .WithDescription(string.Join("\n", items.Select(x => $"`{x.Trigger}` => `{x.Mapping}`"))); }) .SendAsync(); } diff --git a/src/EllieBot/Modules/Utility/Alias/AliasService.cs b/src/EllieBot/Modules/Utility/Alias/AliasService.cs index 876f155..8ec8e9d 100644 --- a/src/EllieBot/Modules/Utility/Alias/AliasService.cs +++ b/src/EllieBot/Modules/Utility/Alias/AliasService.cs @@ -1,54 +1,47 @@ -#nullable disable -using Microsoft.EntityFrameworkCore; +using LinqToDB; +using LinqToDB.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; using EllieBot.Db.Models; namespace EllieBot.Modules.Utility.Services; -public class AliasService : IInputTransformer, IEService +public class AliasService : IInputTransformer, IReadyExecutor, IEService { - public ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>> AliasMaps { get; } = new(); + private ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>> _aliases = new(); private readonly DbService _db; private readonly IMessageSenderService _sender; + private readonly ShardData _shardData; public AliasService( - DiscordSocketClient client, DbService db, - IMessageSenderService sender) + IMessageSenderService sender, + ShardData shardData) { _sender = sender; + _shardData = shardData; using var uow = db.GetDbContext(); - var guildIds = client.Guilds.Select(x => x.Id).ToList(); - var configs = uow.Set<GuildConfig>() - .Include(gc => gc.CommandAliases) - .Where(x => guildIds.Contains(x.GuildId)) - .ToList(); - AliasMaps = new(configs.ToDictionary(x => x.GuildId, - x => new ConcurrentDictionary<string, string>(x.CommandAliases.DistinctBy(ca => ca.Trigger) - .ToDictionary(ca => ca.Trigger, ca => ca.Mapping), - StringComparer.OrdinalIgnoreCase))); _db = db; } - public int ClearAliases(ulong guildId) + public async Task<int> ClearAliases(ulong guildId) { - AliasMaps.TryRemove(guildId, out _); + _aliases.TryRemove(guildId, out _); - int count; - using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.CommandAliases)); - count = gc.CommandAliases.Count; - gc.CommandAliases.Clear(); - uow.SaveChanges(); - return count; + await using var uow = _db.GetDbContext(); + + var deleted = await uow.GetTable<CommandAlias>() + .Where(x => x.GuildId == guildId) + .DeleteAsync(); + + return deleted; } - public async Task<string> TransformInput( - IGuild guild, + public async Task<string?> TransformInput( + IGuild? guild, IMessageChannel channel, IUser user, string input) @@ -56,39 +49,47 @@ public class AliasService : IInputTransformer, IEService if (guild is null || string.IsNullOrWhiteSpace(input)) return null; - if (AliasMaps.TryGetValue(guild.Id, out var maps)) + if (_aliases.TryGetValue(guild.Id, out var maps)) { - string newInput = null; - foreach (var (k, v) in maps) + string? newInput = null; + + if (maps.TryGetValue(input, out var alias)) { - if (string.Equals(input, k, StringComparison.OrdinalIgnoreCase)) + newInput = alias; + } + else + { + foreach (var (k, v) in maps) { - newInput = v; + if (string.Equals(input, k, StringComparison.OrdinalIgnoreCase)) + { + newInput = v; + } + else if (input.StartsWith(k + ' ', StringComparison.OrdinalIgnoreCase)) + { + if (v.Contains("%target%")) + newInput = v.Replace("%target%", input[k.Length..]); + else + newInput = v + ' ' + input[k.Length..]; + } } - else if (input.StartsWith(k + ' ', StringComparison.OrdinalIgnoreCase)) + } + + if (newInput is not null) + { + try { - if (v.Contains("%target%")) - newInput = v.Replace("%target%", input[k.Length..]); - else - newInput = v + ' ' + input[k.Length..]; + var toDelete = await _sender.Response(channel) + .Confirm($"{input} => {newInput}") + .SendAsync(); + toDelete.DeleteAfter(1.5f); + } + catch + { + // ignored } - if (newInput is not null) - { - try - { - var toDelete = await _sender.Response(channel) - .Confirm($"{input} => {newInput}") - .SendAsync(); - toDelete.DeleteAfter(1.5f); - } - catch - { - // ignored - } - - return newInput; - } + return newInput; } return null; @@ -96,4 +97,71 @@ public class AliasService : IInputTransformer, IEService return null; } + + public async Task OnReadyAsync() + { + await using var ctx = _db.GetDbContext(); + + var aliases = ctx.GetTable<CommandAlias>() + .Where(x => Queries.GuildOnShard(x.GuildId, + _shardData.TotalShards, + _shardData.ShardId)) + .ToList(); + + _aliases = new(); + foreach (var alias in aliases) + { + _aliases.GetOrAdd(alias.GuildId, _ => new(StringComparer.OrdinalIgnoreCase)) + .TryAdd(alias.Trigger, alias.Mapping); + } + } + + public async Task<bool> RemoveAliasAsync(ulong guildId, string trigger) + { + await using var ctx = _db.GetDbContext(); + + var deleted = await ctx.GetTable<CommandAlias>() + .Where(x => x.GuildId == guildId && x.Trigger == trigger) + .DeleteAsync(); + + if (_aliases.TryGetValue(guildId, out var aliases)) + aliases.TryRemove(trigger, out _); + + return deleted > 0; + } + + public async Task AddAliasAsync(ulong guildId, string trigger, string mapping) + { + await using var ctx = _db.GetDbContext(); + + await ctx.GetTable<CommandAlias>() + .InsertOrUpdateAsync(() => new() + { + GuildId = guildId, + Trigger = trigger, + Mapping = mapping, + }, + (old) => new() + { + Mapping = mapping + }, + () => new() + { + GuildId = guildId, + Trigger = trigger, + }); + + var guildDict = _aliases.GetOrAdd(guildId, (_) => new()); + guildDict[trigger] = mapping; + } + + public async Task<IReadOnlyDictionary<string, string>?> GetAliasesAsync(ulong guildId) + { + await Task.Yield(); + + if (_aliases.TryGetValue(guildId, out var aliases)) + return aliases; + + return null; + } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Utility/Giveaway/GiveawayService.cs b/src/EllieBot/Modules/Utility/Giveaway/GiveawayService.cs index 7f7b065..44d66a3 100644 --- a/src/EllieBot/Modules/Utility/Giveaway/GiveawayService.cs +++ b/src/EllieBot/Modules/Utility/Giveaway/GiveawayService.cs @@ -94,7 +94,7 @@ public sealed class GiveawayService : IEService, IReadyExecutor var gas = await ctx .GetTable<GiveawayModel>() - .Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) + .Where(x => Queries.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) .ToArrayAsync(); lock (_giveawayCache) diff --git a/src/EllieBot/Modules/Utility/Remind/RemindService.cs b/src/EllieBot/Modules/Utility/Remind/RemindService.cs index db804aa..e594de5 100644 --- a/src/EllieBot/Modules/Utility/Remind/RemindService.cs +++ b/src/EllieBot/Modules/Utility/Remind/RemindService.cs @@ -93,7 +93,7 @@ public class RemindService : IEService, IReadyExecutor, IRemindService await using var uow = _db.GetDbContext(); var earliest = await uow.Set<Reminder>() .ToLinqToDBTable() - .Where(x => Linq2DbExpressions.GuildOnShard(x.ServerId, + .Where(x => Queries.GuildOnShard(x.ServerId, _creds.TotalShards, _client.ShardId)) .OrderBy(x => x.When) @@ -116,7 +116,7 @@ public class RemindService : IEService, IReadyExecutor, IRemindService var reminders = await uow.Set<Reminder>() .ToLinqToDBTable() - .Where(x => Linq2DbExpressions.GuildOnShard(x.ServerId, + .Where(x => Queries.GuildOnShard(x.ServerId, _creds.TotalShards, _client.ShardId)) .Where(x => x.When <= now) diff --git a/src/EllieBot/Modules/Utility/StreamRole/StreamRoleService.cs b/src/EllieBot/Modules/Utility/StreamRole/StreamRoleService.cs index eee20a1..4c191a5 100644 --- a/src/EllieBot/Modules/Utility/StreamRole/StreamRoleService.cs +++ b/src/EllieBot/Modules/Utility/StreamRole/StreamRoleService.cs @@ -3,6 +3,7 @@ using EllieBot.Modules.Utility.Common; using EllieBot.Modules.Utility.Common.Exceptions; using EllieBot.Db.Models; using System.Net; +using LinqToDB.EntityFrameworkCore; namespace EllieBot.Modules.Utility.Services; @@ -10,26 +11,19 @@ public class StreamRoleService : IReadyExecutor, IEService { private readonly DbService _db; private readonly DiscordSocketClient _client; - private readonly ConcurrentDictionary<ulong, StreamRoleSettings> _guildSettings; - private readonly QueueRunner _queueRunner; + private ConcurrentDictionary<ulong, StreamRoleSettings> _guildSettings = new(); + private QueueRunner _queueRunner; - public StreamRoleService(DiscordSocketClient client, DbService db, IBot bot) + public StreamRoleService(DiscordSocketClient client, DbService db) { _db = db; _client = client; - - _guildSettings = bot.AllGuildConfigs.ToDictionary(x => x.GuildId, x => x.StreamRole) - .Where(x => x.Value is { Enabled: true }) - .ToConcurrent(); - - _client.PresenceUpdated += OnPresenceUpdate; - _queueRunner = new QueueRunner(); } private Task OnPresenceUpdate(SocketUser user, SocketPresence? oldPresence, SocketPresence? newPresence) { - + _ = Task.Run(async () => { if (oldPresence?.Activities?.Count != newPresence?.Activities?.Count) @@ -49,8 +43,21 @@ public class StreamRoleService : IReadyExecutor, IEService return Task.CompletedTask; } - public Task OnReadyAsync() - => Task.WhenAll(_client.Guilds.Select(RescanUsers).WhenAll(), _queueRunner.RunAsync()); + public async Task OnReadyAsync() + { + await using var uow = _db.GetDbContext(); + + _guildSettings = await uow.GetTable<StreamRoleSettings>() + .Where(x => x.Enabled) + .ToDictionaryAsyncLinqToDB(x => x.GuildId, x => x) + .Fmap(x => x.ToConcurrent()); + + _client.PresenceUpdated += OnPresenceUpdate; + + + + await Task.WhenAll(_client.Guilds.Select(RescanUsers).WhenAll(), _queueRunner.RunAsync()); + } /// <summary> /// Adds or removes a user from a blacklist or a whitelist in the specified guild. @@ -73,7 +80,7 @@ public class StreamRoleService : IReadyExecutor, IEService var success = false; await using (var uow = _db.GetDbContext()) { - var streamRoleSettings = uow.GetStreamRoleSettings(guild.Id); + var streamRoleSettings = await uow.GetOrCreateStreamRoleSettings(guild.Id); if (listType == StreamRoleListType.Whitelist) { @@ -93,7 +100,9 @@ public class StreamRoleService : IReadyExecutor, IEService } } else + { success = streamRoleSettings.Whitelist.Add(userObj); + } } else { @@ -110,7 +119,9 @@ public class StreamRoleService : IReadyExecutor, IEService success = streamRoleSettings.Blacklist.Remove(toRemove); } else + { success = streamRoleSettings.Blacklist.Add(userObj); + } } await uow.SaveChangesAsync(); @@ -134,7 +145,7 @@ public class StreamRoleService : IReadyExecutor, IEService await using (var uow = _db.GetDbContext()) { - var streamRoleSettings = uow.GetStreamRoleSettings(guild.Id); + var streamRoleSettings = await uow.GetOrCreateStreamRoleSettings(guild.Id); streamRoleSettings.Keyword = keyword; UpdateCache(guild.Id, streamRoleSettings); @@ -150,15 +161,15 @@ public class StreamRoleService : IReadyExecutor, IEService /// </summary> /// <param name="guildId">Guild Id</param> /// <returns>The keyword set</returns> - public string GetKeyword(ulong guildId) + public async Task<string> GetKeyword(ulong guildId) { if (_guildSettings.TryGetValue(guildId, out var outSetting)) return outSetting.Keyword; StreamRoleSettings setting; - using (var uow = _db.GetDbContext()) + await using (var uow = _db.GetDbContext()) { - setting = uow.GetStreamRoleSettings(guildId); + setting = await uow.GetOrCreateStreamRoleSettings(guildId); } UpdateCache(guildId, setting); @@ -180,7 +191,7 @@ public class StreamRoleService : IReadyExecutor, IEService StreamRoleSettings setting; await using (var uow = _db.GetDbContext()) { - var streamRoleSettings = uow.GetStreamRoleSettings(fromRole.Guild.Id); + var streamRoleSettings = await uow.GetOrCreateStreamRoleSettings(fromRole.Guild.Id); streamRoleSettings.Enabled = true; streamRoleSettings.AddRoleId = addRole.Id; @@ -207,7 +218,7 @@ public class StreamRoleService : IReadyExecutor, IEService { await using (var uow = _db.GetDbContext()) { - var streamRoleSettings = uow.GetStreamRoleSettings(guild.Id); + var streamRoleSettings = await uow.GetOrCreateStreamRoleSettings(guild.Id); streamRoleSettings.Enabled = false; streamRoleSettings.AddRoleId = 0; streamRoleSettings.FromRoleId = 0; diff --git a/src/EllieBot/Modules/Utility/Utility.cs b/src/EllieBot/Modules/Utility/Utility.cs index 790315c..c248f40 100644 --- a/src/EllieBot/Modules/Utility/Utility.cs +++ b/src/EllieBot/Modules/Utility/Utility.cs @@ -699,7 +699,7 @@ public partial class Utility : EllieModule [UserPerm(GuildPerm.ManageMessages)] public async Task VerboseError(bool? newstate = null) { - var state = _veService.ToggleVerboseErrors(ctx.Guild.Id, newstate); + var state = await _veService.ToggleVerboseErrors(ctx.Guild.Id, newstate); if (state) await Response().Confirm(strs.verbose_errors_enabled).SendAsync(); diff --git a/src/EllieBot/Modules/Utility/VerboseErrorsService.cs b/src/EllieBot/Modules/Utility/VerboseErrorsService.cs index e8e8c43..748c7c2 100644 --- a/src/EllieBot/Modules/Utility/VerboseErrorsService.cs +++ b/src/EllieBot/Modules/Utility/VerboseErrorsService.cs @@ -1,29 +1,31 @@ #nullable disable +using LinqToDB.EntityFrameworkCore; +using EllieBot.Common.ModuleBehaviors; +using EllieBot.Db.Models; + namespace EllieBot.Modules.Utility.Services; -public class VerboseErrorsService : IEService +public class VerboseErrorsService : IReadyExecutor, IEService { - private readonly ConcurrentHashSet<ulong> _guildsDisabled; + private readonly ConcurrentHashSet<ulong> _guildsDisabled = []; private readonly DbService _db; private readonly CommandHandler _ch; private readonly ICommandsUtilityService _hs; private readonly IMessageSenderService _sender; + private readonly ShardData _shardData; public VerboseErrorsService( - IBot bot, DbService db, CommandHandler ch, IMessageSenderService sender, - ICommandsUtilityService hs) + ICommandsUtilityService hs, + ShardData shardData) { _db = db; _ch = ch; _hs = hs; _sender = sender; - - _ch.CommandErrored += LogVerboseError; - - _guildsDisabled = new(bot.AllGuildConfigs.Where(x => !x.VerboseErrors).Select(x => x.GuildId)); + _shardData = shardData; } private async Task LogVerboseError(CommandInfo cmd, ITextChannel channel, string reason) @@ -48,23 +50,37 @@ public class VerboseErrorsService : IEService } } - public bool ToggleVerboseErrors(ulong guildId, bool? maybeEnabled = null) + public async Task<bool> ToggleVerboseErrors(ulong guildId, bool? maybeEnabled = null) { - using var uow = _db.GetDbContext(); - var gc = uow.GuildConfigsForId(guildId, set => set); + await using var ctx = _db.GetDbContext(); - if (maybeEnabled is bool isEnabled) // set it - gc.VerboseErrors = isEnabled; - else // toggle it - isEnabled = gc.VerboseErrors = !gc.VerboseErrors; - - uow.SaveChanges(); + var isEnabled = ctx.GetTable<GuildConfig>() + .Where(x => x.GuildId == guildId) + .Select(x => x.VerboseErrors) + .FirstOrDefault(); if (isEnabled) // This doesn't need to be duplicated inside the using block + { _guildsDisabled.TryRemove(guildId); + } else + { _guildsDisabled.Add(guildId); + } return isEnabled; } + + public async Task OnReadyAsync() + { + await using var ctx = _db.GetDbContext(); + var disabledOn = ctx.GetTable<GuildConfig>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId) && !x.VerboseErrors) + .Select(x => x.GuildId); + + foreach (var guildId in disabledOn) + _guildsDisabled.Add(guildId); + + _ch.CommandErrored += LogVerboseError; + } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Xp/Xp.cs b/src/EllieBot/Modules/Xp/Xp.cs index a386b91..eee259c 100644 --- a/src/EllieBot/Modules/Xp/Xp.cs +++ b/src/EllieBot/Modules/Xp/Xp.cs @@ -56,7 +56,7 @@ public partial class Xp : EllieModule<XpService> [UserPerm(GuildPerm.Administrator)] public async Task XpExclude(Server _) { - var ex = _service.ToggleExcludeServer(ctx.Guild.Id); + var ex = await _service.ToggleExcludeServerAsync(ctx.Guild.Id); if (ex) await Response().Confirm(strs.excluded(Format.Bold(ctx.Guild.ToString()))).SendAsync(); @@ -69,7 +69,7 @@ public partial class Xp : EllieModule<XpService> [RequireContext(ContextType.Guild)] public async Task XpExclude(Role _, [Leftover] IRole role) { - var ex = _service.ToggleExcludeRole(ctx.Guild.Id, role.Id); + var ex = await _service.ToggleExcludeRoleAsync(ctx.Guild.Id, role.Id); if (ex) await Response().Confirm(strs.excluded(Format.Bold(role.ToString()))).SendAsync(); @@ -85,7 +85,7 @@ public partial class Xp : EllieModule<XpService> if (channel is null) channel = ctx.Channel; - var ex = _service.ToggleExcludeChannel(ctx.Guild.Id, channel.Id); + var ex = await _service.ToggleExcludeChannelAsync(ctx.Guild.Id, channel.Id); if (ex) await Response().Confirm(strs.excluded(Format.Bold(channel.ToString()))).SendAsync(); @@ -308,7 +308,7 @@ public partial class Xp : EllieModule<XpService> if (amount == 0) return; - _service.AddXp(userId, ctx.Guild.Id, amount); + await _service.AddXpAsync(userId, ctx.Guild.Id, amount); var usr = ((SocketGuild)ctx.Guild).GetUser(userId)?.ToString() ?? userId.ToString(); await Response().Confirm(strs.modified(Format.Bold(usr), Format.Bold(amount.ToString()))).SendAsync(); } @@ -455,7 +455,7 @@ public partial class Xp : EllieModule<XpService> if (!string.IsNullOrWhiteSpace(item.Desc)) eb.AddField(GetText(strs.desc), item.Desc); -#if GLOBAL_ELLIE +#if GLOBAL_NADEKO if (key == "default") eb.WithDescription(GetText(strs.xpshop_website)); #endif diff --git a/src/EllieBot/Modules/Xp/XpConfig.cs b/src/EllieBot/Modules/Xp/XpConfig.cs index efa89e8..7b973e4 100644 --- a/src/EllieBot/Modules/Xp/XpConfig.cs +++ b/src/EllieBot/Modules/Xp/XpConfig.cs @@ -16,7 +16,7 @@ public sealed partial class XpConfig : ICloneable<XpConfig> public int XpPerMessage { get; set; } = 3; [Comment("""How often can the users receive XP, in seconds""")] - public int MessageXpCooldown { get; set; } = 300; + public float MessageXpCooldown { get; set; } = 300; [Comment("""Amount of xp users gain from posting an image""")] public int XpFromImage { get; set; } = 0; diff --git a/src/EllieBot/Modules/Xp/XpConfigService.cs b/src/EllieBot/Modules/Xp/XpConfigService.cs index 5b8ed99..bfb46c7 100644 --- a/src/EllieBot/Modules/Xp/XpConfigService.cs +++ b/src/EllieBot/Modules/Xp/XpConfigService.cs @@ -16,8 +16,8 @@ public sealed class XpConfigService : ConfigServiceBase<XpConfig> { AddParsedProp("txt.cooldown", conf => conf.MessageXpCooldown, - int.TryParse, - ConfigPrinters.ToString, + float.TryParse, + (f) => f.ToString("F2"), x => x > 0); AddParsedProp("txt.per_msg", conf => conf.XpPerMessage, int.TryParse, ConfigPrinters.ToString, x => x >= 0); AddParsedProp("txt.per_image", conf => conf.XpFromImage, int.TryParse, ConfigPrinters.ToString, x => x > 0); diff --git a/src/EllieBot/Modules/Xp/XpRewards.cs b/src/EllieBot/Modules/Xp/XpRewards.cs index 1ec3ae2..f737e4a 100644 --- a/src/EllieBot/Modules/Xp/XpRewards.cs +++ b/src/EllieBot/Modules/Xp/XpRewards.cs @@ -31,15 +31,15 @@ public partial class Xp [Cmd] [RequireContext(ContextType.Guild)] - public Task XpLevelUpRewards(int page = 1) + public async Task XpLevelUpRewards(int page = 1) { page--; if (page is < 0 or > 100) - return Task.CompletedTask; + return; - var allRewards = _service.GetRoleRewards(ctx.Guild.Id) - .OrderBy(x => x.Level) + var rews = await _service.GetRoleRewardsAsync(ctx.Guild.Id); + var allRewards = rews.OrderBy(x => x.Level) .Select(x => { var sign = !x.Remove ? "✅ " : "❌ "; @@ -47,7 +47,9 @@ public partial class Xp var str = ctx.Guild.GetRole(x.RoleId)?.ToString(); if (str is null) + { str = GetText(strs.role_not_found(Format.Code(x.RoleId.ToString()))); + } else { if (!x.Remove) @@ -58,7 +60,7 @@ public partial class Xp return (x.Level, Text: sign + str); }) - .Concat(_service.GetCurrencyRewards(ctx.Guild.Id) + .Concat((await _service.GetCurrencyRewardsAsync(ctx.Guild.Id)) .OrderBy(x => x.Level) .Select(x => (x.Level, Format.Bold(x.Amount + _cp.GetCurrencySign())))) @@ -66,7 +68,7 @@ public partial class Xp .OrderBy(x => x.Key) .ToList(); - return Response() + await Response() .Paginated() .Items(allRewards) .PageSize(9) @@ -79,8 +81,10 @@ public partial class Xp return embed.WithDescription(GetText(strs.no_level_up_rewards)); foreach (var reward in items) + { embed.AddField(GetText(strs.level_x(reward.Key)), string.Join("\n", reward.Select(y => y.Item2))); + } return embed; }) @@ -94,7 +98,7 @@ public partial class Xp [Priority(2)] public async Task XpRoleReward(int level) { - _service.ResetRoleReward(ctx.Guild.Id, level); + await _service.ResetRoleRewardAsync(ctx.Guild.Id, level); await Response().Confirm(strs.xp_role_reward_cleared(level)).SendAsync(); } @@ -108,9 +112,11 @@ public partial class Xp if (level < 1) return; - _service.SetRoleReward(ctx.Guild.Id, level, role.Id, action == AddRemove.Remove); + await _service.SetRoleRewardAsync(ctx.Guild.Id, level, role.Id, action == AddRemove.Remove); if (action == AddRemove.Add) + { await Response().Confirm(strs.xp_role_reward_add_role(level, Format.Bold(role.ToString()))).SendAsync(); + } else { await Response() @@ -128,14 +134,18 @@ public partial class Xp if (level < 1 || amount < 0) return; - _service.SetCurrencyReward(ctx.Guild.Id, level, amount); + await _service.SetCurrencyReward(ctx.Guild.Id, level, amount); if (amount == 0) + { await Response().Confirm(strs.cur_reward_cleared(level, _cp.GetCurrencySign())).SendAsync(); + } else + { await Response() .Confirm(strs.cur_reward_added(level, Format.Bold(amount + _cp.GetCurrencySign()))) .SendAsync(); + } } } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Xp/XpService.cs b/src/EllieBot/Modules/Xp/XpService.cs index de539a4..9db0b7e 100644 --- a/src/EllieBot/Modules/Xp/XpService.cs +++ b/src/EllieBot/Modules/Xp/XpService.cs @@ -33,8 +33,8 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand private readonly XpConfigService _xpConfig; private readonly IPubSub _pubSub; - private readonly ConcurrentDictionary<ulong, ConcurrentHashSet<ulong>> _excludedRoles; - private readonly ConcurrentDictionary<ulong, ConcurrentHashSet<ulong>> _excludedChannels; + private readonly ConcurrentDictionary<ulong, ConcurrentHashSet<ulong>> _excludedRoles = new(); + private readonly ConcurrentDictionary<ulong, ConcurrentHashSet<ulong>> _excludedChannels = new(); private readonly ConcurrentHashSet<ulong> _excludedServers; private XpTemplate template; @@ -45,14 +45,14 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand private readonly IBotCache _c; - private readonly QueueRunner _levelUpQueue = new QueueRunner(0, 50); + private readonly QueueRunner _levelUpQueue = new(0, 50); private readonly Channel<UserXpGainData> _xpGainQueue = Channel.CreateUnbounded<UserXpGainData>(); private readonly IMessageSenderService _sender; private readonly INotifySubscriber _notifySub; + private readonly ShardData _shardData; public XpService( DiscordSocketClient client, - IBot bot, DbService db, IBotStrings strings, IImageCache images, @@ -65,7 +65,8 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand IPubSub pubSub, IPatronageService ps, IMessageSenderService sender, - INotifySubscriber notifySub) + INotifySubscriber notifySub, + ShardData shardData) { _db = db; _images = images; @@ -78,6 +79,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand _pubSub = pubSub; _sender = sender; _notifySub = notifySub; + _shardData = shardData; _excludedServers = new(); _excludedChannels = new(); _client = client; @@ -98,25 +100,6 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand } //load settings - var allGuildConfigs = bot.AllGuildConfigs.Where(x => x.XpSettings is not null).ToList(); - - _excludedChannels = allGuildConfigs.ToDictionary(x => x.GuildId, - x => new ConcurrentHashSet<ulong>(x.XpSettings.ExclusionList - .Where(ex => ex.ItemType == ExcludedItemType.Channel) - .Select(ex => ex.ItemId) - .Distinct())) - .ToConcurrent(); - - _excludedRoles = allGuildConfigs.ToDictionary(x => x.GuildId, - x => new ConcurrentHashSet<ulong>(x.XpSettings.ExclusionList - .Where(ex => ex.ItemType - == ExcludedItemType.Role) - .Select(ex => ex.ItemId) - .Distinct())) - .ToConcurrent(); - - _excludedServers = new(allGuildConfigs.Where(x => x.XpSettings.ServerExcluded).Select(x => x.GuildId)); - #if !GLOBAL_ELLIE _client.UserVoiceStateUpdated += Client_OnUserVoiceStateUpdated; @@ -131,6 +114,30 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand { _ = Task.Run(() => _levelUpQueue.RunAsync()); + // initialize ignored + + await using (var ctx = _db.GetDbContext()) + { + var xps = await ctx.GetTable<XpSettings>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .LoadWith(x => x.ExclusionList) + .ToListAsyncLinqToDB(); + + foreach (var xp in xps) + { + if (xp.ServerExcluded) + _excludedServers.Add(xp.GuildId); + + foreach (var item in xp.ExclusionList) + { + if (item.ItemType == ExcludedItemType.Channel) + _excludedChannels[xp.GuildId].Add(item.ItemId); + else if (item.ItemType == ExcludedItemType.Role) + _excludedRoles[xp.GuildId].Add(item.ItemId); + } + } + } + using var timer = new PeriodicTimer(TimeSpan.FromSeconds(5)); while (await timer.WaitForNextTickAsync()) { @@ -327,8 +334,8 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand List<XpCurrencyReward> crews; await using (var ctx = _db.GetDbContext()) { - rrews = ctx.XpSettingsFor(guildId).RoleRewards.ToList(); - crews = ctx.XpSettingsFor(guildId).CurrencyRewards.ToList(); + rrews = await ctx.XpSettingsFor(guildId).Fmap(x => x.RoleRewards.ToList()); + crews = await ctx.XpSettingsFor(guildId).Fmap(x => x.CurrencyRewards.ToList()); } //loop through levels since last level up, so if a high amount of xp is gained, reward are still applied. @@ -467,10 +474,10 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand public void ReloadXpTemplate() => _pubSub.Pub(_xpTemplateReloadKey, true); - public void SetCurrencyReward(ulong guildId, int level, int amount) + public async Task SetCurrencyReward(ulong guildId, int level, int amount) { - using var uow = _db.GetDbContext(); - var settings = uow.XpSettingsFor(guildId); + await using var uow = _db.GetDbContext(); + var settings = await uow.XpSettingsFor(guildId); if (amount <= 0) { @@ -500,22 +507,22 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand uow.SaveChanges(); } - public IEnumerable<XpCurrencyReward> GetCurrencyRewards(ulong id) + public async Task<IEnumerable<XpCurrencyReward>> GetCurrencyRewardsAsync(ulong id) { - using var uow = _db.GetDbContext(); - return uow.XpSettingsFor(id).CurrencyRewards.ToArray(); + await using var uow = _db.GetDbContext(); + return (await uow.XpSettingsFor(id)).CurrencyRewards.ToArray(); } - public IEnumerable<XpRoleReward> GetRoleRewards(ulong id) + public async Task<IEnumerable<XpRoleReward>> GetRoleRewardsAsync(ulong id) { - using var uow = _db.GetDbContext(); - return uow.XpSettingsFor(id).RoleRewards.ToArray(); + await using var uow = _db.GetDbContext(); + return (await uow.XpSettingsFor(id)).RoleRewards.ToArray(); } - public void ResetRoleReward(ulong guildId, int level) + public async Task ResetRoleRewardAsync(ulong guildId, int level) { - using var uow = _db.GetDbContext(); - var settings = uow.XpSettingsFor(guildId); + await using var uow = _db.GetDbContext(); + var settings = await uow.XpSettingsFor(guildId); var toRemove = settings.RoleRewards.FirstOrDefault(x => x.Level == level); if (toRemove is not null) @@ -527,15 +534,14 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand uow.SaveChanges(); } - public void SetRoleReward( + public async Task SetRoleRewardAsync( ulong guildId, int level, ulong roleId, bool remove) { - using var uow = _db.GetDbContext(); - var settings = uow.XpSettingsFor(guildId); - + await using var uow = _db.GetDbContext(); + var settings = await uow.XpSettingsFor(guildId); var rew = settings.RoleRewards.FirstOrDefault(x => x.Level == level); @@ -837,9 +843,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand }); } - public void AddXp(ulong userId, ulong guildId, int amount) + public async Task AddXpAsync(ulong userId, ulong guildId, int amount) { - using var uow = _db.GetDbContext(); + await using var uow = _db.GetDbContext(); var usr = uow.GetOrCreateUserXpStats(guildId, userId); usr.Xp += amount; @@ -893,28 +899,28 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand guildRank); } - public bool ToggleExcludeServer(ulong id) + public async Task<bool> ToggleExcludeServerAsync(ulong id) { - using var uow = _db.GetDbContext(); - var xpSetting = uow.XpSettingsFor(id); + await using var uow = _db.GetDbContext(); + var xpSetting = await uow.XpSettingsFor(id); if (_excludedServers.Add(id)) { xpSetting.ServerExcluded = true; - uow.SaveChanges(); + await uow.SaveChangesAsync(); return true; } _excludedServers.TryRemove(id); xpSetting.ServerExcluded = false; - uow.SaveChanges(); + await uow.SaveChangesAsync(); return false; } - public bool ToggleExcludeRole(ulong guildId, ulong rId) + public async Task<bool> ToggleExcludeRoleAsync(ulong guildId, ulong rId) { var roles = _excludedRoles.GetOrAdd(guildId, _ => new()); - using var uow = _db.GetDbContext(); - var xpSetting = uow.XpSettingsFor(guildId); + await using var uow = _db.GetDbContext(); + var xpSetting = await uow.XpSettingsFor(guildId); var excludeObj = new ExcludedItem { ItemId = rId, @@ -924,7 +930,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand if (roles.Add(rId)) { if (xpSetting.ExclusionList.Add(excludeObj)) - uow.SaveChanges(); + await uow.SaveChangesAsync(); return true; } @@ -935,17 +941,17 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand if (toDelete is not null) { uow.Remove(toDelete); - uow.SaveChanges(); + await uow.SaveChangesAsync(); } return false; } - public bool ToggleExcludeChannel(ulong guildId, ulong chId) + public async Task<bool> ToggleExcludeChannelAsync(ulong guildId, ulong chId) { var channels = _excludedChannels.GetOrAdd(guildId, _ => new()); - using var uow = _db.GetDbContext(); - var xpSetting = uow.XpSettingsFor(guildId); + await using var uow = _db.GetDbContext(); + var xpSetting = await uow.XpSettingsFor(guildId); var excludeObj = new ExcludedItem { ItemId = chId, @@ -955,7 +961,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand if (channels.Add(chId)) { if (xpSetting.ExclusionList.Add(excludeObj)) - uow.SaveChanges(); + await uow.SaveChangesAsync(); return true; } @@ -963,7 +969,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand channels.TryRemove(chId); if (xpSetting.ExclusionList.Remove(excludeObj)) - uow.SaveChanges(); + await uow.SaveChangesAsync(); return false; } @@ -1405,15 +1411,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand public async Task ResetXpRewards(ulong guildId) { await using var uow = _db.GetDbContext(); - var guildConfig = uow.GuildConfigsForId(guildId, - set => set.Include(x => x.XpSettings) - .ThenInclude(x => x.CurrencyRewards) - .Include(x => x.XpSettings) - .ThenInclude(x => x.RoleRewards)); - - uow.RemoveRange(guildConfig.XpSettings.RoleRewards); - uow.RemoveRange(guildConfig.XpSettings.CurrencyRewards); - await uow.SaveChangesAsync(); + await uow.GetTable<XpSettings>() + .Where(x => x.GuildId == guildId) + .DeleteAsync(); } public ValueTask<Dictionary<string, XpConfig.ShopItemInfo>?> GetShopBgs() diff --git a/src/EllieBot/Services/GrpcApi/XpSvc.cs b/src/EllieBot/Services/GrpcApi/XpSvc.cs index 6d66fd8..a30d1c9 100644 --- a/src/EllieBot/Services/GrpcApi/XpSvc.cs +++ b/src/EllieBot/Services/GrpcApi/XpSvc.cs @@ -56,8 +56,8 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService Name = guild.GetRole(x)?.Name ?? "????" }))); - var curRews = _xp.GetCurrencyRewards(request.GuildId); - var roleRews = _xp.GetRoleRewards(request.GuildId); + var curRews = await _xp.GetCurrencyRewardsAsync(request.GuildId); + var roleRews = await _xp.GetRoleRewardsAsync(request.GuildId); var rews = curRews.Select(x => new RewItemReply() { @@ -99,7 +99,7 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService Success = false }; - success = _xp.ToggleExcludeRole(request.GuildId, request.Id); + success = await _xp.ToggleExcludeRoleAsync(request.GuildId, request.Id); } else if (request.Type == "Channel") { @@ -109,7 +109,7 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService Success = false }; - success = _xp.ToggleExcludeChannel(request.GuildId, request.Id); + success = await _xp.ToggleExcludeChannelAsync(request.GuildId, request.Id); } return new() @@ -118,20 +118,20 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService }; } - public override Task<DeleteExclusionReply> DeleteExclusion( + public override async Task<DeleteExclusionReply> DeleteExclusion( DeleteExclusionRequest request, ServerCallContext context) { var success = false; if (request.Type == "Role") - success = _xp.ToggleExcludeRole(request.GuildId, request.Id); + success = await _xp.ToggleExcludeRoleAsync(request.GuildId, request.Id); else - success = _xp.ToggleExcludeChannel(request.GuildId, request.Id); + success = await _xp.ToggleExcludeChannelAsync(request.GuildId, request.Id); - return Task.FromResult(new DeleteExclusionReply + return new DeleteExclusionReply { Success = success - }); + }; } public override async Task<AddRewardReply> AddReward(AddRewardRequest request, ServerCallContext context) @@ -156,7 +156,7 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService Success = false }; - _xp.SetRoleReward(request.GuildId, request.Level, rid, request.Type == "RemoveRole"); + await _xp.SetRoleRewardAsync(request.GuildId, request.Level, rid, request.Type == "RemoveRole"); success = true; } // else if (request.Type == "Currency") @@ -174,25 +174,25 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService }; } - public override Task<DeleteRewardReply> DeleteReward(DeleteRewardRequest request, ServerCallContext context) + public override async Task<DeleteRewardReply> DeleteReward(DeleteRewardRequest request, ServerCallContext context) { var success = false; if (request.Type == "AddRole" || request.Type == "RemoveRole") { - _xp.ResetRoleReward(request.GuildId, request.Level); + await _xp.ResetRoleRewardAsync(request.GuildId, request.Level); success = true; } else if (request.Type == "Currency") { - _xp.SetCurrencyReward(request.GuildId, request.Level, 0); + await _xp.SetCurrencyReward(request.GuildId, request.Level, 0); success = true; } - return Task.FromResult(new DeleteRewardReply + return new() { Success = success - }); + }; } public override async Task<ResetUserXpReply> ResetUserXp(ResetUserXpRequest request, ServerCallContext context) @@ -271,9 +271,7 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService SetServerExclusionRequest request, ServerCallContext context) { - await Task.Yield(); - - var newValue = _xp.ToggleExcludeServer(request.GuildId); + var newValue = await _xp.ToggleExcludeServerAsync(request.GuildId); return new() { Success = newValue diff --git a/src/EllieBot/_common/IBot.cs b/src/EllieBot/_common/IBot.cs index c6c5a06..54b3785 100644 --- a/src/EllieBot/_common/IBot.cs +++ b/src/EllieBot/_common/IBot.cs @@ -5,8 +5,5 @@ namespace EllieBot; public interface IBot { - IReadOnlyList<ulong> GetCurrentGuildIds(); - event Func<GuildConfig, Task> JoinedGuild; - IReadOnlyCollection<GuildConfig> AllGuildConfigs { get; } bool IsReady { get; } } \ No newline at end of file diff --git a/src/EllieBot/_common/Impl/Localization.cs b/src/EllieBot/_common/Impl/Localization.cs index a1ff55d..9cfbf1b 100644 --- a/src/EllieBot/_common/Impl/Localization.cs +++ b/src/EllieBot/_common/Impl/Localization.cs @@ -1,16 +1,19 @@ #nullable disable +using LinqToDB.EntityFrameworkCore; +using EllieBot.Common.ModuleBehaviors; +using EllieBot.Db.Models; using Newtonsoft.Json; using System.Globalization; namespace EllieBot.Services; -public class Localization : ILocalization +public class Localization : ILocalization, IReadyExecutor { private static readonly Dictionary<string, CommandData> _commandData = JsonConvert.DeserializeObject<Dictionary<string, CommandData>>( File.ReadAllText("./data/strings/commands/commands.en-US.json")); - private readonly ConcurrentDictionary<ulong, CultureInfo> _guildCultureInfos; + private ConcurrentDictionary<ulong, CultureInfo> _guildCultureInfos; public IDictionary<ulong, CultureInfo> GuildCultureInfos => _guildCultureInfos; @@ -20,30 +23,13 @@ public class Localization : ILocalization private readonly BotConfigService _bss; private readonly DbService _db; + private readonly ShardData _shardData; - public Localization(BotConfigService bss, Bot bot, DbService db) + public Localization(BotConfigService bss, DbService db, ShardData shardData) { _bss = bss; _db = db; - - var cultureInfoNames = bot.AllGuildConfigs.ToDictionary(x => x.GuildId, x => x.Locale); - - _guildCultureInfos = new(cultureInfoNames - .ToDictionary(x => x.Key, - x => - { - CultureInfo cultureInfo = null; - try - { - if (x.Value is null) - return null; - cultureInfo = new(x.Value); - } - catch { } - - return cultureInfo; - }) - .Where(x => x.Value is not null)); + _shardData = shardData; } public void SetGuildCulture(IGuild guild, CultureInfo ci) @@ -59,7 +45,7 @@ public class Localization : ILocalization using (var uow = _db.GetDbContext()) { - var gc = uow.GuildConfigsForId(guildId, set => set); + var gc = uow.GuildConfigsForId(guildId); gc.Locale = ci.Name; uow.SaveChanges(); } @@ -117,4 +103,34 @@ public class Localization : ILocalization return toReturn; } + + public async Task OnReadyAsync() + { + await using var uow = _db.GetDbContext(); + + var cultureInfoNames = await uow.GuildConfigs + .Where(x => Queries.GuildOnShard(x.GuildId, + _shardData.TotalShards, + _shardData.ShardId)) + .ToListAsyncLinqToDB(); + + _guildCultureInfos = cultureInfoNames + .ToDictionary(x => x.GuildId, + x => + { + CultureInfo cultureInfo = null; + try + { + if (x.Locale is null) + return null; + + cultureInfo = new(x.Locale); + } + catch { } + + return cultureInfo; + }) + .Where(x => x.Value is not null) + .ToConcurrent(); + } } \ No newline at end of file diff --git a/src/EllieBot/_common/Linq2DbExpressions.cs b/src/EllieBot/_common/Linq2DbExpressions.cs index baa1f74..071b2da 100644 --- a/src/EllieBot/_common/Linq2DbExpressions.cs +++ b/src/EllieBot/_common/Linq2DbExpressions.cs @@ -5,7 +5,7 @@ using System.Linq.Expressions; namespace EllieBot.Common; -public static class Linq2DbExpressions +public static class Queries { [ExpressionMethod(nameof(GuildOnShardExpression))] public static bool GuildOnShard(ulong guildId, int totalShards, int shardId) diff --git a/src/EllieBot/_common/Services/CommandHandler.cs b/src/EllieBot/_common/Services/CommandHandler.cs index a9c81a1..0497a47 100644 --- a/src/EllieBot/_common/Services/CommandHandler.cs +++ b/src/EllieBot/_common/Services/CommandHandler.cs @@ -1,6 +1,8 @@ #nullable disable +using LinqToDB.EntityFrameworkCore; using EllieBot.Common.Configs; using EllieBot.Common.ModuleBehaviors; +using EllieBot.Db.Models; using ExecuteResult = Discord.Commands.ExecuteResult; using PreconditionResult = Discord.Commands.PreconditionResult; @@ -26,8 +28,9 @@ public class CommandHandler : IEService, IReadyExecutor, ICommandHandler private readonly IBot _bot; private readonly IBehaviorHandler _behaviorHandler; private readonly IServiceProvider _services; + private readonly ShardData _shardData; - private readonly ConcurrentDictionary<ulong, string> _prefixes; + private ConcurrentDictionary<ulong, string> _prefixes; private readonly DbService _db; @@ -42,7 +45,8 @@ public class CommandHandler : IEService, IReadyExecutor, ICommandHandler IBot bot, IBehaviorHandler behaviorHandler, // InteractionService interactions, - IServiceProvider services) + IServiceProvider services, + ShardData shardData) { _client = client; _commandService = commandService; @@ -52,15 +56,21 @@ public class CommandHandler : IEService, IReadyExecutor, ICommandHandler _behaviorHandler = behaviorHandler; _db = db; _services = services; + _shardData = shardData; // _interactions = interactions; - - _prefixes = bot.AllGuildConfigs.Where(x => x.Prefix is not null) - .ToDictionary(x => x.GuildId, x => x.Prefix) - .ToConcurrent(); } public async Task OnReadyAsync() { + await using (var uow = _db.GetDbContext()) + { + _prefixes = await uow.GetTable<GuildConfig>() + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .Where(x => x.Prefix != null) + .ToListAsyncLinqToDB() + .Fmap(x => x.ToDictionary(x => x.GuildId, x => x.Prefix).ToConcurrent()); + } + // clear users on short cooldown every GLOBAL_COMMANDS_COOLDOWN miliseconds using var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(GLOBAL_COMMANDS_COOLDOWN)); while (await timer.WaitForNextTickAsync()) @@ -229,7 +239,7 @@ public class CommandHandler : IEService, IReadyExecutor, ICommandHandler { try { -#if !GLOBAL_ELLIE +#if !GLOBAL_NADEKO // track how many messages each user is sending UserMessagesSent.AddOrUpdate(usrMsg.Author.Id, 1, (_, old) => ++old); #endif @@ -261,7 +271,7 @@ public class CommandHandler : IEService, IReadyExecutor, ICommandHandler var blockTime = Environment.TickCount - startTime; var messageContent = await _behaviorHandler.RunInputTransformersAsync(guild, usrMsg); - + var prefix = GetPrefix(guild?.Id); var isPrefixCommand = messageContent.StartsWith(".prefix", StringComparison.InvariantCultureIgnoreCase); // execute the command and measure the time it took diff --git a/src/EllieBot/_common/Services/Impl/BlacklistService.cs b/src/EllieBot/_common/Services/Impl/BlacklistService.cs index b92f5b2..2980158 100644 --- a/src/EllieBot/_common/Services/Impl/BlacklistService.cs +++ b/src/EllieBot/_common/Services/Impl/BlacklistService.cs @@ -113,7 +113,7 @@ public sealed class BlacklistService : IExecOnMessage, IReadyExecutor var items = uow.GetTable<BlacklistEntry>() .Where(x => x.Type != BlacklistType.Server || (x.Type == BlacklistType.Server - && Linq2DbExpressions.GuildOnShard(x.ItemId, totalShards, _client.ShardId))) + && Queries.GuildOnShard(x.ItemId, totalShards, _client.ShardId))) .ToArray(); diff --git a/src/EllieBot/_common/Services/Impl/GuildColorsService.cs b/src/EllieBot/_common/Services/Impl/GuildColorsService.cs index 3c0ff4a..5aa5b7e 100644 --- a/src/EllieBot/_common/Services/Impl/GuildColorsService.cs +++ b/src/EllieBot/_common/Services/Impl/GuildColorsService.cs @@ -117,7 +117,7 @@ public sealed class GuildColorsService : IReadyExecutor, IGuildColorsService, IE { await using var ctx = _db.GetDbContext(); var guildColors = await ctx.GetTable<GuildColors>() - .Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId, + .Where(x => Queries.GuildOnShard(x.GuildId, _creds.TotalShards, _client.ShardId)) .ToListAsync(); diff --git a/src/EllieBot/_common/Services/ShardData.cs b/src/EllieBot/_common/Services/ShardData.cs new file mode 100644 index 0000000..1d51e82 --- /dev/null +++ b/src/EllieBot/_common/Services/ShardData.cs @@ -0,0 +1,19 @@ +namespace EllieBot.Common; + +public sealed class ShardData : IEService +{ + private readonly DiscordSocketClient _client; + private readonly IBotCreds _creds; + + public int TotalShards + => _creds.TotalShards; + + public int ShardId + => _client.ShardId; + + public ShardData(DiscordSocketClient client, IBotCreds creds) + { + _client = client; + _creds = creds; + } +} \ No newline at end of file diff --git a/src/EllieBot/_common/_Extensions/Extensions.cs b/src/EllieBot/_common/_Extensions/Extensions.cs index 5a21861..7ce6482 100644 --- a/src/EllieBot/_common/_Extensions/Extensions.cs +++ b/src/EllieBot/_common/_Extensions/Extensions.cs @@ -59,7 +59,7 @@ public static class Extensions /// <returns>Formatted duration string</returns> public static string ToPrettyStringHm(this TimeSpan span) { - if(span > TimeSpan.FromHours(24)) + if (span > TimeSpan.FromHours(24)) return $"{span.Days:00}d:{span.Hours:00}h"; if (span > TimeSpan.FromMinutes(2)) @@ -228,4 +228,9 @@ public static class Extensions public static IEnumerable<IRole> GetRoles(this IGuildUser user) => user.RoleIds.Select(r => user.Guild.GetRole(r)).Where(r => r is not null); + public static async Task<U> Fmap<T, U>(this Task<T> task, Func<T, U> func) + { + var res = await task; + return func(res); + } } \ No newline at end of file diff --git a/src/EllieBot/data/strings/commands/commands.en-US.yml b/src/EllieBot/data/strings/commands/commands.en-US.yml index 6d2ef7a..66acf0b 100644 --- a/src/EllieBot/data/strings/commands/commands.en-US.yml +++ b/src/EllieBot/data/strings/commands/commands.en-US.yml @@ -354,7 +354,7 @@ sarlist: - page: desc: "The page number to show." sarautodelete: - desc: Toggles the automatic deletion of the user's message and Nadeko's confirmations for `{0}iam` and `{0}iamn` commands. + desc: Toggles the automatic deletion of the user's message and Ellie's confirmations for `{0}iam` and `{0}iamn` commands. ex: - '' params: