Restructured the project structure back to the way it was, there's no reasonable way to split the modules

This commit is contained in:
Kwoth
2024-04-26 22:26:24 +00:00
parent 6c9c8bf63e
commit e0819f760c
768 changed files with 192 additions and 1047 deletions

View File

@@ -0,0 +1,14 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class AutoCommand : DbEntity
{
public string CommandText { get; set; }
public ulong ChannelId { get; set; }
public string ChannelName { get; set; }
public ulong? GuildId { get; set; }
public string GuildName { get; set; }
public ulong? VoiceChannelId { get; set; }
public string VoiceChannelName { get; set; }
public int Interval { get; set; }
}

View File

@@ -0,0 +1,9 @@
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db.Models;
public class AutoPublishChannel : DbEntity
{
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
}

View File

@@ -0,0 +1,10 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class AutoTranslateChannel : DbEntity
{
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
public bool AutoDelete { get; set; }
public IList<AutoTranslateUser> Users { get; set; } = new List<AutoTranslateUser>();
}

View File

@@ -0,0 +1,11 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class AutoTranslateUser : DbEntity
{
public int ChannelId { get; set; }
public AutoTranslateChannel Channel { get; set; }
public ulong UserId { get; set; }
public string Source { get; set; }
public string Target { get; set; }
}

View File

@@ -0,0 +1,15 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class BlacklistEntry : DbEntity
{
public ulong ItemId { get; set; }
public BlacklistType Type { get; set; }
}
public enum BlacklistType
{
Server,
Channel,
User
}

View File

@@ -0,0 +1,8 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class CommandAlias : DbEntity
{
public string Trigger { get; set; }
public string Mapping { get; set; }
}

View File

@@ -0,0 +1,8 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class CommandCooldown : DbEntity
{
public int Seconds { get; set; }
public string CommandName { get; set; }
}

View File

@@ -0,0 +1,12 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class CurrencyTransaction : DbEntity
{
public long Amount { get; set; }
public string Note { get; set; }
public ulong UserId { get; set; }
public string Type { get; set; }
public string Extra { get; set; }
public ulong? OtherId { get; set; }
}

View File

@@ -0,0 +1,12 @@
#nullable disable
using System.ComponentModel.DataAnnotations;
namespace Nadeko.Bot.Db.Models;
public class DbEntity
{
[Key]
public int Id { get; set; }
public DateTime? DateAdded { get; set; } = DateTime.UtcNow;
}

View File

@@ -0,0 +1,14 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class DelMsgOnCmdChannel : DbEntity
{
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;
}

View File

@@ -0,0 +1,12 @@
#nullable disable
using Nadeko.Bot.Db;
namespace Nadeko.Bot.Db.Models;
public class DiscordPermOverride : DbEntity
{
public GuildPerm Perm { get; set; }
public ulong? GuildId { get; set; }
public string Command { get; set; }
}

View File

@@ -0,0 +1,37 @@
#nullable disable
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db.Models;
// FUTURE remove LastLevelUp from here and UserXpStats
public class DiscordUser : DbEntity
{
public ulong UserId { get; set; }
public string Username { get; set; }
public string Discriminator { get; set; }
public string AvatarId { get; set; }
public int? ClubId { get; set; }
public ClubInfo Club { get; set; }
public bool IsClubAdmin { get; set; }
public long TotalXp { get; set; }
public XpNotificationLocation NotifyOnLevelUp { get; set; }
public long CurrencyAmount { get; set; }
public override bool Equals(object obj)
=> obj is DiscordUser du ? du.UserId == UserId : false;
public override int GetHashCode()
=> UserId.GetHashCode();
public override string ToString()
{
if (string.IsNullOrWhiteSpace(Discriminator) || Discriminator == "0000")
return Username;
return Username + "#" + Discriminator;
}
}

View File

@@ -0,0 +1,49 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class CurrencyEvent
{
public enum Type
{
Reaction,
GameStatus
//NotRaid,
}
public ulong ServerId { get; set; }
public ulong ChannelId { get; set; }
public ulong MessageId { get; set; }
public Type EventType { get; set; }
/// <summary>
/// Amount of currency that the user will be rewarded.
/// </summary>
public long Amount { get; set; }
/// <summary>
/// Maximum amount of currency that can be handed out.
/// </summary>
public long PotSize { get; set; }
public List<AwardedUser> AwardedUsers { get; set; }
/// <summary>
/// Used as extra data storage for events which need it.
/// </summary>
public ulong ExtraId { get; set; }
/// <summary>
/// May be used for some future event.
/// </summary>
public ulong ExtraId2 { get; set; }
/// <summary>
/// May be used for some future event.
/// </summary>
public string ExtraString { get; set; }
}
public class AwardedUser
{
}

View File

@@ -0,0 +1,19 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class FeedSub : DbEntity
{
public int GuildConfigId { get; set; }
public GuildConfig GuildConfig { 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;
}

View File

@@ -0,0 +1,35 @@
#nullable disable
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db.Models;
public class FollowedStream : DbEntity
{
public enum FType
{
Twitch = 0,
Picarto = 3,
Youtube = 4,
Facebook = 5,
Trovo = 6
}
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
public string Username { get; set; }
public FType Type { get; set; }
public string Message { get; set; }
protected bool Equals(FollowedStream other)
=> ChannelId == other.ChannelId
&& Username.Trim().ToUpperInvariant() == other.Username.Trim().ToUpperInvariant()
&& Type == other.Type;
public override int GetHashCode()
=> HashCode.Combine(ChannelId, Username, (int)Type);
public override bool Equals(object obj)
=> obj is FollowedStream fs && Equals(fs);
}

View File

@@ -0,0 +1,14 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class GCChannelId : DbEntity
{
public GuildConfig GuildConfig { 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();
}

View File

@@ -0,0 +1,9 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class GamblingStats : DbEntity
{
public string Feature { get; set; }
public decimal Bet { get; set; }
public decimal PaidOut { get; set; }
}

View File

@@ -0,0 +1,11 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class GroupName : DbEntity
{
public int GuildConfigId { get; set; }
public GuildConfig GuildConfig { get; set; }
public int Number { get; set; }
public string Name { get; set; }
}

View File

@@ -0,0 +1,109 @@
#nullable disable
using NadekoBot.Db.Models;
namespace Nadeko.Bot.Db.Models;
public class GuildConfig : DbEntity
{
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; }
//greet stuff
public int AutoDeleteGreetMessagesTimer { get; set; } = 30;
public int AutoDeleteByeMessagesTimer { get; set; } = 30;
public ulong GreetMessageChannelId { get; set; }
public ulong ByeMessageChannelId { get; set; }
public bool SendDmGreetMessage { get; set; }
public string DmGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
public bool SendChannelGreetMessage { get; set; }
public string ChannelGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
public bool SendChannelByeMessage { get; set; }
public string ChannelByeMessageText { get; set; } = "%user% has left!";
//self assignable roles
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 FilterLinks { get; set; }
//public HashSet<FilterLinksChannelId> FilterLinksChannels { get; set; } = new HashSet<FilterLinksChannelId>();
public bool FilterWords { get; set; }
public HashSet<FilteredWord> FilteredWords { get; set; } = new();
public HashSet<FilterWordsChannelId> FilterWordsChannelIds { get; set; } = new();
public HashSet<MutedUserId> MutedUsers { get; set; } = new();
public string MuteRoleName { get; set; }
public bool CleverbotEnabled { get; set; }
public AntiRaidSetting AntiRaidSetting { get; set; }
public AntiSpamSetting AntiSpamSetting { get; set; }
public AntiAltSetting AntiAltSetting { get; set; }
public string Locale { get; set; }
public string TimeZoneId { get; set; }
public HashSet<UnmuteTimer> UnmuteTimers { get; set; } = new();
public HashSet<UnbanTimer> UnbanTimer { get; set; } = new();
public HashSet<UnroleTimer> UnroleTimer { get; set; } = new();
public HashSet<VcRoleInfo> VcRoleInfos { get; set; }
public HashSet<CommandAlias> CommandAliases { get; set; } = new();
public List<WarningPunishment> WarnPunishments { 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 List<GroupName> SelfAssignableRoleGroupNames { get; set; }
public int WarnExpireHours { get; set; }
public WarnExpireAction WarnExpireAction { get; set; } = WarnExpireAction.Clear;
public bool DisableGlobalExpressions { get; set; } = false;
#region Boost Message
public bool SendBoostMessage { get; set; }
public string BoostMessage { get; set; } = "%user% just boosted this server!";
public ulong BoostMessageChannelId { get; set; }
public int BoostMessageDeleteAfter { get; set; }
public bool StickyRoles { get; set; }
#endregion
}

View File

@@ -0,0 +1,16 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class IgnoredLogItem : DbEntity
{
public int LogSettingId { get; set; }
public LogSetting LogSetting { get; set; }
public ulong LogItemId { get; set; }
public IgnoredItemType ItemType { get; set; }
}
public enum IgnoredItemType
{
Channel,
User
}

View File

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

View File

@@ -0,0 +1,15 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class ImageOnlyChannel : DbEntity
{
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
public OnlyChannelType Type { get; set; }
}
public enum OnlyChannelType
{
Image,
Link
}

View File

@@ -0,0 +1,37 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class LogSetting : DbEntity
{
public List<IgnoredLogItem> LogIgnores { get; set; } = new();
public ulong GuildId { get; set; }
public ulong? LogOtherId { get; set; }
public ulong? MessageUpdatedId { get; set; }
public ulong? MessageDeletedId { get; set; }
public ulong? UserJoinedId { get; set; }
public ulong? UserLeftId { get; set; }
public ulong? UserBannedId { get; set; }
public ulong? UserUnbannedId { get; set; }
public ulong? UserUpdatedId { get; set; }
public ulong? ChannelCreatedId { get; set; }
public ulong? ChannelDestroyedId { get; set; }
public ulong? ChannelUpdatedId { get; set; }
public ulong? ThreadDeletedId { get; set; }
public ulong? ThreadCreatedId { get; set; }
public ulong? UserMutedId { get; set; }
//userpresence
public ulong? LogUserPresenceId { get; set; }
//voicepresence
public ulong? LogVoicePresenceId { get; set; }
public ulong? LogVoicePresenceTTSId { get; set; }
public ulong? LogWarnsId { get; set; }
}

View File

@@ -0,0 +1,55 @@
#nullable disable
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
namespace Nadeko.Bot.Db.Models;
[DebuggerDisplay("{PrimaryTarget}{SecondaryTarget} {SecondaryTargetName} {State} {PrimaryTargetId}")]
public class Permissionv2 : DbEntity, IIndexed
{
public int? GuildConfigId { get; set; }
public int Index { get; set; }
public PrimaryPermissionType PrimaryTarget { get; set; }
public ulong PrimaryTargetId { get; set; }
public SecondaryPermissionType SecondaryTarget { get; set; }
public string SecondaryTargetName { get; set; }
public bool IsCustomCommand { get; set; }
public bool State { get; set; }
[NotMapped]
public static Permissionv2 AllowAllPerm
=> new()
{
PrimaryTarget = PrimaryPermissionType.Server,
PrimaryTargetId = 0,
SecondaryTarget = SecondaryPermissionType.AllModules,
SecondaryTargetName = "*",
State = true,
Index = 0
};
public static List<Permissionv2> GetDefaultPermlist
=> new()
{
AllowAllPerm
};
}
public enum PrimaryPermissionType
{
User,
Channel,
Role,
Server
}
public enum SecondaryPermissionType
{
Module,
Command,
AllModules
}

View File

@@ -0,0 +1,12 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class PlantedCurrency : DbEntity
{
public long Amount { get; set; }
public string Password { get; set; }
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
public ulong UserId { get; set; }
public ulong MessageId { get; set; }
}

View File

@@ -0,0 +1,18 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class PlaylistSong : DbEntity
{
public string Provider { get; set; }
public MusicType ProviderType { get; set; }
public string Title { get; set; }
public string Uri { get; set; }
public string Query { get; set; }
}
public enum MusicType
{
Radio,
YouTube,
Local,
}

View File

@@ -0,0 +1,19 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class Reminder : DbEntity
{
public DateTime When { get; set; }
public ulong ChannelId { get; set; }
public ulong ServerId { get; set; }
public ulong UserId { get; set; }
public string Message { get; set; }
public bool IsPrivate { get; set; }
public ReminderType Type { get; set; }
}
public enum ReminderType
{
User,
Timely
}

View File

@@ -0,0 +1,15 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class Repeater
{
public int Id { get; set; }
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
public ulong? LastMessageId { get; set; }
public string Message { get; set; }
public TimeSpan Interval { get; set; }
public TimeSpan? StartTimeOfDay { get; set; }
public bool NoRedundant { get; set; }
public DateTime DateAdded { get; set; }
}

View File

@@ -0,0 +1,10 @@
#nullable disable
using Nadeko.Bot.Db;
namespace Nadeko.Bot.Db.Models;
public class RotatingPlayingStatus : DbEntity
{
public string Status { get; set; }
public ActivityType Type { get; set; }
}

View File

@@ -0,0 +1,46 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public enum ShopEntryType
{
Role,
List,
Command
}
public class ShopEntry : DbEntity, IIndexed
{
public int Index { get; set; }
public int Price { get; set; }
public string Name { get; set; }
public ulong AuthorId { get; set; }
public ShopEntryType Type { get; set; }
//role
public string RoleName { get; set; }
public ulong RoleId { get; set; }
//list
public HashSet<ShopEntryItem> Items { get; set; } = new();
public ulong? RoleRequirement { get; set; }
// command
public string Command { get; set; }
}
public class ShopEntryItem : DbEntity
{
public string Text { get; set; }
public override bool Equals(object obj)
{
if (obj is null || GetType() != obj.GetType())
return false;
return ((ShopEntryItem)obj).Text == Text;
}
public override int GetHashCode()
=> Text.GetHashCode(StringComparison.InvariantCulture);
}

View File

@@ -0,0 +1,13 @@
#nullable disable
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db.Models;
public class StreamOnlineMessage : DbEntity
{
public ulong ChannelId { get; set; }
public ulong MessageId { get; set; }
public FollowedStream.FType Type { get; set; }
public string Name { get; set; }
}

View File

@@ -0,0 +1,68 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class StreamRoleSettings : DbEntity
{
public int GuildConfigId { get; set; }
public GuildConfig GuildConfig { get; set; }
/// <summary>
/// Whether the feature is enabled in the guild.
/// </summary>
public bool Enabled { get; set; }
/// <summary>
/// Id of the role to give to the users in the role 'FromRole' when they start streaming
/// </summary>
public ulong AddRoleId { get; set; }
/// <summary>
/// Id of the role whose users are eligible to get the 'AddRole'
/// </summary>
public ulong FromRoleId { get; set; }
/// <summary>
/// If set, feature will only apply to users who have this keyword in their streaming status.
/// </summary>
public string Keyword { get; set; }
/// <summary>
/// A collection of whitelisted users' IDs. Whitelisted users don't require 'keyword' in
/// order to get the stream role.
/// </summary>
public HashSet<StreamRoleWhitelistedUser> Whitelist { get; set; } = new();
/// <summary>
/// A collection of blacklisted users' IDs. Blacklisted useres will never get the stream role.
/// </summary>
public HashSet<StreamRoleBlacklistedUser> Blacklist { get; set; } = new();
}
public class StreamRoleBlacklistedUser : DbEntity
{
public ulong UserId { get; set; }
public string Username { get; set; }
public override bool Equals(object obj)
{
if (obj is not StreamRoleBlacklistedUser x)
return false;
return x.UserId == UserId;
}
public override int GetHashCode()
=> UserId.GetHashCode();
}
public class StreamRoleWhitelistedUser : DbEntity
{
public ulong UserId { get; set; }
public string Username { get; set; }
public override bool Equals(object obj)
=> obj is StreamRoleWhitelistedUser x ? x.UserId == UserId : false;
public override int GetHashCode()
=> UserId.GetHashCode();
}

View File

@@ -0,0 +1,8 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class VcRoleInfo : DbEntity
{
public ulong VoiceChannelId { get; set; }
public ulong RoleId { get; set; }
}

View File

@@ -0,0 +1,11 @@
namespace Nadeko.Bot.Db.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; }
}

View File

@@ -0,0 +1,19 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
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; }
/// <summary>
/// Duration of the punishment, in minutes. This works only for supported Actions, like:
/// Mute, Chatmute, Voicemute, etc...
/// </summary>
public int PunishDuration { get; set; }
}

View File

@@ -0,0 +1,12 @@
namespace Nadeko.Bot.Db.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;
}

View File

@@ -0,0 +1,14 @@
namespace Nadeko.Bot.Db.Models;
#nullable disable
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<AntiSpamIgnore> IgnoredChannels { get; set; } = new();
}

View File

@@ -0,0 +1,42 @@
#nullable disable
using Nadeko.Bot.Db.Models;
using System.ComponentModel.DataAnnotations;
namespace NadekoBot.Db.Models;
public class ClubInfo : DbEntity
{
[MaxLength(20)]
public string Name { get; set; }
public string Description { get; set; }
public string ImageUrl { get; set; } = string.Empty;
public int Xp { get; set; } = 0;
public int? OwnerId { get; set; }
public DiscordUser Owner { get; set; }
public List<DiscordUser> Members { get; set; } = new();
public List<ClubApplicants> Applicants { get; set; } = new();
public List<ClubBans> Bans { get; set; } = new();
public override string ToString()
=> Name;
}
public class ClubApplicants
{
public int ClubId { get; set; }
public ClubInfo Club { get; set; }
public int UserId { get; set; }
public DiscordUser User { get; set; }
}
public class ClubBans
{
public int ClubId { get; set; }
public ClubInfo Club { get; set; }
public int UserId { get; set; }
public DiscordUser User { get; set; }
}

View File

@@ -0,0 +1,9 @@
using Nadeko.Bot.Db.Models;
namespace NadekoBot.Db.Models;
public class BankUser : DbEntity
{
public ulong UserId { get; set; }
public long Balance { get; set; }
}

View File

@@ -0,0 +1,27 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class NadekoExpression : DbEntity
{
public ulong? GuildId { get; set; }
public string Response { get; set; }
public string Trigger { get; set; }
public bool AutoDeleteTrigger { get; set; }
public bool DmResponse { get; set; }
public bool ContainsAnywhere { get; set; }
public bool AllowTarget { get; set; }
public string Reactions { get; set; }
public string[] GetReactions()
=> string.IsNullOrWhiteSpace(Reactions) ? Array.Empty<string>() : Reactions.Split("@@@");
public bool IsGlobal()
=> GuildId is null or 0;
}
public class ReactionResponse : DbEntity
{
public bool OwnerOnly { get; set; }
public string Text { get; set; }
}

View File

@@ -0,0 +1,26 @@
#nullable disable
using System.ComponentModel.DataAnnotations;
namespace Nadeko.Bot.Db.Models;
public class Quote : DbEntity
{
public ulong GuildId { get; set; }
[Required]
public string Keyword { get; set; }
[Required]
public string AuthorName { get; set; }
public ulong AuthorId { get; set; }
[Required]
public string Text { get; set; }
}
public enum OrderType
{
Id = -1,
Keyword = -2
}

View File

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

View File

@@ -0,0 +1,13 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class FilterLinksChannelId : DbEntity
{
public ulong ChannelId { get; set; }
public override bool Equals(object obj)
=> obj is FilterLinksChannelId f && f.ChannelId == ChannelId;
public override int GetHashCode()
=> ChannelId.GetHashCode();
}

View File

@@ -0,0 +1,7 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class FilteredWord : DbEntity
{
public string Word { get; set; }
}

View File

@@ -0,0 +1,14 @@
namespace NadekoBot.Db.Models;
#nullable disable
public sealed class GiveawayModel
{
public int Id { get; set; }
public ulong GuildId { get; set; }
public ulong MessageId { get; set; }
public ulong ChannelId { get; set; }
public string Message { get; set; }
public IList<GiveawayUser> Participants { get; set; } = new List<GiveawayUser>();
public DateTime EndsAt { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace NadekoBot.Db.Models;
#nullable disable
public sealed class GiveawayUser
{
public int Id { get; set; }
public int GiveawayId { get; set; }
public ulong UserId { get; set; }
public string Name { get; set; }
}

View File

@@ -0,0 +1,9 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class BanTemplate : DbEntity
{
public ulong GuildId { get; set; }
public string Text { get; set; }
public int? PruneDays { get; set; }
}

View File

@@ -0,0 +1,13 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class MutedUserId : DbEntity
{
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;
}

View File

@@ -0,0 +1,15 @@
namespace Nadeko.Bot.Db.Models;
public enum PunishmentAction
{
Mute,
Kick,
Ban,
Softban,
RemoveRoles,
ChatMute,
VoiceMute,
AddRole,
Warn,
TimeOut
}

View File

@@ -0,0 +1,8 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public enum WarnExpireAction
{
Clear,
Delete
}

View File

@@ -0,0 +1,13 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class Warning : DbEntity
{
public ulong GuildId { get; set; }
public ulong UserId { get; set; }
public string Reason { get; set; }
public bool Forgiven { get; set; }
public string ForgivenBy { get; set; }
public string Moderator { get; set; }
public long Weight { get; set; }
}

View File

@@ -0,0 +1,10 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class WarningPunishment : DbEntity
{
public int Count { get; set; }
public PunishmentAction Punishment { get; set; }
public int Time { get; set; }
public ulong? RoleId { get; set; }
}

View File

@@ -0,0 +1,18 @@
#nullable disable
using System.ComponentModel.DataAnnotations;
namespace Nadeko.Bot.Db.Models;
public class ReactionRoleV2 : DbEntity
{
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
public ulong MessageId { get; set; }
[MaxLength(100)]
public string Emote { get; set; }
public ulong RoleId { get; set; }
public int Group { get; set; }
public int LevelReq { get; set; }
}

View File

@@ -0,0 +1,11 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class SelfAssignedRole : DbEntity
{
public ulong GuildId { get; set; }
public ulong RoleId { get; set; }
public int Group { get; set; }
public int LevelRequirement { get; set; }
}

View File

@@ -0,0 +1,14 @@
namespace Nadeko.Bot.Db.Models;
#nullable disable
public class StickyRole : DbEntity
{
public ulong GuildId { get; set; }
public string RoleIds { get; set; }
public ulong UserId { get; set; }
public ulong[] GetRoleIds()
=> string.IsNullOrWhiteSpace(RoleIds)
? []
: RoleIds.Split(',').Select(ulong.Parse).ToArray();
}

View File

@@ -0,0 +1,20 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class SlowmodeIgnoredRole : DbEntity
{
public ulong RoleId { get; set; }
// override object.Equals
public override bool Equals(object obj)
{
if (obj is null || GetType() != obj.GetType())
return false;
return ((SlowmodeIgnoredRole)obj).RoleId == RoleId;
}
// override object.GetHashCode
public override int GetHashCode()
=> RoleId.GetHashCode();
}

View File

@@ -0,0 +1,20 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class SlowmodeIgnoredUser : DbEntity
{
public ulong UserId { get; set; }
// override object.Equals
public override bool Equals(object obj)
{
if (obj is null || GetType() != obj.GetType())
return false;
return ((SlowmodeIgnoredUser)obj).UserId == UserId;
}
// override object.GetHashCode
public override int GetHashCode()
=> UserId.GetHashCode();
}

View File

@@ -0,0 +1,48 @@
#nullable disable
namespace NadekoBot.Db.Models;
/// <summary>
/// Contains data about usage of Patron-Only commands per user
/// in order to provide support for quota limitations
/// (allow user x who is pledging amount y to use the specified command only
/// x amount of times in the specified time period)
/// </summary>
public class PatronQuota
{
public ulong UserId { get; set; }
public FeatureType FeatureType { get; set; }
public string Feature { get; set; }
public uint HourlyCount { get; set; }
public uint DailyCount { get; set; }
public uint MonthlyCount { get; set; }
}
public enum FeatureType
{
Command,
Group,
Module,
Limit
}
public class PatronUser
{
public string UniquePlatformUserId { get; set; }
public ulong UserId { get; set; }
public int AmountCents { get; set; }
public DateTime LastCharge { get; set; }
// Date Only component
public DateTime ValidThru { get; set; }
public PatronUser Clone()
=> new PatronUser()
{
UniquePlatformUserId = this.UniquePlatformUserId,
UserId = this.UserId,
AmountCents = this.AmountCents,
LastCharge = this.LastCharge,
ValidThru = this.ValidThru
};
}

View File

@@ -0,0 +1,10 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class RewardedUser : DbEntity
{
public ulong UserId { get; set; }
public string PlatformUserId { get; set; }
public long AmountRewardedThisMonth { get; set; }
public DateTime LastReward { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace NadekoBot.Db.Models;
#nullable disable
public sealed class ArchivedTodoListModel
{
public int Id { get; set; }
public ulong UserId { get; set; }
public string Name { get; set; }
public List<TodoModel> Items { get; set; }
}

View File

@@ -0,0 +1,13 @@
namespace NadekoBot.Db.Models;
#nullable disable
public sealed class TodoModel
{
public int Id { get; set; }
public ulong UserId { get; set; }
public string Todo { get; set; }
public DateTime DateAdded { get; set; }
public bool IsDone { get; set; }
public int? ArchiveId { get; set; }
}

View File

@@ -0,0 +1,14 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class UnbanTimer : DbEntity
{
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;
}

View File

@@ -0,0 +1,14 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class UnmuteTimer : DbEntity
{
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;
}

View File

@@ -0,0 +1,15 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class UnroleTimer : DbEntity
{
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;
}

View File

@@ -0,0 +1,13 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class UserXpStats : DbEntity
{
public ulong UserId { get; set; }
public ulong GuildId { get; set; }
public long Xp { get; set; }
public long AwardedXp { get; set; }
public XpNotificationLocation NotifyOnLevelUp { get; set; }
}
public enum XpNotificationLocation { None, Dm, Channel }

View File

@@ -0,0 +1,62 @@
#nullable disable
namespace Nadeko.Bot.Db.Models;
public class XpSettings : DbEntity
{
public int GuildConfigId { get; set; }
public GuildConfig GuildConfig { get; set; }
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 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;
}