From fd210a8d9f82a5c83343780225ebc11b72e07dfc Mon Sep 17 00:00:00 2001 From: Emotion Date: Mon, 7 Aug 2023 21:16:16 +1200 Subject: [PATCH] Updated the Ellie.Bot.Db module --- src/Ellie.Bot.Db/.globalconfig | 1 + src/Ellie.Bot.Db/Extensions/ClubExtensions.cs | 12 +- .../Extensions/GuildConfigExtensions.cs | 6 +- .../MusicPlayerSettingsExtensions.cs | 27 ---- .../Extensions/MusicPlaylistExtensions.cs | 19 --- .../Extensions/QuoteExtensions.cs | 14 +- .../Extensions/ReminderExtensions.cs | 8 +- .../Extensions/WaifuExtensions.cs | 145 ------------------ .../Extensions/WarningExtensions.cs | 30 ++-- src/Ellie.Bot.Db/LevelStats.cs | 2 +- src/Ellie.Bot.Db/Models/AntiProtection.cs | 67 -------- src/Ellie.Bot.Db/Models/AutoPublishChannel.cs | 2 +- src/Ellie.Bot.Db/Models/DbEntity.cs | 2 +- ...dPemOverride.cs => DiscordPermOverride.cs} | 0 src/Ellie.Bot.Db/Models/DiscordUser.cs | 1 - src/Ellie.Bot.Db/Models/FeedSub.cs | 2 +- src/Ellie.Bot.Db/Models/FollowedStream.cs | 1 - src/Ellie.Bot.Db/Models/MusicPlaylist.cs | 10 -- src/Ellie.Bot.Db/Models/MusicSettings.cs | 61 -------- .../Models/StreamOnlineMessage.cs | 2 +- src/Ellie.Bot.Db/Models/Waifu.cs | 33 ---- src/Ellie.Bot.Db/Models/WaifuItem.cs | 10 -- src/Ellie.Bot.Db/Models/WaifuUpdate.cs | 23 --- src/Ellie.Bot.Db/Models/XpShopOwnedItem.cs | 18 --- .../Models/anti/AntiAltSetting.cs | 11 ++ .../Models/anti/AntiRaidSetting.cs | 19 +++ .../Models/anti/AntiSpamIgnore.cs | 12 ++ .../Models/anti/AntiSpamSetting.cs | 13 ++ .../Models/{ => club}/ClubInfo.cs | 0 .../Models/{ => currency}/BankUser.cs | 2 +- .../Models/{ => expr}/EllieExpression.cs | 0 src/Ellie.Bot.Db/Models/{ => expr}/Quote.cs | 1 + .../Models/{ => filter}/FilterChannelId.cs | 0 .../{ => filter}/FilterLinksChannelId.cs | 0 .../Models/{ => filter}/FilteredWord.cs | 0 .../Models/{ => punish}/BanTemplate.cs | 0 .../Models/{ => punish}/MutedUserId.cs | 0 .../Models/{ => punish}/WarnExpireAction.cs | 0 .../Models/{ => punish}/Warning.cs | 0 .../Models/{ => punish}/WarningPunishment.cs | 0 .../{ => slowmode}/SlowmodeIgnoredRole.cs | 4 +- .../{ => slowmode}/SlowmodeIgnoredUser.cs | 0 .../Models/{ => support}/PatronQuota.cs | 2 +- .../RewardUser.cs} | 0 .../Models/{ => untimer}/UnbanTimer.cs | 0 .../Models/{ => untimer}/UnmuteTimer.cs | 0 .../Models/{ => untimer}/UnroleTimer.cs | 0 .../Models/{ => xp}/UserXpStats.cs | 0 .../StreamNotifications/Models/StreamData.cs | 21 +++ 49 files changed, 122 insertions(+), 459 deletions(-) create mode 100644 src/Ellie.Bot.Db/.globalconfig delete mode 100644 src/Ellie.Bot.Db/Extensions/MusicPlayerSettingsExtensions.cs delete mode 100644 src/Ellie.Bot.Db/Extensions/MusicPlaylistExtensions.cs delete mode 100644 src/Ellie.Bot.Db/Extensions/WaifuExtensions.cs delete mode 100644 src/Ellie.Bot.Db/Models/AntiProtection.cs rename src/Ellie.Bot.Db/Models/{DiscordPemOverride.cs => DiscordPermOverride.cs} (100%) delete mode 100644 src/Ellie.Bot.Db/Models/MusicPlaylist.cs delete mode 100644 src/Ellie.Bot.Db/Models/MusicSettings.cs delete mode 100644 src/Ellie.Bot.Db/Models/Waifu.cs delete mode 100644 src/Ellie.Bot.Db/Models/WaifuItem.cs delete mode 100644 src/Ellie.Bot.Db/Models/WaifuUpdate.cs delete mode 100644 src/Ellie.Bot.Db/Models/XpShopOwnedItem.cs create mode 100644 src/Ellie.Bot.Db/Models/anti/AntiAltSetting.cs create mode 100644 src/Ellie.Bot.Db/Models/anti/AntiRaidSetting.cs create mode 100644 src/Ellie.Bot.Db/Models/anti/AntiSpamIgnore.cs create mode 100644 src/Ellie.Bot.Db/Models/anti/AntiSpamSetting.cs rename src/Ellie.Bot.Db/Models/{ => club}/ClubInfo.cs (100%) rename src/Ellie.Bot.Db/Models/{ => currency}/BankUser.cs (76%) rename src/Ellie.Bot.Db/Models/{ => expr}/EllieExpression.cs (100%) rename src/Ellie.Bot.Db/Models/{ => expr}/Quote.cs (99%) rename src/Ellie.Bot.Db/Models/{ => filter}/FilterChannelId.cs (100%) rename src/Ellie.Bot.Db/Models/{ => filter}/FilterLinksChannelId.cs (100%) rename src/Ellie.Bot.Db/Models/{ => filter}/FilteredWord.cs (100%) rename src/Ellie.Bot.Db/Models/{ => punish}/BanTemplate.cs (100%) rename src/Ellie.Bot.Db/Models/{ => punish}/MutedUserId.cs (100%) rename src/Ellie.Bot.Db/Models/{ => punish}/WarnExpireAction.cs (100%) rename src/Ellie.Bot.Db/Models/{ => punish}/Warning.cs (100%) rename src/Ellie.Bot.Db/Models/{ => punish}/WarningPunishment.cs (100%) rename src/Ellie.Bot.Db/Models/{ => slowmode}/SlowmodeIgnoredRole.cs (97%) rename src/Ellie.Bot.Db/Models/{ => slowmode}/SlowmodeIgnoredUser.cs (100%) rename src/Ellie.Bot.Db/Models/{ => support}/PatronQuota.cs (98%) rename src/Ellie.Bot.Db/Models/{RewardedUser.cs => support/RewardUser.cs} (100%) rename src/Ellie.Bot.Db/Models/{ => untimer}/UnbanTimer.cs (100%) rename src/Ellie.Bot.Db/Models/{ => untimer}/UnmuteTimer.cs (100%) rename src/Ellie.Bot.Db/Models/{ => untimer}/UnroleTimer.cs (100%) rename src/Ellie.Bot.Db/Models/{ => xp}/UserXpStats.cs (100%) create mode 100644 src/Ellie.Bot.Modules.Searches/_common/StreamNotifications/Models/StreamData.cs diff --git a/src/Ellie.Bot.Db/.globalconfig b/src/Ellie.Bot.Db/.globalconfig new file mode 100644 index 0000000..5e750a2 --- /dev/null +++ b/src/Ellie.Bot.Db/.globalconfig @@ -0,0 +1 @@ +dotnet_diagnostic.CS8981.severity = none \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Extensions/ClubExtensions.cs b/src/Ellie.Bot.Db/Extensions/ClubExtensions.cs index be40d67..0e5a419 100644 --- a/src/Ellie.Bot.Db/Extensions/ClubExtensions.cs +++ b/src/Ellie.Bot.Db/Extensions/ClubExtensions.cs @@ -8,12 +8,12 @@ public static class ClubExtensions { private static IQueryable Include(this DbSet clubs) => clubs.Include(x => x.Owner) - .Include(x => x.Applicants) - .ThenInclude(x => x.User) - .Include(x => x.Bans) - .ThenInclude(x => x.User) - .Include(x => x.Members) - .AsQueryable(); + .Include(x => x.Applicants) + .ThenInclude(x => x.User) + .Include(x => x.Bans) + .ThenInclude(x => x.User) + .Include(x => x.Members) + .AsQueryable(); public static ClubInfo GetByOwner(this DbSet clubs, ulong userId) => Include(clubs).FirstOrDefault(c => c.Owner.UserId == userId); diff --git a/src/Ellie.Bot.Db/Extensions/GuildConfigExtensions.cs b/src/Ellie.Bot.Db/Extensions/GuildConfigExtensions.cs index da7ff8f..cb2da22 100644 --- a/src/Ellie.Bot.Db/Extensions/GuildConfigExtensions.cs +++ b/src/Ellie.Bot.Db/Extensions/GuildConfigExtensions.cs @@ -29,7 +29,7 @@ public static class GuildConfigExtensions /// Db Context /// Id of the guild to get stream role settings for. /// Guild'p stream role settings - public static StreamRoleSettings GetStreamRoleSettings(this EllieBaseContext ctx, ulong guildId) + public static StreamRoleSettings GetStreamRoleSettings(this DbContext ctx, ulong guildId) { var conf = ctx.GuildConfigsForId(guildId, set => set.Include(y => y.StreamRole) @@ -120,7 +120,7 @@ public static class GuildConfigExtensions // .First(x => x.GuildId == guildId); } - public static LogSetting LogSettingsFor(this EllieBaseContext ctx, ulong guildId) + public static LogSetting LogSettingsFor(this DbContext ctx, ulong guildId) { var logSetting = ctx.Set() .AsQueryable() @@ -148,7 +148,7 @@ public static class GuildConfigExtensions return query.ToList(); } - public static GuildConfig GcWithPermissionsFor(this EllieBaseContext ctx, ulong guildId) + public static GuildConfig GcWithPermissionsFor(this DbContext ctx, ulong guildId) { var config = ctx.Set().AsQueryable() .Where(gc => gc.GuildId == guildId) diff --git a/src/Ellie.Bot.Db/Extensions/MusicPlayerSettingsExtensions.cs b/src/Ellie.Bot.Db/Extensions/MusicPlayerSettingsExtensions.cs deleted file mode 100644 index 5fa94ac..0000000 --- a/src/Ellie.Bot.Db/Extensions/MusicPlayerSettingsExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -#nullable disable -using Microsoft.EntityFrameworkCore; -using Ellie.Services.Database.Models; - -namespace Ellie.Db; - -public static class MusicPlayerSettingsExtensions -{ - public static async Task ForGuildAsync(this DbSet settings, ulong guildId) - { - var toReturn = await settings.AsQueryable().FirstOrDefaultAsync(x => x.GuildId == guildId); - - if (toReturn is null) - { - var newSettings = new MusicPlayerSettings - { - GuildId = guildId, - PlayerRepeat = PlayerRepeatType.Queue - }; - - await settings.AddAsync(newSettings); - return newSettings; - } - - return toReturn; - } -} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Extensions/MusicPlaylistExtensions.cs b/src/Ellie.Bot.Db/Extensions/MusicPlaylistExtensions.cs deleted file mode 100644 index c140b4b..0000000 --- a/src/Ellie.Bot.Db/Extensions/MusicPlaylistExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -#nullable disable -using Microsoft.EntityFrameworkCore; -using Ellie.Services.Database.Models; - -namespace Ellie.Db; - -public static class MusicPlaylistExtensions -{ - public static List GetPlaylistsOnPage(this DbSet playlists, int num) - { - if (num < 1) - throw new ArgumentOutOfRangeException(nameof(num)); - - return playlists.AsQueryable().Skip((num - 1) * 20).Take(20).Include(pl => pl.Songs).ToList(); - } - - public static MusicPlaylist GetWithSongs(this DbSet playlists, int id) - => playlists.Include(mpl => mpl.Songs).FirstOrDefault(mpl => mpl.Id == id); -} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Extensions/QuoteExtensions.cs b/src/Ellie.Bot.Db/Extensions/QuoteExtensions.cs index 6f6bb6a..5b6a4bd 100644 --- a/src/Ellie.Bot.Db/Extensions/QuoteExtensions.cs +++ b/src/Ellie.Bot.Db/Extensions/QuoteExtensions.cs @@ -43,13 +43,13 @@ public static class QuoteExtensions { var rngk = new EllieRandom(); return (await quotes.AsQueryable() - .Where(q => q.GuildId == guildId - && (keyword == null || q.Keyword == keyword) - && (EF.Functions.Like(q.Text.ToUpper(), $"%{text.ToUpper()}%") - || EF.Functions.Like(q.AuthorName, text))) - .ToListAsync()) - .OrderBy(_ => rngk.Next()) - .FirstOrDefault(); + .Where(q => q.GuildId == guildId + && (keyword == null || q.Keyword == keyword) + && (EF.Functions.Like(q.Text.ToUpper(), $"%{text.ToUpper()}%") + || EF.Functions.Like(q.AuthorName, text))) + .ToListAsync()) + .OrderBy(_ => rngk.Next()) + .FirstOrDefault(); } public static void RemoveAllByKeyword(this DbSet quotes, ulong guildId, string keyword) diff --git a/src/Ellie.Bot.Db/Extensions/ReminderExtensions.cs b/src/Ellie.Bot.Db/Extensions/ReminderExtensions.cs index cd64d29..8ce2273 100644 --- a/src/Ellie.Bot.Db/Extensions/ReminderExtensions.cs +++ b/src/Ellie.Bot.Db/Extensions/ReminderExtensions.cs @@ -16,8 +16,8 @@ public static class ReminderExtensions public static IEnumerable RemindersForServer(this DbSet reminders, ulong serverId, int page) => reminders.AsQueryable() - .Where(x => x.ServerId == serverId) - .OrderBy(x => x.DateAdded) - .Skip(page * 10) - .Take(10); + .Where(x => x.ServerId == serverId) + .OrderBy(x => x.DateAdded) + .Skip(page * 10) + .Take(10); } \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Extensions/WaifuExtensions.cs b/src/Ellie.Bot.Db/Extensions/WaifuExtensions.cs deleted file mode 100644 index 1f3e73f..0000000 --- a/src/Ellie.Bot.Db/Extensions/WaifuExtensions.cs +++ /dev/null @@ -1,145 +0,0 @@ -#nullable disable -using LinqToDB; -using LinqToDB.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Ellie.Db.Models; -using Ellie.Services.Database; -using Ellie.Services.Database.Models; - -namespace Ellie.Db; - -public class WaifuInfoStats -{ - public int WaifuId { get; init; } - public string FullName { get; init; } - public long Price { get; init; } - public string ClaimerName { get; init; } - public string AffinityName { get; init; } - public int AffinityCount { get; init; } - public int DivorceCount { get; init; } - public int ClaimCount { get; init; } -} - -public static class WaifuExtensions -{ - public static WaifuInfo ByWaifuUserId( - this DbSet waifus, - ulong userId, - Func, IQueryable> includes = null) - { - if (includes is null) - { - return waifus.Include(wi => wi.Waifu) - .Include(wi => wi.Affinity) - .Include(wi => wi.Claimer) - .Include(wi => wi.Items) - .FirstOrDefault(wi => wi.Waifu.UserId == userId); - } - - return includes(waifus).AsQueryable().FirstOrDefault(wi => wi.Waifu.UserId == userId); - } - - public static IEnumerable GetTop(this DbSet waifus, int count, int skip = 0) - { - if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - if (count == 0) - return new List(); - - return waifus.Include(wi => wi.Waifu) - .Include(wi => wi.Affinity) - .Include(wi => wi.Claimer) - .OrderByDescending(wi => wi.Price) - .Skip(skip) - .Take(count) - .Select(x => new WaifuLbResult - { - Affinity = x.Affinity == null ? null : x.Affinity.Username, - AffinityDiscrim = x.Affinity == null ? null : x.Affinity.Discriminator, - Claimer = x.Claimer == null ? null : x.Claimer.Username, - ClaimerDiscrim = x.Claimer == null ? null : x.Claimer.Discriminator, - Username = x.Waifu.Username, - Discrim = x.Waifu.Discriminator, - Price = x.Price - }) - .ToList(); - } - - public static decimal GetTotalValue(this DbSet waifus) - => waifus.AsQueryable().Where(x => x.ClaimerId != null).Sum(x => x.Price); - - public static ulong GetWaifuUserId(this DbSet waifus, ulong ownerId, string name) - => waifus.AsQueryable() - .AsNoTracking() - .Where(x => x.Claimer.UserId == ownerId && x.Waifu.Username + "#" + x.Waifu.Discriminator == name) - .Select(x => x.Waifu.UserId) - .FirstOrDefault(); - - public static async Task GetWaifuInfoAsync(this DbContext ctx, ulong userId) - { - await ctx.Set() - .ToLinqToDBTable() - .InsertOrUpdateAsync(() => new() - { - AffinityId = null, - ClaimerId = null, - Price = 1, - WaifuId = ctx.Set().Where(x => x.UserId == userId).Select(x => x.Id).First() - }, - _ => new(), - () => new() - { - WaifuId = ctx.Set().Where(x => x.UserId == userId).Select(x => x.Id).First() - }); - - var toReturn = ctx.Set().AsQueryable() - .Where(w => w.WaifuId - == ctx.Set() - .AsQueryable() - .Where(u => u.UserId == userId) - .Select(u => u.Id) - .FirstOrDefault()) - .Select(w => new WaifuInfoStats - { - WaifuId = w.WaifuId, - FullName = - ctx.Set() - .AsQueryable() - .Where(u => u.UserId == userId) - .Select(u => u.Username + "#" + u.Discriminator) - .FirstOrDefault(), - AffinityCount = - ctx.Set() - .AsQueryable() - .Count(x => x.UserId == w.WaifuId - && x.UpdateType == WaifuUpdateType.AffinityChanged - && x.NewId != null), - AffinityName = - ctx.Set() - .AsQueryable() - .Where(u => u.Id == w.AffinityId) - .Select(u => u.Username + "#" + u.Discriminator) - .FirstOrDefault(), - ClaimCount = ctx.Set().AsQueryable().Count(x => x.ClaimerId == w.WaifuId), - ClaimerName = - ctx.Set() - .AsQueryable() - .Where(u => u.Id == w.ClaimerId) - .Select(u => u.Username + "#" + u.Discriminator) - .FirstOrDefault(), - DivorceCount = - ctx.Set() - .AsQueryable() - .Count(x => x.OldId == w.WaifuId - && x.NewId == null - && x.UpdateType == WaifuUpdateType.Claimed), - Price = w.Price, - }) - .FirstOrDefault(); - - if (toReturn is null) - return null; - - return toReturn; - } -} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Extensions/WarningExtensions.cs b/src/Ellie.Bot.Db/Extensions/WarningExtensions.cs index 31275b9..ccb1b72 100644 --- a/src/Ellie.Bot.Db/Extensions/WarningExtensions.cs +++ b/src/Ellie.Bot.Db/Extensions/WarningExtensions.cs @@ -9,8 +9,8 @@ public static class WarningExtensions public static Warning[] ForId(this DbSet warnings, ulong guildId, ulong userId) { var query = warnings.AsQueryable() - .Where(x => x.GuildId == guildId && x.UserId == userId) - .OrderByDescending(x => x.DateAdded); + .Where(x => x.GuildId == guildId && x.UserId == userId) + .OrderByDescending(x => x.DateAdded); return query.ToArray(); } @@ -26,10 +26,10 @@ public static class WarningExtensions throw new ArgumentOutOfRangeException(nameof(index)); var warn = warnings.AsQueryable() - .Where(x => x.GuildId == guildId && x.UserId == userId) - .OrderByDescending(x => x.DateAdded) - .Skip(index) - .FirstOrDefault(); + .Where(x => x.GuildId == guildId && x.UserId == userId) + .OrderByDescending(x => x.DateAdded) + .Skip(index) + .FirstOrDefault(); if (warn is null || warn.Forgiven) return false; @@ -45,15 +45,15 @@ public static class WarningExtensions ulong userId, string mod) => await warnings.AsQueryable() - .Where(x => x.GuildId == guildId && x.UserId == userId) - .ForEachAsync(x => - { - if (x.Forgiven != true) - { - x.Forgiven = true; - x.ForgivenBy = mod; - } - }); + .Where(x => x.GuildId == guildId && x.UserId == userId) + .ForEachAsync(x => + { + if (x.Forgiven != true) + { + x.Forgiven = true; + x.ForgivenBy = mod; + } + }); public static Warning[] GetForGuild(this DbSet warnings, ulong id) => warnings.AsQueryable().Where(x => x.GuildId == id).ToArray(); diff --git a/src/Ellie.Bot.Db/LevelStats.cs b/src/Ellie.Bot.Db/LevelStats.cs index 5ae7349..738794f 100644 --- a/src/Ellie.Bot.Db/LevelStats.cs +++ b/src/Ellie.Bot.Db/LevelStats.cs @@ -38,4 +38,4 @@ public readonly struct LevelStats LevelXp = xp - totalXp; RequiredXp = required; } -} +} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/AntiProtection.cs b/src/Ellie.Bot.Db/Models/AntiProtection.cs deleted file mode 100644 index fe27693..0000000 --- a/src/Ellie.Bot.Db/Models/AntiProtection.cs +++ /dev/null @@ -1,67 +0,0 @@ -#nullable disable -namespace Ellie.Services.Database.Models; - - -// todo db required, nullable? -public class AntiRaidSetting : DbEntity -{ - public int GuildConfigId { get; set; } - public GuildConfig GuildConfig { get; set; } - - public int UserThreshold { get; set; } - public int Seconds { get; set; } - public PunishmentAction Action { get; set; } - - /// - /// Duration of the punishment, in minutes. This works only for supported Actions, like: - /// Mute, Chatmute, Voicemute, etc... - /// - public int PunishDuration { get; set; } -} - -public class AntiSpamSetting : DbEntity -{ - public int GuildConfigId { get; set; } - public GuildConfig GuildConfig { 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 IgnoredChannels { get; set; } = new(); -} - -public class AntiAltSetting -{ - public int Id { get; set; } - public int GuildConfigId { get; set; } - public TimeSpan MinAge { get; set; } - public PunishmentAction Action { get; set; } - public int ActionDurationMinutes { get; set; } - public ulong? RoleId { get; set; } -} - -public enum PunishmentAction -{ - Mute, - Kick, - Ban, - Softban, - RemoveRoles, - ChatMute, - VoiceMute, - AddRole, - Warn, - TimeOut -} - -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 : false; -} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/AutoPublishChannel.cs b/src/Ellie.Bot.Db/Models/AutoPublishChannel.cs index 7ad898d..6b364fa 100644 --- a/src/Ellie.Bot.Db/Models/AutoPublishChannel.cs +++ b/src/Ellie.Bot.Db/Models/AutoPublishChannel.cs @@ -2,7 +2,7 @@ using Ellie.Services.Database.Models; namespace Ellie.Db.Models; -public class AutoPublishChannel : DbEntity +public class AutoPublishChannel { public ulong GuildId { get; set; } public ulong ChannelId { get; set; } diff --git a/src/Ellie.Bot.Db/Models/DbEntity.cs b/src/Ellie.Bot.Db/Models/DbEntity.cs index 095516c..369bcbf 100644 --- a/src/Ellie.Bot.Db/Models/DbEntity.cs +++ b/src/Ellie.Bot.Db/Models/DbEntity.cs @@ -7,6 +7,6 @@ public class DbEntity { [Key] public int Id { get; set; } - + public DateTime? DateAdded { get; set; } = DateTime.UtcNow; } \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/DiscordPemOverride.cs b/src/Ellie.Bot.Db/Models/DiscordPermOverride.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/DiscordPemOverride.cs rename to src/Ellie.Bot.Db/Models/DiscordPermOverride.cs diff --git a/src/Ellie.Bot.Db/Models/DiscordUser.cs b/src/Ellie.Bot.Db/Models/DiscordUser.cs index c3fa32b..d62dbc9 100644 --- a/src/Ellie.Bot.Db/Models/DiscordUser.cs +++ b/src/Ellie.Bot.Db/Models/DiscordUser.cs @@ -3,7 +3,6 @@ using Ellie.Services.Database.Models; namespace Ellie.Db.Models; - // FUTURE remove LastLevelUp from here and UserXpStats public class DiscordUser : DbEntity { diff --git a/src/Ellie.Bot.Db/Models/FeedSub.cs b/src/Ellie.Bot.Db/Models/FeedSub.cs index fabac6e..65578fe 100644 --- a/src/Ellie.Bot.Db/Models/FeedSub.cs +++ b/src/Ellie.Bot.Db/Models/FeedSub.cs @@ -16,4 +16,4 @@ public class FeedSub : DbEntity public override bool Equals(object obj) => obj is FeedSub s && s.Url.ToLower() == Url.ToLower() && s.GuildConfigId == GuildConfigId; -} \ No newline at end of file +} diff --git a/src/Ellie.Bot.Db/Models/FollowedStream.cs b/src/Ellie.Bot.Db/Models/FollowedStream.cs index 2772a20..f4ef3d6 100644 --- a/src/Ellie.Bot.Db/Models/FollowedStream.cs +++ b/src/Ellie.Bot.Db/Models/FollowedStream.cs @@ -30,6 +30,5 @@ public class FollowedStream : DbEntity public override bool Equals(object obj) => obj is FollowedStream fs && Equals(fs); - } \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/MusicPlaylist.cs b/src/Ellie.Bot.Db/Models/MusicPlaylist.cs deleted file mode 100644 index 178c09e..0000000 --- a/src/Ellie.Bot.Db/Models/MusicPlaylist.cs +++ /dev/null @@ -1,10 +0,0 @@ -#nullable disable -namespace Ellie.Services.Database.Models; - -public class MusicPlaylist : DbEntity -{ - public string Name { get; set; } - public string Author { get; set; } - public ulong AuthorId { get; set; } - public List Songs { get; set; } = new(); -} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/MusicSettings.cs b/src/Ellie.Bot.Db/Models/MusicSettings.cs deleted file mode 100644 index 37d195a..0000000 --- a/src/Ellie.Bot.Db/Models/MusicSettings.cs +++ /dev/null @@ -1,61 +0,0 @@ -#nullable disable -namespace Ellie.Services.Database.Models; - -public class MusicPlayerSettings -{ - /// - /// Auto generated Id - /// - public int Id { get; set; } - - /// - /// Id of the guild - /// - public ulong GuildId { get; set; } - - /// - /// Queue repeat type - /// - public PlayerRepeatType PlayerRepeat { get; set; } = PlayerRepeatType.Queue; - - /// - /// Channel id the bot will always try to send track related messages to - /// - public ulong? MusicChannelId { get; set; } - - /// - /// Default volume player will be created with - /// - public int Volume { get; set; } = 100; - - /// - /// Whether the bot should auto disconnect from the voice channel once the queue is done - /// This only has effect if - /// - public bool AutoDisconnect { get; set; } - - /// - /// Selected quality preset for the music player - /// - public QualityPreset QualityPreset { get; set; } - - /// - /// Whether the bot will automatically queue related songs - /// - public bool AutoPlay { get; set; } -} - -public enum QualityPreset -{ - Highest, - High, - Medium, - Low -} - -public enum PlayerRepeatType -{ - None, - Track, - Queue -} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/StreamOnlineMessage.cs b/src/Ellie.Bot.Db/Models/StreamOnlineMessage.cs index 6b15750..ef6389e 100644 --- a/src/Ellie.Bot.Db/Models/StreamOnlineMessage.cs +++ b/src/Ellie.Bot.Db/Models/StreamOnlineMessage.cs @@ -1,4 +1,4 @@ -#nullable disable +#nullable disable using Ellie.Services.Database.Models; namespace Ellie.Db.Models; diff --git a/src/Ellie.Bot.Db/Models/Waifu.cs b/src/Ellie.Bot.Db/Models/Waifu.cs deleted file mode 100644 index b357499..0000000 --- a/src/Ellie.Bot.Db/Models/Waifu.cs +++ /dev/null @@ -1,33 +0,0 @@ -#nullable disable -using Ellie.Db.Models; - -namespace Ellie.Services.Database.Models; - -public class WaifuInfo : DbEntity -{ - public int WaifuId { get; set; } - public DiscordUser Waifu { get; set; } - - public int? ClaimerId { get; set; } - public DiscordUser Claimer { get; set; } - - public int? AffinityId { get; set; } - public DiscordUser Affinity { get; set; } - - public long Price { get; set; } - public List Items { get; set; } = new(); -} - -public class WaifuLbResult -{ - public string Username { get; set; } - public string Discrim { get; set; } - - public string Claimer { get; set; } - public string ClaimerDiscrim { get; set; } - - public string Affinity { get; set; } - public string AffinityDiscrim { get; set; } - - public long Price { get; set; } -} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/WaifuItem.cs b/src/Ellie.Bot.Db/Models/WaifuItem.cs deleted file mode 100644 index 95491c8..0000000 --- a/src/Ellie.Bot.Db/Models/WaifuItem.cs +++ /dev/null @@ -1,10 +0,0 @@ -#nullable disable -namespace Ellie.Services.Database.Models; - -public class WaifuItem : DbEntity -{ - public WaifuInfo WaifuInfo { get; set; } - public int? WaifuInfoId { get; set; } - public string ItemEmoji { get; set; } - public string Name { get; set; } -} diff --git a/src/Ellie.Bot.Db/Models/WaifuUpdate.cs b/src/Ellie.Bot.Db/Models/WaifuUpdate.cs deleted file mode 100644 index 28255db..0000000 --- a/src/Ellie.Bot.Db/Models/WaifuUpdate.cs +++ /dev/null @@ -1,23 +0,0 @@ -#nullable disable -using Ellie.Db.Models; - -namespace Ellie.Services.Database.Models; - -public class WaifuUpdate : DbEntity -{ - public int UserId { get; set; } - public DiscordUser User { get; set; } - public WaifuUpdateType UpdateType { get; set; } - - public int? OldId { get; set; } - public DiscordUser Old { get; set; } - - public int? NewId { get; set; } - public DiscordUser New { get; set; } -} - -public enum WaifuUpdateType -{ - AffinityChanged, - Claimed -} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/XpShopOwnedItem.cs b/src/Ellie.Bot.Db/Models/XpShopOwnedItem.cs deleted file mode 100644 index affd086..0000000 --- a/src/Ellie.Bot.Db/Models/XpShopOwnedItem.cs +++ /dev/null @@ -1,18 +0,0 @@ -#nullable disable warnings -using Ellie.Services.Database.Models; - -namespace Ellie.Db.Models; - -public class XpShopOwnedItem : DbEntity -{ - public ulong UserId { get; set; } - public XpShopItemType ItemType { get; set; } - public bool IsUsing { get; set; } - public string ItemKey { get; set; } -} - -public enum XpShopItemType -{ - Background = 0, - Frame = 1, -} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/anti/AntiAltSetting.cs b/src/Ellie.Bot.Db/Models/anti/AntiAltSetting.cs new file mode 100644 index 0000000..6fde1b4 --- /dev/null +++ b/src/Ellie.Bot.Db/Models/anti/AntiAltSetting.cs @@ -0,0 +1,11 @@ +namespace Ellie.Services.Database.Models; + +public class AntiAltSetting +{ + public int Id { get; set; } + public int GuildConfigId { get; set; } + public TimeSpan MinAge { get; set; } + public PunishmentAction Action { get; set; } + public int ActionDurationMinutes { get; set; } + public ulong? RoleId { get; set; } +} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/anti/AntiRaidSetting.cs b/src/Ellie.Bot.Db/Models/anti/AntiRaidSetting.cs new file mode 100644 index 0000000..1e90f63 --- /dev/null +++ b/src/Ellie.Bot.Db/Models/anti/AntiRaidSetting.cs @@ -0,0 +1,19 @@ +#nullable disable +namespace Ellie.Services.Database.Models; + +// todo db required, nullable? +public class AntiRaidSetting : DbEntity +{ + public int GuildConfigId { get; set; } + public GuildConfig GuildConfig { get; set; } + + public int UserThreshold { get; set; } + public int Seconds { get; set; } + public PunishmentAction Action { get; set; } + + /// + /// Duration of the punishment, in minutes. This works only for supported Actions, like: + /// Mute, Chatmute, Voicemute, etc... + /// + public int PunishDuration { get; set; } +} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/anti/AntiSpamIgnore.cs b/src/Ellie.Bot.Db/Models/anti/AntiSpamIgnore.cs new file mode 100644 index 0000000..c9fff4d --- /dev/null +++ b/src/Ellie.Bot.Db/Models/anti/AntiSpamIgnore.cs @@ -0,0 +1,12 @@ +namespace Ellie.Services.Database.Models; + +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 : false; +} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/anti/AntiSpamSetting.cs b/src/Ellie.Bot.Db/Models/anti/AntiSpamSetting.cs new file mode 100644 index 0000000..70d41bd --- /dev/null +++ b/src/Ellie.Bot.Db/Models/anti/AntiSpamSetting.cs @@ -0,0 +1,13 @@ +namespace Ellie.Services.Database.Models; + +public class AntiSpamSetting : DbEntity +{ + public int GuildConfigId { get; set; } + public GuildConfig GuildConfig { 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 IgnoredChannels { get; set; } = new(); +} \ No newline at end of file diff --git a/src/Ellie.Bot.Db/Models/ClubInfo.cs b/src/Ellie.Bot.Db/Models/club/ClubInfo.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/ClubInfo.cs rename to src/Ellie.Bot.Db/Models/club/ClubInfo.cs diff --git a/src/Ellie.Bot.Db/Models/BankUser.cs b/src/Ellie.Bot.Db/Models/currency/BankUser.cs similarity index 76% rename from src/Ellie.Bot.Db/Models/BankUser.cs rename to src/Ellie.Bot.Db/Models/currency/BankUser.cs index 5ad0846..425b4d7 100644 --- a/src/Ellie.Bot.Db/Models/BankUser.cs +++ b/src/Ellie.Bot.Db/Models/currency/BankUser.cs @@ -1,4 +1,4 @@ -using Ellie.Services.Database.Models; +using Ellie.Services.Database.Models; namespace Ellie.Db.Models; diff --git a/src/Ellie.Bot.Db/Models/EllieExpression.cs b/src/Ellie.Bot.Db/Models/expr/EllieExpression.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/EllieExpression.cs rename to src/Ellie.Bot.Db/Models/expr/EllieExpression.cs diff --git a/src/Ellie.Bot.Db/Models/Quote.cs b/src/Ellie.Bot.Db/Models/expr/Quote.cs similarity index 99% rename from src/Ellie.Bot.Db/Models/Quote.cs rename to src/Ellie.Bot.Db/Models/expr/Quote.cs index 6ec60d7..2cc0c1a 100644 --- a/src/Ellie.Bot.Db/Models/Quote.cs +++ b/src/Ellie.Bot.Db/Models/expr/Quote.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations; namespace Ellie.Services.Database.Models; + public class Quote : DbEntity { public ulong GuildId { get; set; } diff --git a/src/Ellie.Bot.Db/Models/FilterChannelId.cs b/src/Ellie.Bot.Db/Models/filter/FilterChannelId.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/FilterChannelId.cs rename to src/Ellie.Bot.Db/Models/filter/FilterChannelId.cs diff --git a/src/Ellie.Bot.Db/Models/FilterLinksChannelId.cs b/src/Ellie.Bot.Db/Models/filter/FilterLinksChannelId.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/FilterLinksChannelId.cs rename to src/Ellie.Bot.Db/Models/filter/FilterLinksChannelId.cs diff --git a/src/Ellie.Bot.Db/Models/FilteredWord.cs b/src/Ellie.Bot.Db/Models/filter/FilteredWord.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/FilteredWord.cs rename to src/Ellie.Bot.Db/Models/filter/FilteredWord.cs diff --git a/src/Ellie.Bot.Db/Models/BanTemplate.cs b/src/Ellie.Bot.Db/Models/punish/BanTemplate.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/BanTemplate.cs rename to src/Ellie.Bot.Db/Models/punish/BanTemplate.cs diff --git a/src/Ellie.Bot.Db/Models/MutedUserId.cs b/src/Ellie.Bot.Db/Models/punish/MutedUserId.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/MutedUserId.cs rename to src/Ellie.Bot.Db/Models/punish/MutedUserId.cs diff --git a/src/Ellie.Bot.Db/Models/WarnExpireAction.cs b/src/Ellie.Bot.Db/Models/punish/WarnExpireAction.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/WarnExpireAction.cs rename to src/Ellie.Bot.Db/Models/punish/WarnExpireAction.cs diff --git a/src/Ellie.Bot.Db/Models/Warning.cs b/src/Ellie.Bot.Db/Models/punish/Warning.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/Warning.cs rename to src/Ellie.Bot.Db/Models/punish/Warning.cs diff --git a/src/Ellie.Bot.Db/Models/WarningPunishment.cs b/src/Ellie.Bot.Db/Models/punish/WarningPunishment.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/WarningPunishment.cs rename to src/Ellie.Bot.Db/Models/punish/WarningPunishment.cs diff --git a/src/Ellie.Bot.Db/Models/SlowmodeIgnoredRole.cs b/src/Ellie.Bot.Db/Models/slowmode/SlowmodeIgnoredRole.cs similarity index 97% rename from src/Ellie.Bot.Db/Models/SlowmodeIgnoredRole.cs rename to src/Ellie.Bot.Db/Models/slowmode/SlowmodeIgnoredRole.cs index 6ab743b..011eacd 100644 --- a/src/Ellie.Bot.Db/Models/SlowmodeIgnoredRole.cs +++ b/src/Ellie.Bot.Db/Models/slowmode/SlowmodeIgnoredRole.cs @@ -4,7 +4,7 @@ namespace Ellie.Services.Database.Models; public class SlowmodeIgnoredRole : DbEntity { public ulong RoleId { get; set; } - + // override object.Equals public override bool Equals(object obj) { @@ -13,7 +13,7 @@ public class SlowmodeIgnoredRole : DbEntity return ((SlowmodeIgnoredRole)obj).RoleId == RoleId; } - + // override object.GetHashCode public override int GetHashCode() => RoleId.GetHashCode(); diff --git a/src/Ellie.Bot.Db/Models/SlowmodeIgnoredUser.cs b/src/Ellie.Bot.Db/Models/slowmode/SlowmodeIgnoredUser.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/SlowmodeIgnoredUser.cs rename to src/Ellie.Bot.Db/Models/slowmode/SlowmodeIgnoredUser.cs diff --git a/src/Ellie.Bot.Db/Models/PatronQuota.cs b/src/Ellie.Bot.Db/Models/support/PatronQuota.cs similarity index 98% rename from src/Ellie.Bot.Db/Models/PatronQuota.cs rename to src/Ellie.Bot.Db/Models/support/PatronQuota.cs index c4ca0fc..afbb5bb 100644 --- a/src/Ellie.Bot.Db/Models/PatronQuota.cs +++ b/src/Ellie.Bot.Db/Models/support/PatronQuota.cs @@ -1,4 +1,4 @@ -#nullable disable +#nullable disable namespace Ellie.Db.Models; /// diff --git a/src/Ellie.Bot.Db/Models/RewardedUser.cs b/src/Ellie.Bot.Db/Models/support/RewardUser.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/RewardedUser.cs rename to src/Ellie.Bot.Db/Models/support/RewardUser.cs diff --git a/src/Ellie.Bot.Db/Models/UnbanTimer.cs b/src/Ellie.Bot.Db/Models/untimer/UnbanTimer.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/UnbanTimer.cs rename to src/Ellie.Bot.Db/Models/untimer/UnbanTimer.cs diff --git a/src/Ellie.Bot.Db/Models/UnmuteTimer.cs b/src/Ellie.Bot.Db/Models/untimer/UnmuteTimer.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/UnmuteTimer.cs rename to src/Ellie.Bot.Db/Models/untimer/UnmuteTimer.cs diff --git a/src/Ellie.Bot.Db/Models/UnroleTimer.cs b/src/Ellie.Bot.Db/Models/untimer/UnroleTimer.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/UnroleTimer.cs rename to src/Ellie.Bot.Db/Models/untimer/UnroleTimer.cs diff --git a/src/Ellie.Bot.Db/Models/UserXpStats.cs b/src/Ellie.Bot.Db/Models/xp/UserXpStats.cs similarity index 100% rename from src/Ellie.Bot.Db/Models/UserXpStats.cs rename to src/Ellie.Bot.Db/Models/xp/UserXpStats.cs diff --git a/src/Ellie.Bot.Modules.Searches/_common/StreamNotifications/Models/StreamData.cs b/src/Ellie.Bot.Modules.Searches/_common/StreamNotifications/Models/StreamData.cs new file mode 100644 index 0000000..3e17356 --- /dev/null +++ b/src/Ellie.Bot.Modules.Searches/_common/StreamNotifications/Models/StreamData.cs @@ -0,0 +1,21 @@ +#nullable disable +using Ellie.Db.Models; + +namespace Ellie.Modules.Searches.Common; + +public record StreamData +{ + public FollowedStream.FType StreamType { get; set; } + public string Name { get; set; } + public string UniqueName { get; set; } + public int Viewers { get; set; } + public string Title { get; set; } + public string Game { get; set; } + public string Preview { get; set; } + public bool IsLive { get; set; } + public string StreamUrl { get; set; } + public string AvatarUrl { get; set; } + + public StreamDataKey CreateKey() + => new(StreamType, UniqueName.ToLower()); +} \ No newline at end of file