diff --git a/backend/AutoMods/Controllers/AutoModEventController.cs b/backend/AutoMods/Controllers/AutoModEventController.cs index 93875b60c..625d155eb 100644 --- a/backend/AutoMods/Controllers/AutoModEventController.cs +++ b/backend/AutoMods/Controllers/AutoModEventController.cs @@ -18,7 +18,7 @@ public class AutoModEventController(IdentityManager identityManager, AutoModEven [HttpGet] public async Task GetAllItems([FromRoute] ulong guildId, - [FromQuery] [Range(0, int.MaxValue)] int startPage = 0) + [FromQuery][Range(0, int.MaxValue)] int startPage = 0) { var identity = await SetupAuthentication(); diff --git a/backend/AutoMods/Extensions/SearchContains.cs b/backend/AutoMods/Extensions/SearchContains.cs index 810633416..0b48e45a2 100644 --- a/backend/AutoMods/Extensions/SearchContains.cs +++ b/backend/AutoMods/Extensions/SearchContains.cs @@ -6,20 +6,18 @@ namespace AutoMods.Extensions; public static class SearchContains { public static bool Search(this string search, AutoModEventExpanded obj) => - obj == null - ? false - : search.Search(obj.AutoModEvent) || - search.Search(obj.Suspect); + obj != null +&& (search.Search(obj.AutoModEvent) || + search.Search(obj.Suspect)); public static bool Search(this string search, AutoModEvent obj) => - obj == null - ? false - : search.Search(obj.AutoModAction.ToString()) || + obj != null +&& (search.Search(obj.AutoModAction.ToString()) || search.Search(obj.AutoModType.ToString()) || search.Search(obj.CreatedAt) || search.Search(obj.Username) || search.Search(obj.Nickname) || search.Search(obj.UserId) || search.Search(obj.MessageContent) || - search.Search(obj.MessageId); + search.Search(obj.MessageId)); } diff --git a/backend/AutoMods/MessageChecks/EmbedCheck.cs b/backend/AutoMods/MessageChecks/EmbedCheck.cs index fbf05222a..f43c44022 100644 --- a/backend/AutoMods/MessageChecks/EmbedCheck.cs +++ b/backend/AutoMods/MessageChecks/EmbedCheck.cs @@ -6,5 +6,5 @@ namespace AutoMods.MessageChecks; public static class EmbedCheck { - public static bool Check(IMessage message, AutoModConfig config, DiscordSocketClient _) => config.Limit == null ? false : message.Embeds == null ? false : message.Embeds.Count > config.Limit; + public static bool Check(IMessage message, AutoModConfig config, DiscordSocketClient _) => config.Limit != null && message.Embeds != null && message.Embeds.Count > config.Limit; } diff --git a/backend/AutoMods/MessageChecks/MentionCheck.cs b/backend/AutoMods/MessageChecks/MentionCheck.cs index 899ea3128..7fd55aeab 100644 --- a/backend/AutoMods/MessageChecks/MentionCheck.cs +++ b/backend/AutoMods/MessageChecks/MentionCheck.cs @@ -6,5 +6,5 @@ namespace AutoMods.MessageChecks; public static class MentionCheck { - public static bool Check(IMessage message, AutoModConfig config, DiscordSocketClient _) => config.Limit == null ? false : message.MentionedUserIds == null ? false : message.MentionedUserIds.Count > config.Limit; + public static bool Check(IMessage message, AutoModConfig config, DiscordSocketClient _) => config.Limit != null && message.MentionedUserIds != null && message.MentionedUserIds.Count > config.Limit; } diff --git a/backend/AutoMods/Migrations/20220225095748_InitialCreate.cs b/backend/AutoMods/Migrations/20220225095748_InitialCreate.cs index 08270c04d..76a2c65ec 100644 --- a/backend/AutoMods/Migrations/20220225095748_InitialCreate.cs +++ b/backend/AutoMods/Migrations/20220225095748_InitialCreate.cs @@ -7,74 +7,74 @@ namespace AutoMods.Migrations; public partial class InitialCreate : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "AutoMods"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "AutoMods"); - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "AutoModConfigs", - schema: "AutoMods", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - GuildId = table.Column(type: "bigint unsigned", nullable: false), - AutoModType = table.Column(type: "int", nullable: false), - AutoModAction = table.Column(type: "int", nullable: false), - PunishmentType = table.Column(type: "int", nullable: true), - PunishmentDurationMinutes = table.Column(type: "int", nullable: true), - IgnoreChannels = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - IgnoreRoles = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - TimeLimitMinutes = table.Column(type: "int", nullable: true), - Limit = table.Column(type: "int", nullable: true), - CustomWordFilter = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ChannelNotificationBehavior = table.Column(type: "int", nullable: false) - }, - constraints: table => table.PrimaryKey("PK_AutoModConfigs", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "AutoModConfigs", + schema: "AutoMods", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GuildId = table.Column(type: "bigint unsigned", nullable: false), + AutoModType = table.Column(type: "int", nullable: false), + AutoModAction = table.Column(type: "int", nullable: false), + PunishmentType = table.Column(type: "int", nullable: true), + PunishmentDurationMinutes = table.Column(type: "int", nullable: true), + IgnoreChannels = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IgnoreRoles = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + TimeLimitMinutes = table.Column(type: "int", nullable: true), + Limit = table.Column(type: "int", nullable: true), + CustomWordFilter = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ChannelNotificationBehavior = table.Column(type: "int", nullable: false) + }, + constraints: table => table.PrimaryKey("PK_AutoModConfigs", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "AutoModEvents", - schema: "AutoMods", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - GuildId = table.Column(type: "bigint unsigned", nullable: false), - AutoModType = table.Column(type: "int", nullable: false), - AutoModAction = table.Column(type: "int", nullable: false), - UserId = table.Column(type: "bigint unsigned", nullable: false), - Username = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Nickname = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Discriminator = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - MessageId = table.Column(type: "bigint unsigned", nullable: false), - MessageContent = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - AssociatedCaseId = table.Column(type: "int", nullable: true) - }, - constraints: table => table.PrimaryKey("PK_AutoModEvents", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); - } + migrationBuilder.CreateTable( + name: "AutoModEvents", + schema: "AutoMods", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GuildId = table.Column(type: "bigint unsigned", nullable: false), + AutoModType = table.Column(type: "int", nullable: false), + AutoModAction = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "bigint unsigned", nullable: false), + Username = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Nickname = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Discriminator = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + MessageId = table.Column(type: "bigint unsigned", nullable: false), + MessageContent = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + AssociatedCaseId = table.Column(type: "int", nullable: true) + }, + constraints: table => table.PrimaryKey("PK_AutoModEvents", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AutoModConfigs", - schema: "AutoMods"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AutoModConfigs", + schema: "AutoMods"); - migrationBuilder.DropTable( - name: "AutoModEvents", - schema: "AutoMods"); - } + migrationBuilder.DropTable( + name: "AutoModEvents", + schema: "AutoMods"); + } } diff --git a/backend/AutoMods/Services/AutoModChecker.cs b/backend/AutoMods/Services/AutoModChecker.cs index f77bea895..1479d6b8b 100644 --- a/backend/AutoMods/Services/AutoModChecker.cs +++ b/backend/AutoMods/Services/AutoModChecker.cs @@ -187,7 +187,7 @@ private async Task FinaliseAutoMod(AutoModConfig autoModConfig, IMessage m if (modType != AutoModType.TooManyAutomods) await CheckAutoMod(AutoModType.TooManyAutomods, message, CheckMultipleEvents, scope); - + return true; } diff --git a/backend/Bot/Abstractions/DataContext.cs b/backend/Bot/Abstractions/DataContext.cs index 732fe730c..8737d78a4 100644 --- a/backend/Bot/Abstractions/DataContext.cs +++ b/backend/Bot/Abstractions/DataContext.cs @@ -25,15 +25,15 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) FloatArrayComparer floatArrayComparer = new(); foreach (var entityType in modelBuilder.Model.GetEntityTypes()) - foreach (var property in entityType.GetProperties()) - { - if (property.ClrType == typeof(ulong[])) - property.SetValueComparer(ulongArrayComparer); - else if (property.ClrType == typeof(string[])) - property.SetValueComparer(stringArrayComparer); - else if (property.ClrType == typeof(float[])) - property.SetValueComparer(floatArrayComparer); - } + foreach (var property in entityType.GetProperties()) + { + if (property.ClrType == typeof(ulong[])) + property.SetValueComparer(ulongArrayComparer); + else if (property.ClrType == typeof(string[])) + property.SetValueComparer(stringArrayComparer); + else if (property.ClrType == typeof(float[])) + property.SetValueComparer(floatArrayComparer); + } OverrideModelCreating(modelBuilder); } diff --git a/backend/Bot/Abstractions/DataConverters.cs b/backend/Bot/Abstractions/DataConverters.cs index 2cb6da046..946fc5711 100644 --- a/backend/Bot/Abstractions/DataConverters.cs +++ b/backend/Bot/Abstractions/DataConverters.cs @@ -3,7 +3,7 @@ namespace Bot.Abstractions; -public class JsonDataConverter : ValueConverter +public class JsonDataConverter : ValueConverter { public JsonDataConverter() : base( v => JsonConvert.SerializeObject(v), diff --git a/backend/Bot/Bot.csproj b/backend/Bot/Bot.csproj index 2ea8d3c50..9af978602 100644 --- a/backend/Bot/Bot.csproj +++ b/backend/Bot/Bot.csproj @@ -10,7 +10,6 @@ - diff --git a/backend/Bot/BotModule.cs b/backend/Bot/BotModule.cs index 576e2292b..f16386921 100644 --- a/backend/Bot/BotModule.cs +++ b/backend/Bot/BotModule.cs @@ -151,7 +151,7 @@ public override void PostWebBuild(WebApplication app, AppSettings settings) options.RoutePrefix = string.Empty; }); } - + app.UseMiddleware(); app.UseMiddleware(); app.UseMiddleware(); diff --git a/backend/Bot/Controllers/BotEnumControllers.cs b/backend/Bot/Controllers/BotEnumControllers.cs index 61ba33744..de56f4f9d 100644 --- a/backend/Bot/Controllers/BotEnumControllers.cs +++ b/backend/Bot/Controllers/BotEnumControllers.cs @@ -15,7 +15,7 @@ public async Task ApiError([FromQuery] Language? language = null) await TranslateEnum(language); [HttpGet("editstatus")] - public async Task ViewEditStatus([FromQuery] Language? language = null) => + public async Task ViewEditStatus([FromQuery] Language? language = null) => await TranslateEnum(language); [HttpGet("language")] diff --git a/backend/Bot/Controllers/StatusController.cs b/backend/Bot/Controllers/StatusController.cs index 8594a756a..adee90d01 100644 --- a/backend/Bot/Controllers/StatusController.cs +++ b/backend/Bot/Controllers/StatusController.cs @@ -19,9 +19,9 @@ public async Task Status() { var config = await _settingsRepository.GetAppSettings(); - if (!HttpContext.Request.Headers.TryGetValue("Accept", out var value)) return Ok("OK"); - - return value.ToString().Search("application/json") + return !HttpContext.Request.Headers.TryGetValue("Accept", out var value) + ? Ok("OK") + : value.ToString().Search("application/json") ? Ok(new { status = "OK", diff --git a/backend/Bot/Controllers/UserNetworkController.cs b/backend/Bot/Controllers/UserNetworkController.cs index ccb98d3a7..c79067728 100644 --- a/backend/Bot/Controllers/UserNetworkController.cs +++ b/backend/Bot/Controllers/UserNetworkController.cs @@ -21,7 +21,7 @@ public class UserNetworkController(GuildConfigRepository guildConfigRepository, private readonly IServiceProvider _serviceProvider = serviceProvider; [HttpGet("user")] - public async Task GetUserNetwork([FromQuery] [Required] ulong userId) + public async Task GetUserNetwork([FromQuery][Required] ulong userId) { var identity = await SetupAuthentication(); diff --git a/backend/Bot/Identities/DiscordCommandIdentity.cs b/backend/Bot/Identities/DiscordCommandIdentity.cs index f01c6ea96..d0c55ca2d 100644 --- a/backend/Bot/Identities/DiscordCommandIdentity.cs +++ b/backend/Bot/Identities/DiscordCommandIdentity.cs @@ -50,10 +50,9 @@ public override async Task HasAdminRoleOnGuild(ulong guildId) var guildUser = GetGuildMembership(guildId); - return guildUser is null - ? false - : guildUser.Guild.OwnerId == guildUser.Id || - guildUser.RoleIds.Any(x => guildConfig.AdminRoles.Contains(x)); + return guildUser is not null +&& (guildUser.Guild.OwnerId == guildUser.Id || + guildUser.RoleIds.Any(x => guildConfig.AdminRoles.Contains(x))); } catch (ResourceNotFoundException) { @@ -75,12 +74,10 @@ public override async Task HasModRoleOrHigherOnGuild(ulong guildId) var guildUser = GetGuildMembership(guildId); - return guildUser is null - ? false - : guildUser.Guild.OwnerId == guildUser.Id - ? true - : guildUser.RoleIds.Any(x => guildConfig.AdminRoles.Contains(x) || - guildConfig.ModRoles.Contains(x)); + return guildUser is not null +&& (guildUser.Guild.OwnerId == guildUser.Id +|| guildUser.RoleIds.Any(x => guildConfig.AdminRoles.Contains(x) || + guildConfig.ModRoles.Contains(x))); } catch (ResourceNotFoundException) { diff --git a/backend/Bot/Identities/DiscordOAuthIdentity.cs b/backend/Bot/Identities/DiscordOAuthIdentity.cs index 17d41b629..ad181af81 100644 --- a/backend/Bot/Identities/DiscordOAuthIdentity.cs +++ b/backend/Bot/Identities/DiscordOAuthIdentity.cs @@ -81,10 +81,9 @@ public override async Task HasAdminRoleOnGuild(ulong guildId) var guildUser = GetGuildMembership(guildId); - return guildUser is null - ? false - : guildUser.Guild.OwnerId == guildUser.Id || - guildUser.RoleIds.Any(x => guildConfig.AdminRoles.Contains(x)); + return guildUser is not null +&& (guildUser.Guild.OwnerId == guildUser.Id || + guildUser.RoleIds.Any(x => guildConfig.AdminRoles.Contains(x))); } catch (ResourceNotFoundException) { @@ -107,12 +106,10 @@ public override async Task HasModRoleOrHigherOnGuild(ulong guildId) var guildUser = GetGuildMembership(guildId); - return guildUser is null - ? false - : guildUser.Guild.OwnerId == guildUser.Id - ? true - : guildUser.RoleIds.Any(x => guildConfig.AdminRoles.Contains(x) || - guildConfig.ModRoles.Contains(x)); + return guildUser is not null +&& (guildUser.Guild.OwnerId == guildUser.Id +|| guildUser.RoleIds.Any(x => guildConfig.AdminRoles.Contains(x) || + guildConfig.ModRoles.Contains(x))); } catch (ResourceNotFoundException) { diff --git a/backend/Bot/Migrations/20220225103441_InitialCreate.cs b/backend/Bot/Migrations/20220225103441_InitialCreate.cs index bc370940c..b3924b9b7 100644 --- a/backend/Bot/Migrations/20220225103441_InitialCreate.cs +++ b/backend/Bot/Migrations/20220225103441_InitialCreate.cs @@ -7,81 +7,81 @@ namespace Bot.Migrations; public partial class InitialCreate : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "Bot"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "Bot"); - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "AppSettings", - schema: "Bot", - columns: table => new - { - ClientId = table.Column(type: "bigint unsigned", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - DiscordBotToken = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ClientSecret = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - AbsolutePathToFileUpload = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ServiceDomain = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ServiceBaseUrl = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - SiteAdmins = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - AuditLogWebhookUrl = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CorsEnabled = table.Column(type: "tinyint(1)", nullable: false), - Lang = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - EmbedTitle = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - EmbedContent = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => table.PrimaryKey("PK_AppSettings", x => x.ClientId)) - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "AppSettings", + schema: "Bot", + columns: table => new + { + ClientId = table.Column(type: "bigint unsigned", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + DiscordBotToken = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ClientSecret = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AbsolutePathToFileUpload = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ServiceDomain = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ServiceBaseUrl = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SiteAdmins = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AuditLogWebhookUrl = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CorsEnabled = table.Column(type: "tinyint(1)", nullable: false), + Lang = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + EmbedTitle = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + EmbedContent = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => table.PrimaryKey("PK_AppSettings", x => x.ClientId)) + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "GuildConfigs", - schema: "Bot", - columns: table => new - { - GuildId = table.Column(type: "bigint unsigned", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ModRoles = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - AdminRoles = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - StaffChannels = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - BotChannels = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ModNotificationDm = table.Column(type: "tinyint(1)", nullable: false), - StaffLogs = table.Column(type: "bigint unsigned", nullable: false), - StaffAnnouncements = table.Column(type: "bigint unsigned", nullable: false), - StrictModPermissionCheck = table.Column(type: "tinyint(1)", nullable: false), - ExecuteWhoIsOnJoin = table.Column(type: "tinyint(1)", nullable: false), - PublishModeratorInfo = table.Column(type: "tinyint(1)", nullable: false), - PreferredLanguage = table.Column(type: "int", nullable: false) - }, - constraints: table => table.PrimaryKey("PK_GuildConfigs", x => x.GuildId)) - .Annotation("MySql:CharSet", "utf8mb4"); - } + migrationBuilder.CreateTable( + name: "GuildConfigs", + schema: "Bot", + columns: table => new + { + GuildId = table.Column(type: "bigint unsigned", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ModRoles = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AdminRoles = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + StaffChannels = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + BotChannels = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ModNotificationDm = table.Column(type: "tinyint(1)", nullable: false), + StaffLogs = table.Column(type: "bigint unsigned", nullable: false), + StaffAnnouncements = table.Column(type: "bigint unsigned", nullable: false), + StrictModPermissionCheck = table.Column(type: "tinyint(1)", nullable: false), + ExecuteWhoIsOnJoin = table.Column(type: "tinyint(1)", nullable: false), + PublishModeratorInfo = table.Column(type: "tinyint(1)", nullable: false), + PreferredLanguage = table.Column(type: "int", nullable: false) + }, + constraints: table => table.PrimaryKey("PK_GuildConfigs", x => x.GuildId)) + .Annotation("MySql:CharSet", "utf8mb4"); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AppSettings", - schema: "Bot"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppSettings", + schema: "Bot"); - migrationBuilder.DropTable( - name: "GuildConfigs", - schema: "Bot"); - } + migrationBuilder.DropTable( + name: "GuildConfigs", + schema: "Bot"); + } } diff --git a/backend/Bot/Migrations/20220811092432_AddHTTPSetting.cs b/backend/Bot/Migrations/20220811092432_AddHTTPSetting.cs index c898bafdc..1caa1f70c 100644 --- a/backend/Bot/Migrations/20220811092432_AddHTTPSetting.cs +++ b/backend/Bot/Migrations/20220811092432_AddHTTPSetting.cs @@ -6,35 +6,35 @@ namespace Bot.Migrations; public partial class AddHTTPSetting : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ServiceBaseUrl", - schema: "Bot", - table: "AppSettings"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ServiceBaseUrl", + schema: "Bot", + table: "AppSettings"); - migrationBuilder.AddColumn( - name: "EncryptionType", - schema: "Bot", - table: "AppSettings", - type: "int", - nullable: false, - defaultValue: 0); - } + migrationBuilder.AddColumn( + name: "EncryptionType", + schema: "Bot", + table: "AppSettings", + type: "int", + nullable: false, + defaultValue: 0); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "EncryptionType", - schema: "Bot", - table: "AppSettings"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "EncryptionType", + schema: "Bot", + table: "AppSettings"); - migrationBuilder.AddColumn( - name: "ServiceBaseUrl", - schema: "Bot", - table: "AppSettings", - type: "longtext", - nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"); - } + migrationBuilder.AddColumn( + name: "ServiceBaseUrl", + schema: "Bot", + table: "AppSettings", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + } } diff --git a/backend/Bot/Services/DiscordRest.cs b/backend/Bot/Services/DiscordRest.cs index 47df6d7a6..2ae4f639d 100644 --- a/backend/Bot/Services/DiscordRest.cs +++ b/backend/Bot/Services/DiscordRest.cs @@ -348,8 +348,7 @@ private async Task IsImageAvailable(string imageUrl) var response = await client.GetAsync(imageUrl); return response.IsSuccessStatusCode - ? true - : response.StatusCode == HttpStatusCode.NotFound ? false : throw new UnauthorizedException(); +|| (response.StatusCode == HttpStatusCode.NotFound ? false : throw new UnauthorizedException()); } public async Task> FetchGuildUsers(ulong guildId, CacheBehavior cacheBehavior) diff --git a/backend/Bot/Services/IdentityManager.cs b/backend/Bot/Services/IdentityManager.cs index 66856b5f6..890e9745f 100644 --- a/backend/Bot/Services/IdentityManager.cs +++ b/backend/Bot/Services/IdentityManager.cs @@ -47,10 +47,10 @@ private async Task RegisterNewIdentity(IUser user) var guildConfigs = await database.SelectAllGuildConfigs(); var guilds = (from guildConfig in guildConfigs - select discordRest.FetchGuildUserInfo(guildConfig.GuildId, user.Id, CacheBehavior.Default) + select discordRest.FetchGuildUserInfo(guildConfig.GuildId, user.Id, CacheBehavior.Default) into gUser - where gUser is not null - select UserGuild.GetUserGuild(gUser)).ToList(); + where gUser is not null + select UserGuild.GetUserGuild(gUser)).ToList(); var identity = new DiscordCommandIdentity(user, guilds, _serviceProvider); _identities[key] = identity; diff --git a/backend/Greeting/Attributes/RequireGreeterAttribute.cs b/backend/Greeting/Attributes/RequireGreeterAttribute.cs index 2c59099ec..4fb35dfb8 100644 --- a/backend/Greeting/Attributes/RequireGreeterAttribute.cs +++ b/backend/Greeting/Attributes/RequireGreeterAttribute.cs @@ -1,8 +1,8 @@ using Bot.Exceptions; -using Discord.Interactions; using Discord; -using Microsoft.Extensions.DependencyInjection; +using Discord.Interactions; using Greeting.Data; +using Microsoft.Extensions.DependencyInjection; namespace Greeting.Attributes; diff --git a/backend/Greeting/Commands/GreeterMute.cs b/backend/Greeting/Commands/GreeterMute.cs index af0cbbf53..b7a6d0884 100644 --- a/backend/Greeting/Commands/GreeterMute.cs +++ b/backend/Greeting/Commands/GreeterMute.cs @@ -1,14 +1,14 @@ -using Discord.Interactions; +using Bot.Exceptions; using Discord; +using Discord.Interactions; +using Greeting.Attributes; using Greeting.Data; +using Humanizer; +using Microsoft.Extensions.Logging; using Punishments.Abstractions; using Punishments.Enums; -using Punishments.Models; -using Greeting.Attributes; -using Bot.Exceptions; -using Microsoft.Extensions.Logging; using Punishments.Extensions; -using Humanizer; +using Punishments.Models; namespace Greeting.Commands; diff --git a/backend/GuildAudits/Migrations/20220207080714_InitialCreate.cs b/backend/GuildAudits/Migrations/20220207080714_InitialCreate.cs index 2d5402b36..6f3250953 100644 --- a/backend/GuildAudits/Migrations/20220207080714_InitialCreate.cs +++ b/backend/GuildAudits/Migrations/20220207080714_InitialCreate.cs @@ -7,30 +7,30 @@ namespace GuildAudits.Migrations; public partial class InitialCreate : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "GuildAudits"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "GuildAudits"); - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "GuildAuditConfigs", - schema: "GuildAudits", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - GuildId = table.Column(type: "bigint unsigned", nullable: false), - GuildAuditEvent = table.Column(type: "int", nullable: false), - ChannelId = table.Column(type: "bigint unsigned", nullable: false), - PingRoles = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => table.PrimaryKey("PK_GuildAuditConfigs", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); - } + migrationBuilder.CreateTable( + name: "GuildAuditConfigs", + schema: "GuildAudits", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GuildId = table.Column(type: "bigint unsigned", nullable: false), + GuildAuditEvent = table.Column(type: "int", nullable: false), + ChannelId = table.Column(type: "bigint unsigned", nullable: false), + PingRoles = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => table.PrimaryKey("PK_GuildAuditConfigs", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); + } protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable( name: "GuildAuditConfigs", diff --git a/backend/GuildAudits/Migrations/20220829141452_GuildAuditIgnoreChannels.cs b/backend/GuildAudits/Migrations/20220829141452_GuildAuditIgnoreChannels.cs index 0bd774288..91888b2d8 100644 --- a/backend/GuildAudits/Migrations/20220829141452_GuildAuditIgnoreChannels.cs +++ b/backend/GuildAudits/Migrations/20220829141452_GuildAuditIgnoreChannels.cs @@ -6,47 +6,47 @@ namespace GuildAudits.Migrations; public partial class GuildAuditIgnoreChannels : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "GuildAuditEvent", - schema: "GuildAudits", - table: "GuildAuditConfigs", - newName: "GuildAuditLogEvent"); - - migrationBuilder.AddColumn( - name: "IgnoreChannels", - schema: "GuildAudits", - table: "GuildAuditConfigs", - type: "longtext", - nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "IgnoreRoles", - schema: "GuildAudits", - table: "GuildAuditConfigs", - type: "longtext", - nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IgnoreChannels", - schema: "GuildAudits", - table: "GuildAuditConfigs"); - - migrationBuilder.DropColumn( - name: "IgnoreRoles", - schema: "GuildAudits", - table: "GuildAuditConfigs"); - - migrationBuilder.RenameColumn( - name: "GuildAuditLogEvent", - schema: "GuildAudits", - table: "GuildAuditConfigs", - newName: "GuildAuditEvent"); - } + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "GuildAuditEvent", + schema: "GuildAudits", + table: "GuildAuditConfigs", + newName: "GuildAuditLogEvent"); + + migrationBuilder.AddColumn( + name: "IgnoreChannels", + schema: "GuildAudits", + table: "GuildAuditConfigs", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "IgnoreRoles", + schema: "GuildAudits", + table: "GuildAuditConfigs", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IgnoreChannels", + schema: "GuildAudits", + table: "GuildAuditConfigs"); + + migrationBuilder.DropColumn( + name: "IgnoreRoles", + schema: "GuildAudits", + table: "GuildAuditConfigs"); + + migrationBuilder.RenameColumn( + name: "GuildAuditLogEvent", + schema: "GuildAudits", + table: "GuildAuditConfigs", + newName: "GuildAuditEvent"); + } } diff --git a/backend/GuildAudits/Services/GuildAuditor.cs b/backend/GuildAudits/Services/GuildAuditor.cs index e83bfe07b..ad23ee6eb 100644 --- a/backend/GuildAudits/Services/GuildAuditor.cs +++ b/backend/GuildAudits/Services/GuildAuditor.cs @@ -51,28 +51,28 @@ public async Task SendEmbed(EmbedBuilder embed, ulong guildId, GuildAuditLogEven var guildConfigRepository = scope.ServiceProvider.GetRequiredService(); embed.WithColor(eventType switch - { - GuildAuditLogEvent.MessageSent => Color.Green, - GuildAuditLogEvent.MessageUpdated => Color.Orange, - GuildAuditLogEvent.MessageDeleted => Color.Red, - GuildAuditLogEvent.UsernameUpdated => Color.Orange, - GuildAuditLogEvent.AvatarUpdated => Color.Orange, - GuildAuditLogEvent.NicknameUpdated => Color.Orange, - GuildAuditLogEvent.UserRolesUpdated => Color.Orange, - GuildAuditLogEvent.UserJoined => Color.Green, - GuildAuditLogEvent.UserRemoved => Color.Red, - GuildAuditLogEvent.BanAdded => Color.Red, - GuildAuditLogEvent.BanRemoved => Color.Green, - GuildAuditLogEvent.InviteCreated => Color.Green, - GuildAuditLogEvent.InviteDeleted => Color.Red, - GuildAuditLogEvent.ThreadCreated => Color.Green, - GuildAuditLogEvent.VoiceJoined => Color.Green, - GuildAuditLogEvent.VoiceLeft => Color.Red, - GuildAuditLogEvent.VoiceMoved => Color.Orange, - GuildAuditLogEvent.ReactionAdded => Color.Green, - GuildAuditLogEvent.ReactionRemoved => Color.Red, - _ => throw new NotImplementedException() - }) + { + GuildAuditLogEvent.MessageSent => Color.Green, + GuildAuditLogEvent.MessageUpdated => Color.Orange, + GuildAuditLogEvent.MessageDeleted => Color.Red, + GuildAuditLogEvent.UsernameUpdated => Color.Orange, + GuildAuditLogEvent.AvatarUpdated => Color.Orange, + GuildAuditLogEvent.NicknameUpdated => Color.Orange, + GuildAuditLogEvent.UserRolesUpdated => Color.Orange, + GuildAuditLogEvent.UserJoined => Color.Green, + GuildAuditLogEvent.UserRemoved => Color.Red, + GuildAuditLogEvent.BanAdded => Color.Red, + GuildAuditLogEvent.BanRemoved => Color.Green, + GuildAuditLogEvent.InviteCreated => Color.Green, + GuildAuditLogEvent.InviteDeleted => Color.Red, + GuildAuditLogEvent.ThreadCreated => Color.Green, + GuildAuditLogEvent.VoiceJoined => Color.Green, + GuildAuditLogEvent.VoiceLeft => Color.Red, + GuildAuditLogEvent.VoiceMoved => Color.Orange, + GuildAuditLogEvent.ReactionAdded => Color.Green, + GuildAuditLogEvent.ReactionRemoved => Color.Red, + _ => throw new NotImplementedException() + }) .WithCurrentTimestamp(); try diff --git a/backend/Invites/Controllers/UserNetworkController.cs b/backend/Invites/Controllers/UserNetworkController.cs index e10a92d05..fa5892149 100644 --- a/backend/Invites/Controllers/UserNetworkController.cs +++ b/backend/Invites/Controllers/UserNetworkController.cs @@ -17,7 +17,7 @@ public class UserNetworkController(IdentityManager identityManager, DiscordRest private readonly InviteRepository _inviteRepository = inviteRepository; [HttpGet("invite")] - public async Task GetInviteNetwork([FromQuery] [Required] string inviteUrl) + public async Task GetInviteNetwork([FromQuery][Required] string inviteUrl) { var identity = await SetupAuthentication(); diff --git a/backend/Invites/Migrations/20220207080747_InitialCreate.cs b/backend/Invites/Migrations/20220207080747_InitialCreate.cs index 8608a176e..698ccdc41 100644 --- a/backend/Invites/Migrations/20220207080747_InitialCreate.cs +++ b/backend/Invites/Migrations/20220207080747_InitialCreate.cs @@ -7,33 +7,33 @@ namespace Invites.Migrations; public partial class InitialCreate : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "Invites"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "Invites"); - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "UserInvites", - schema: "Invites", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - GuildId = table.Column(type: "bigint unsigned", nullable: false), - TargetChannelId = table.Column(type: "bigint unsigned", nullable: false), - JoinedUserId = table.Column(type: "bigint unsigned", nullable: false), - UsedInvite = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - InviteIssuerId = table.Column(type: "bigint unsigned", nullable: false), - JoinedAt = table.Column(type: "datetime(6)", nullable: false), - InviteCreatedAt = table.Column(type: "datetime(6)", nullable: true) - }, - constraints: table => table.PrimaryKey("PK_UserInvites", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); - } + migrationBuilder.CreateTable( + name: "UserInvites", + schema: "Invites", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GuildId = table.Column(type: "bigint unsigned", nullable: false), + TargetChannelId = table.Column(type: "bigint unsigned", nullable: false), + JoinedUserId = table.Column(type: "bigint unsigned", nullable: false), + UsedInvite = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + InviteIssuerId = table.Column(type: "bigint unsigned", nullable: false), + JoinedAt = table.Column(type: "datetime(6)", nullable: false), + InviteCreatedAt = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => table.PrimaryKey("PK_UserInvites", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); + } protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable( name: "UserInvites", diff --git a/backend/Invites/Models/TrackedInvite.cs b/backend/Invites/Models/TrackedInvite.cs index e435c08ac..6f2b47576 100644 --- a/backend/Invites/Models/TrackedInvite.cs +++ b/backend/Invites/Models/TrackedInvite.cs @@ -48,7 +48,7 @@ public TrackedInvite(ulong guildId, string vanityUrl, int uses) public ulong GuildId { get; set; } public DateTime? ExpiresAt { get; set; } - public bool IsExpired() => ExpiresAt == null ? false : ExpiresAt < DateTime.UtcNow; + public bool IsExpired() => ExpiresAt != null && ExpiresAt < DateTime.UtcNow; public bool HasNewUses(int currentUses) => currentUses != Uses; } diff --git a/backend/Launch/Initialize.cs b/backend/Launch/Initialize.cs index 4abd457b6..cf29469df 100644 --- a/backend/Launch/Initialize.cs +++ b/backend/Launch/Initialize.cs @@ -156,7 +156,7 @@ private static Action GetDatabaseOptions() var connectionString = $"Server={databaseSettings.Host};Port={databaseSettings.Port};" + $"Database={databaseSettings.Database};Uid={databaseSettings.User};Pwd={databaseSettings.Pass};"; - + return x => x.UseMySql( connectionString, ServerVersion.AutoDetect(connectionString), diff --git a/backend/Levels/Commands/UpdateAllXp.cs b/backend/Levels/Commands/UpdateAllXp.cs index 2b063bb7e..b6f7a0e7d 100644 --- a/backend/Levels/Commands/UpdateAllXp.cs +++ b/backend/Levels/Commands/UpdateAllXp.cs @@ -1,9 +1,9 @@ using Bot.Abstractions; using Bot.Attributes; -using Discord.Interactions; using Bot.Enums; -using Levels.Data; using Discord; +using Discord.Interactions; +using Levels.Data; using Levels.Models; namespace Levels.Commands; diff --git a/backend/Levels/Controllers/LevelsConfigController.cs b/backend/Levels/Controllers/LevelsConfigController.cs index 4124ec621..18bac3f7f 100644 --- a/backend/Levels/Controllers/LevelsConfigController.cs +++ b/backend/Levels/Controllers/LevelsConfigController.cs @@ -34,7 +34,7 @@ public async Task GetConfig([FromRoute] ulong guildId) var dto = new GuildLevelConfigDto { Id = guildId, - + Coefficients = config.Coefficients, XpInterval = config.XpInterval, @@ -94,13 +94,14 @@ public async Task PutConfig([FromRoute] ulong guildId, [FromBody] existing.Coefficients = config.Coefficients; existing.XpInterval = config.XpInterval; - existing.Experience = new ExperienceConfig() { + existing.Experience = new ExperienceConfig() + { MaximumTextXpGiven = config.MaximumTextXpGiven, MaximumVoiceXpGiven = config.MaximumVoiceXpGiven, MinimumTextXpGiven = config.MinimumTextXpGiven, MinimumVoiceXpGiven = config.MinimumVoiceXpGiven }; - + existing.VoiceXpRequiredMembers = config.VoiceXpRequiredMembers; existing.VoiceXpCountMutedMembers = config.VoiceXpCountMutedMembers; diff --git a/backend/Levels/DTOs/GuildLevelConfigDto.cs b/backend/Levels/DTOs/GuildLevelConfigDto.cs index 5d5ec1a29..0fc967676 100644 --- a/backend/Levels/DTOs/GuildLevelConfigDto.cs +++ b/backend/Levels/DTOs/GuildLevelConfigDto.cs @@ -25,5 +25,5 @@ public class GuildLevelConfigDto public ulong NicknameDisabledReplacement { get; set; } public Dictionary Levels { get; set; } - public Dictionary LevelUpMessageOverrides { get; set; } + public Dictionary LevelUpMessageOverrides { get; set; } } diff --git a/backend/Levels/Models/GuildLevelConfig.cs b/backend/Levels/Models/GuildLevelConfig.cs index a214eae79..19fb655ea 100644 --- a/backend/Levels/Models/GuildLevelConfig.cs +++ b/backend/Levels/Models/GuildLevelConfig.cs @@ -37,7 +37,8 @@ public GuildLevelConfig() { } - public GuildLevelConfig(ulong guildId) { + public GuildLevelConfig(ulong guildId) + { Id = guildId; Experience = new ExperienceConfig() @@ -68,12 +69,12 @@ public GuildLevelConfig(ulong guildId) { public ExperienceConfig GetExperienceConfig(IChannel channel) { Experience ??= new ExperienceConfig() - { - MaximumTextXpGiven = 0, - MaximumVoiceXpGiven = 0, - MinimumTextXpGiven = 0, - MinimumVoiceXpGiven = 0 - }; + { + MaximumTextXpGiven = 0, + MaximumVoiceXpGiven = 0, + MinimumTextXpGiven = 0, + MinimumVoiceXpGiven = 0 + }; ExperienceOverrides ??= []; diff --git a/backend/MOTDs/Migrations/20220207080848_InitialCreate.cs b/backend/MOTDs/Migrations/20220207080848_InitialCreate.cs index 0d81de145..7ad32cb05 100644 --- a/backend/MOTDs/Migrations/20220207080848_InitialCreate.cs +++ b/backend/MOTDs/Migrations/20220207080848_InitialCreate.cs @@ -7,31 +7,31 @@ namespace MOTDs.Migrations; public partial class InitialCreate : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "MOTDs"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "MOTDs"); - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "GuildMotDs", - schema: "MOTDs", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - GuildId = table.Column(type: "bigint unsigned", nullable: false), - UserId = table.Column(type: "bigint unsigned", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - Message = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ShowMotd = table.Column(type: "tinyint(1)", nullable: false) - }, - constraints: table => table.PrimaryKey("PK_GuildMotDs", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); - } + migrationBuilder.CreateTable( + name: "GuildMotDs", + schema: "MOTDs", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GuildId = table.Column(type: "bigint unsigned", nullable: false), + UserId = table.Column(type: "bigint unsigned", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + Message = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ShowMotd = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => table.PrimaryKey("PK_GuildMotDs", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); + } protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable( name: "GuildMotDs", diff --git a/backend/Messaging/Controllers/ScheduledMessageController.cs b/backend/Messaging/Controllers/ScheduledMessageController.cs index 2cf25e53d..f75ef686b 100644 --- a/backend/Messaging/Controllers/ScheduledMessageController.cs +++ b/backend/Messaging/Controllers/ScheduledMessageController.cs @@ -23,7 +23,7 @@ public class ScheduledMessageController(MessagingRepository messagingRepo, Guild [HttpGet] public async Task GetMessages([FromRoute] ulong guildId, - [FromQuery] [Range(0, int.MaxValue)] int page = 0) + [FromQuery][Range(0, int.MaxValue)] int page = 0) { var identity = await SetupAuthentication(); diff --git a/backend/Messaging/Migrations/20220207080818_InitialCreate.cs b/backend/Messaging/Migrations/20220207080818_InitialCreate.cs index a8c29f463..032bca1ad 100644 --- a/backend/Messaging/Migrations/20220207080818_InitialCreate.cs +++ b/backend/Messaging/Migrations/20220207080818_InitialCreate.cs @@ -7,38 +7,38 @@ namespace Messaging.Migrations; public partial class InitialCreate : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "Messaging"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "Messaging"); - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "ScheduledMessages", - schema: "Messaging", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Content = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ScheduledFor = table.Column(type: "datetime(6)", nullable: false), - Status = table.Column(type: "int", nullable: false), - GuildId = table.Column(type: "bigint unsigned", nullable: false), - ChannelId = table.Column(type: "bigint unsigned", nullable: false), - CreatorId = table.Column(type: "bigint unsigned", nullable: false), - LastEditedById = table.Column(type: "bigint unsigned", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - LastEditedAt = table.Column(type: "datetime(6)", nullable: false), - FailureReason = table.Column(type: "int", nullable: true) - }, - constraints: table => table.PrimaryKey("PK_ScheduledMessages", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); - } + migrationBuilder.CreateTable( + name: "ScheduledMessages", + schema: "Messaging", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Content = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ScheduledFor = table.Column(type: "datetime(6)", nullable: false), + Status = table.Column(type: "int", nullable: false), + GuildId = table.Column(type: "bigint unsigned", nullable: false), + ChannelId = table.Column(type: "bigint unsigned", nullable: false), + CreatorId = table.Column(type: "bigint unsigned", nullable: false), + LastEditedById = table.Column(type: "bigint unsigned", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + LastEditedAt = table.Column(type: "datetime(6)", nullable: false), + FailureReason = table.Column(type: "int", nullable: true) + }, + constraints: table => table.PrimaryKey("PK_ScheduledMessages", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); + } protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable( name: "ScheduledMessages", diff --git a/backend/Music/Abstractions/MusicCommand.cs b/backend/Music/Abstractions/MusicCommand.cs index bed1628bb..674d41116 100644 --- a/backend/Music/Abstractions/MusicCommand.cs +++ b/backend/Music/Abstractions/MusicCommand.cs @@ -22,7 +22,7 @@ public override async Task BeforeCommandExecute() throw new UserNotInVoiceChannel(); Player = await Audio.GetPlayerAsync(Context, Music); - + Music.SetCurrentChannelId(Context.Guild.Id, Context.Channel.Id); } } diff --git a/backend/Music/Extensions/CreatePaginator.cs b/backend/Music/Extensions/CreatePaginator.cs index e3f587b77..f8b30547d 100644 --- a/backend/Music/Extensions/CreatePaginator.cs +++ b/backend/Music/Extensions/CreatePaginator.cs @@ -14,20 +14,20 @@ public static async Task SendPaginator(this InteractiveService interactive, IEnu switch (pageBuilders.Length) { case > 1: - { - Paginator paginator = new StaticPaginatorBuilder() - .WithPages(pageBuilders) - .WithDefaultEmotes() - .AddUser(context.User) - .WithFooter(PaginatorFooter.PageNumber) - .WithActionOnCancellation(ActionOnStop.DeleteInput) - .WithActionOnTimeout(ActionOnStop.DeleteInput) - .Build(); + { + Paginator paginator = new StaticPaginatorBuilder() + .WithPages(pageBuilders) + .WithDefaultEmotes() + .AddUser(context.User) + .WithFooter(PaginatorFooter.PageNumber) + .WithActionOnCancellation(ActionOnStop.DeleteInput) + .WithActionOnTimeout(ActionOnStop.DeleteInput) + .Build(); - await interactive.SendPaginatorAsync(paginator, context.Interaction, - responseType: InteractionResponseType.DeferredChannelMessageWithSource); - break; - } + await interactive.SendPaginatorAsync(paginator, context.Interaction, + responseType: InteractionResponseType.DeferredChannelMessageWithSource); + break; + } case 1: await context.Interaction.ModifyOriginalResponseAsync(x => { diff --git a/backend/Music/Extensions/GetPlayer.cs b/backend/Music/Extensions/GetPlayer.cs index 1777f6131..09cd338ce 100644 --- a/backend/Music/Extensions/GetPlayer.cs +++ b/backend/Music/Extensions/GetPlayer.cs @@ -1,14 +1,13 @@ -using Lavalink4NET.Players.Vote; -using Lavalink4NET.Players; -using Music.Exceptions; +using Discord; using Lavalink4NET; -using Music.Services; -using Discord; using Lavalink4NET.DiscordNet; using Lavalink4NET.Integrations.SponsorBlock; -using System.Collections.Immutable; -using System.Numerics; using Lavalink4NET.Integrations.SponsorBlock.Extensions; +using Lavalink4NET.Players; +using Lavalink4NET.Players.Vote; +using Music.Exceptions; +using Music.Services; +using System.Collections.Immutable; namespace Music.Extensions; diff --git a/backend/Music/Music.csproj b/backend/Music/Music.csproj index 9901d24ab..e6ef0e388 100644 --- a/backend/Music/Music.csproj +++ b/backend/Music/Music.csproj @@ -9,15 +9,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/backend/Music/MusicModule.cs b/backend/Music/MusicModule.cs index daa80ca1c..7143ced38 100644 --- a/backend/Music/MusicModule.cs +++ b/backend/Music/MusicModule.cs @@ -73,9 +73,11 @@ public static IPAddress GetMyIp() using var webclient = new HttpClient(); foreach (var service in services) - try { + try + { return IPAddress.Parse(webclient.GetStringAsync(service).Result); - } catch { } + } + catch { } return null; } diff --git a/backend/Music/Services/MusicService.cs b/backend/Music/Services/MusicService.cs index a3f11a84b..9e7f30ea3 100644 --- a/backend/Music/Services/MusicService.cs +++ b/backend/Music/Services/MusicService.cs @@ -87,7 +87,7 @@ public SocketTextChannel GetMusicChannel(ILavalinkPlayer player) return _client.GetGuild(player.GuildId).GetTextChannel(channelId); } - + private async Task CheckLeft(SocketUser user, SocketVoiceState originalState, SocketVoiceState newState) { if (newState.VoiceChannel == null) @@ -111,7 +111,7 @@ public void SetStartTimeAsCurrent(ulong guildId) StartTimes[guildId] = DateTime.UtcNow; } } - + public DateTime GetStartTime(ulong guildId) { lock (StartTimes) diff --git a/backend/PrivateVCs/Commands/CreateVc.cs b/backend/PrivateVCs/Commands/CreateVc.cs index e277276a6..1492aba99 100644 --- a/backend/PrivateVCs/Commands/CreateVc.cs +++ b/backend/PrivateVCs/Commands/CreateVc.cs @@ -86,7 +86,7 @@ await RespondInteraction( ); return; } - + if (user.VoiceChannel == null) { await RespondInteraction( @@ -167,7 +167,7 @@ await newChannel.AddPermissionOverwriteAsync(staffRole, ) ); } - + await user.ModifyAsync(properties => properties.Channel = new Optional(newChannel)); await RespondInteraction( diff --git a/backend/PrivateVCs/Data/PrivateVcDatabase.cs b/backend/PrivateVCs/Data/PrivateVcDatabase.cs index c403b7489..b833c9b55 100644 --- a/backend/PrivateVCs/Data/PrivateVcDatabase.cs +++ b/backend/PrivateVCs/Data/PrivateVcDatabase.cs @@ -8,7 +8,7 @@ namespace PrivateVcs.Data; public class PrivateVcDatabase(DbContextOptions options) : DataContext(options), IDataContextCreate { public DbSet PrivateVcConfigs { get; set; } - + public static void AddContextToServiceProvider(Action optionsAction, IServiceCollection serviceCollection) => serviceCollection.AddDbContext(optionsAction); diff --git a/backend/PrivateVCs/Services/VcChecker.cs b/backend/PrivateVCs/Services/VcChecker.cs index f34d875c6..0593805b4 100644 --- a/backend/PrivateVCs/Services/VcChecker.cs +++ b/backend/PrivateVCs/Services/VcChecker.cs @@ -33,7 +33,8 @@ public void RegisterEvents() await CheckRemoveVCs(guild); }; - _client.UserVoiceStateUpdated += async (_, voiceChannel, _) => { + _client.UserVoiceStateUpdated += async (_, voiceChannel, _) => + { if (voiceChannel.VoiceChannel is not null) await CheckRemoveVCs(voiceChannel.VoiceChannel.Guild); }; @@ -146,7 +147,7 @@ private async Task ChannelUpdated(SocketChannel _, SocketChannel newChannel) return; var guild = voiceChannel.Guild; - + using var scope = _serviceProvider.CreateScope(); var config = await scope.ServiceProvider.GetRequiredService() @@ -211,19 +212,19 @@ await dm.SendMessageAsync( switch (authorized.TargetType) { case PermissionTarget.Role: - { - var role = guild.GetRole(authorized.TargetId); - if (role.Permissions.MentionEveryone) - continue; - break; - } + { + var role = guild.GetRole(authorized.TargetId); + if (role.Permissions.MentionEveryone) + continue; + break; + } case PermissionTarget.User: - { - var user = guild.GetUser(authorized.TargetId); - if (user.GuildPermissions.MentionEveryone) - continue; - break; - } + { + var user = guild.GetUser(authorized.TargetId); + if (user.GuildPermissions.MentionEveryone) + continue; + break; + } default: throw new InvalidDataException($"Unknown target type for private VCs of: {authorized.TargetType}"); } diff --git a/backend/Punishments/Commands/Unwarn.cs b/backend/Punishments/Commands/Unwarn.cs index e6f95003c..11a5eb3d4 100644 --- a/backend/Punishments/Commands/Unwarn.cs +++ b/backend/Punishments/Commands/Unwarn.cs @@ -33,7 +33,7 @@ public async Task UnwarnCommand([Summary("user", "User to unwarn")] IUser user) } var mCase = modCases.FirstOrDefault(); - + var embed = new EmbedBuilder() .WithAuthor(user) .WithDescription($"Found last warning of `{mCase.Title}` for {mCase.Username}. Do you want to delete the warning?") diff --git a/backend/Punishments/Controllers/ModCaseController.cs b/backend/Punishments/Controllers/ModCaseController.cs index dc140bdca..fc8407ad6 100644 --- a/backend/Punishments/Controllers/ModCaseController.cs +++ b/backend/Punishments/Controllers/ModCaseController.cs @@ -151,7 +151,7 @@ public async Task CreateItem([FromRoute] ulong guildId, [FromBody [HttpGet] public async Task GetAllItems([FromRoute] ulong guildId, - [FromQuery] [Range(0, int.MaxValue)] int startPage = 0) + [FromQuery][Range(0, int.MaxValue)] int startPage = 0) { var identity = await SetupAuthentication(); diff --git a/backend/Punishments/Controllers/ModCaseTableController.cs b/backend/Punishments/Controllers/ModCaseTableController.cs index 67894dc7d..b8169929a 100644 --- a/backend/Punishments/Controllers/ModCaseTableController.cs +++ b/backend/Punishments/Controllers/ModCaseTableController.cs @@ -25,18 +25,18 @@ public class ModCaseTableController(GuildConfigRepository guildConfigRepository, [HttpPost("modcasetable")] public async Task GetAllModCases([FromRoute] ulong guildId, - [FromQuery] [Range(0, int.MaxValue)] int startPage = 0, [FromBody] ModCaseTableFilterDto search = null) => + [FromQuery][Range(0, int.MaxValue)] int startPage = 0, [FromBody] ModCaseTableFilterDto search = null) => Ok(await GenerateTable(guildId, ModCaseTableType.Default, startPage, search)); [HttpPost("expiringpunishment")] public async Task GetExpiringPunishments([FromRoute] ulong guildId, - [FromQuery] [Range(0, int.MaxValue)] int startPage = 0, [FromBody] ModCaseTableFilterDto search = null) => + [FromQuery][Range(0, int.MaxValue)] int startPage = 0, [FromBody] ModCaseTableFilterDto search = null) => Ok(await GenerateTable(guildId, ModCaseTableType.OnlyPunishments, startPage, search, ModCaseTableSortType.SortByExpiring)); [HttpPost("casebin")] public async Task GetDeletedModCases([FromRoute] ulong guildId, - [FromQuery] [Range(0, int.MaxValue)] int startPage = 0, [FromBody] ModCaseTableFilterDto search = null) => + [FromQuery][Range(0, int.MaxValue)] int startPage = 0, [FromBody] ModCaseTableFilterDto search = null) => Ok(await GenerateTable(guildId, ModCaseTableType.OnlyBin, startPage, search, ModCaseTableSortType.SortByDeleting)); diff --git a/backend/Punishments/Data/ModCaseTemplateRepository.cs b/backend/Punishments/Data/ModCaseTemplateRepository.cs index 652e0dbfe..b296f9cc8 100644 --- a/backend/Punishments/Data/ModCaseTemplateRepository.cs +++ b/backend/Punishments/Data/ModCaseTemplateRepository.cs @@ -65,20 +65,13 @@ public async Task> GetTemplatesBasedOnPermissions(Identity return filteredTemplates; } - private async Task AllowedToView(ModCaseTemplate template, Identity identity) - { - if (identity.GetCurrentUser().IsBot) - return true; - - return await identity.IsSiteAdmin() - ? true - : template.UserId == Identity.Id - ? true - : template.ViewPermission switch - { - ViewPermission.Self => false, - ViewPermission.Global => true, - _ => await identity.HasPermission(DiscordPermission.Moderator, template.CreatedForGuildId) - }; - } + private async Task AllowedToView(ModCaseTemplate template, Identity identity) => identity.GetCurrentUser().IsBot +|| await identity.IsSiteAdmin() +|| template.UserId == Identity.Id +|| template.ViewPermission switch +{ + ViewPermission.Self => false, + ViewPermission.Global => true, + _ => await identity.HasPermission(DiscordPermission.Moderator, template.CreatedForGuildId) +}; } diff --git a/backend/Punishments/Extensions/IdentityPermissions.cs b/backend/Punishments/Extensions/IdentityPermissions.cs index c4e906b8f..f168fa12f 100644 --- a/backend/Punishments/Extensions/IdentityPermissions.cs +++ b/backend/Punishments/Extensions/IdentityPermissions.cs @@ -67,8 +67,7 @@ public static async Task HasPermission(this Identity identity, ApiActionPe }; return await identity.HasPermission(DiscordPermission.Admin, modCase.GuildId) - ? true - : await identity.HasPermission(DiscordPermission.Moderator, modCase.GuildId) && +|| await identity.HasPermission(DiscordPermission.Moderator, modCase.GuildId) && identity.HasPermission(x, modCase.GuildId); } catch (ResourceNotFoundException) diff --git a/backend/Punishments/Migrations/20220225095811_InitialCreate.cs b/backend/Punishments/Migrations/20220225095811_InitialCreate.cs index 29efc9540..cf78fe33a 100644 --- a/backend/Punishments/Migrations/20220225095811_InitialCreate.cs +++ b/backend/Punishments/Migrations/20220225095811_InitialCreate.cs @@ -7,130 +7,130 @@ namespace Punishments.Migrations; public partial class InitialCreate : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "Punishments"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "Punishments"); - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "ModCases", - schema: "Punishments", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CaseId = table.Column(type: "int", nullable: false), - GuildId = table.Column(type: "bigint unsigned", nullable: false), - Title = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Description = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - UserId = table.Column(type: "bigint unsigned", nullable: false), - Username = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Discriminator = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Nickname = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ModId = table.Column(type: "bigint unsigned", nullable: false), - HighSeverity = table.Column(type: "tinyint(1)", nullable: true), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - OccurredAt = table.Column(type: "datetime(6)", nullable: false), - LastEditedAt = table.Column(type: "datetime(6)", nullable: false), - LastEditedByModId = table.Column(type: "bigint unsigned", nullable: false), - Labels = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Others = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Valid = table.Column(type: "tinyint(1)", nullable: true), - CreationType = table.Column(type: "int", nullable: false), - PunishmentType = table.Column(type: "int", nullable: false), - PunishedUntil = table.Column(type: "datetime(6)", nullable: true), - PunishmentActive = table.Column(type: "tinyint(1)", nullable: false), - AllowComments = table.Column(type: "tinyint(1)", nullable: false), - LockedByUserId = table.Column(type: "bigint unsigned", nullable: false), - LockedAt = table.Column(type: "datetime(6)", nullable: true), - MarkedToDeleteAt = table.Column(type: "datetime(6)", nullable: true), - DeletedByUserId = table.Column(type: "bigint unsigned", nullable: false) - }, - constraints: table => table.PrimaryKey("PK_ModCases", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "ModCases", + schema: "Punishments", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CaseId = table.Column(type: "int", nullable: false), + GuildId = table.Column(type: "bigint unsigned", nullable: false), + Title = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "bigint unsigned", nullable: false), + Username = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Discriminator = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Nickname = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ModId = table.Column(type: "bigint unsigned", nullable: false), + HighSeverity = table.Column(type: "tinyint(1)", nullable: true), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + OccurredAt = table.Column(type: "datetime(6)", nullable: false), + LastEditedAt = table.Column(type: "datetime(6)", nullable: false), + LastEditedByModId = table.Column(type: "bigint unsigned", nullable: false), + Labels = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Others = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Valid = table.Column(type: "tinyint(1)", nullable: true), + CreationType = table.Column(type: "int", nullable: false), + PunishmentType = table.Column(type: "int", nullable: false), + PunishedUntil = table.Column(type: "datetime(6)", nullable: true), + PunishmentActive = table.Column(type: "tinyint(1)", nullable: false), + AllowComments = table.Column(type: "tinyint(1)", nullable: false), + LockedByUserId = table.Column(type: "bigint unsigned", nullable: false), + LockedAt = table.Column(type: "datetime(6)", nullable: true), + MarkedToDeleteAt = table.Column(type: "datetime(6)", nullable: true), + DeletedByUserId = table.Column(type: "bigint unsigned", nullable: false) + }, + constraints: table => table.PrimaryKey("PK_ModCases", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "ModCaseTemplates", - schema: "Punishments", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(type: "bigint unsigned", nullable: false), - TemplateName = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedForGuildId = table.Column(type: "bigint unsigned", nullable: false), - ViewPermission = table.Column(type: "int", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - CaseTitle = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CaseDescription = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CaseLabels = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CasePunishmentType = table.Column(type: "int", nullable: false), - CasePunishedUntil = table.Column(type: "datetime(6)", nullable: true), - HandlePunishment = table.Column(type: "tinyint(1)", nullable: false), - HighSeverity = table.Column(type: "tinyint(1)", nullable: true) - }, - constraints: table => table.PrimaryKey("PK_ModCaseTemplates", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "ModCaseTemplates", + schema: "Punishments", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(type: "bigint unsigned", nullable: false), + TemplateName = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedForGuildId = table.Column(type: "bigint unsigned", nullable: false), + ViewPermission = table.Column(type: "int", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + CaseTitle = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CaseDescription = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CaseLabels = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CasePunishmentType = table.Column(type: "int", nullable: false), + CasePunishedUntil = table.Column(type: "datetime(6)", nullable: true), + HandlePunishment = table.Column(type: "tinyint(1)", nullable: false), + HighSeverity = table.Column(type: "tinyint(1)", nullable: true) + }, + constraints: table => table.PrimaryKey("PK_ModCaseTemplates", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "ModCaseComments", - schema: "Punishments", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ModCaseId = table.Column(type: "int", nullable: false), - Message = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - UserId = table.Column(type: "bigint unsigned", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ModCaseComments", x => x.Id); - table.ForeignKey( - name: "FK_ModCaseComments_ModCases_ModCaseId", - column: x => x.ModCaseId, - principalSchema: "Punishments", - principalTable: "ModCases", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "ModCaseComments", + schema: "Punishments", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ModCaseId = table.Column(type: "int", nullable: false), + Message = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "bigint unsigned", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ModCaseComments", x => x.Id); + table.ForeignKey( + name: "FK_ModCaseComments_ModCases_ModCaseId", + column: x => x.ModCaseId, + principalSchema: "Punishments", + principalTable: "ModCases", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateIndex( - name: "IX_ModCaseComments_ModCaseId", - schema: "Punishments", - table: "ModCaseComments", - column: "ModCaseId"); - } + migrationBuilder.CreateIndex( + name: "IX_ModCaseComments_ModCaseId", + schema: "Punishments", + table: "ModCaseComments", + column: "ModCaseId"); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ModCaseComments", - schema: "Punishments"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ModCaseComments", + schema: "Punishments"); - migrationBuilder.DropTable( - name: "ModCaseTemplates", - schema: "Punishments"); + migrationBuilder.DropTable( + name: "ModCaseTemplates", + schema: "Punishments"); - migrationBuilder.DropTable( - name: "ModCases", - schema: "Punishments"); - } + migrationBuilder.DropTable( + name: "ModCases", + schema: "Punishments"); + } } diff --git a/backend/Punishments/Migrations/20220830111440_SeverityType.cs b/backend/Punishments/Migrations/20220830111440_SeverityType.cs index ff8012e33..fc9ff1f78 100644 --- a/backend/Punishments/Migrations/20220830111440_SeverityType.cs +++ b/backend/Punishments/Migrations/20220830111440_SeverityType.cs @@ -6,34 +6,34 @@ namespace Punishments.Migrations; public partial class SeverityType : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "HighSeverity", - schema: "Punishments", - table: "ModCases"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "HighSeverity", + schema: "Punishments", + table: "ModCases"); - migrationBuilder.AddColumn( - name: "Severity", - schema: "Punishments", - table: "ModCases", - type: "int", - nullable: false, - defaultValue: 0); - } + migrationBuilder.AddColumn( + name: "Severity", + schema: "Punishments", + table: "ModCases", + type: "int", + nullable: false, + defaultValue: 0); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Severity", - schema: "Punishments", - table: "ModCases"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Severity", + schema: "Punishments", + table: "ModCases"); - migrationBuilder.AddColumn( - name: "HighSeverity", - schema: "Punishments", - table: "ModCases", - type: "tinyint(1)", - nullable: true); - } + migrationBuilder.AddColumn( + name: "HighSeverity", + schema: "Punishments", + table: "ModCases", + type: "tinyint(1)", + nullable: true); + } } diff --git a/backend/Punishments/Migrations/20220830122330_TemplateSeverityType.cs b/backend/Punishments/Migrations/20220830122330_TemplateSeverityType.cs index 29c8779df..403c61510 100644 --- a/backend/Punishments/Migrations/20220830122330_TemplateSeverityType.cs +++ b/backend/Punishments/Migrations/20220830122330_TemplateSeverityType.cs @@ -6,34 +6,34 @@ namespace Punishments.Migrations; public partial class TemplateSeverityType : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "HighSeverity", - schema: "Punishments", - table: "ModCaseTemplates"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "HighSeverity", + schema: "Punishments", + table: "ModCaseTemplates"); - migrationBuilder.AddColumn( - name: "CaseSeverityType", - schema: "Punishments", - table: "ModCaseTemplates", - type: "int", - nullable: false, - defaultValue: 0); - } + migrationBuilder.AddColumn( + name: "CaseSeverityType", + schema: "Punishments", + table: "ModCaseTemplates", + type: "int", + nullable: false, + defaultValue: 0); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CaseSeverityType", - schema: "Punishments", - table: "ModCaseTemplates"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CaseSeverityType", + schema: "Punishments", + table: "ModCaseTemplates"); - migrationBuilder.AddColumn( - name: "HighSeverity", - schema: "Punishments", - table: "ModCaseTemplates", - type: "tinyint(1)", - nullable: true); - } + migrationBuilder.AddColumn( + name: "HighSeverity", + schema: "Punishments", + table: "ModCaseTemplates", + type: "tinyint(1)", + nullable: true); + } } diff --git a/backend/Role Reactions/Abstractions/MenuHandler.cs b/backend/Role Reactions/Abstractions/MenuHandler.cs index 2e5203a04..caa202767 100644 --- a/backend/Role Reactions/Abstractions/MenuHandler.cs +++ b/backend/Role Reactions/Abstractions/MenuHandler.cs @@ -1,5 +1,5 @@ -using Discord.Interactions; -using Discord; +using Discord; +using Discord.Interactions; using Microsoft.Extensions.DependencyInjection; using RoleReactions.Data; diff --git a/backend/Role Reactions/Commands/RemoveAssignedRole.cs b/backend/Role Reactions/Commands/RemoveAssignedRole.cs index 6c6b82d54..c4f921faa 100644 --- a/backend/Role Reactions/Commands/RemoveAssignedRole.cs +++ b/backend/Role Reactions/Commands/RemoveAssignedRole.cs @@ -56,7 +56,7 @@ await RespondInteraction($"Role menu `{menu.Name}` does not have a message relat $"Please delete and recreate the menu."); return; } - + menu.RoleToEmote.Remove(role.Id); await Database.SaveChangesAsync(); diff --git a/backend/UserMaps/Migrations/20220207080957_InitialCreate.cs b/backend/UserMaps/Migrations/20220207080957_InitialCreate.cs index 42cc87247..2686fbb39 100644 --- a/backend/UserMaps/Migrations/20220207080957_InitialCreate.cs +++ b/backend/UserMaps/Migrations/20220207080957_InitialCreate.cs @@ -7,32 +7,32 @@ namespace UserMaps.Migrations; public partial class InitialCreate : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "UserMaps"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "UserMaps"); - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "UserMaps", - schema: "UserMaps", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - GuildId = table.Column(type: "bigint unsigned", nullable: false), - UserA = table.Column(type: "bigint unsigned", nullable: false), - UserB = table.Column(type: "bigint unsigned", nullable: false), - CreatorUserId = table.Column(type: "bigint unsigned", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - Reason = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => table.PrimaryKey("PK_UserMaps", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); - } + migrationBuilder.CreateTable( + name: "UserMaps", + schema: "UserMaps", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GuildId = table.Column(type: "bigint unsigned", nullable: false), + UserA = table.Column(type: "bigint unsigned", nullable: false), + UserB = table.Column(type: "bigint unsigned", nullable: false), + CreatorUserId = table.Column(type: "bigint unsigned", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + Reason = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => table.PrimaryKey("PK_UserMaps", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); + } protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable( name: "UserMaps", diff --git a/backend/UserNotes/Migrations/20220207081023_InitialCreate.cs b/backend/UserNotes/Migrations/20220207081023_InitialCreate.cs index 2a17c0b6c..73e15eb90 100644 --- a/backend/UserNotes/Migrations/20220207081023_InitialCreate.cs +++ b/backend/UserNotes/Migrations/20220207081023_InitialCreate.cs @@ -7,31 +7,31 @@ namespace UserNotes.Migrations; public partial class InitialCreate : Migration { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "UserNotes"); + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "UserNotes"); - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); - migrationBuilder.CreateTable( - name: "UserNotes", - schema: "UserNotes", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - GuildId = table.Column(type: "bigint unsigned", nullable: false), - UserId = table.Column(type: "bigint unsigned", nullable: false), - Description = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatorId = table.Column(type: "bigint unsigned", nullable: false), - UpdatedAt = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => table.PrimaryKey("PK_UserNotes", x => x.Id)) - .Annotation("MySql:CharSet", "utf8mb4"); - } + migrationBuilder.CreateTable( + name: "UserNotes", + schema: "UserNotes", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GuildId = table.Column(type: "bigint unsigned", nullable: false), + UserId = table.Column(type: "bigint unsigned", nullable: false), + Description = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatorId = table.Column(type: "bigint unsigned", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => table.PrimaryKey("PK_UserNotes", x => x.Id)) + .Annotation("MySql:CharSet", "utf8mb4"); + } protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable( name: "UserNotes", diff --git a/backend/Utilities/Commands/Cleanup.cs b/backend/Utilities/Commands/Cleanup.cs index 0637bb985..56bb44b49 100644 --- a/backend/Utilities/Commands/Cleanup.cs +++ b/backend/Utilities/Commands/Cleanup.cs @@ -117,17 +117,17 @@ private static async Task IterateAndDeleteChannels(ITextChannel channel, in switch (toDelete.Count) { case >= 2: - { - RequestOptions options = new() { - AuditLogReason = - $"Bulkdelete by {currentActor.Username} ({currentActor.Id})." - }; - - await channel.DeleteMessagesAsync(toDelete, options); - toDelete.Clear(); - break; - } + RequestOptions options = new() + { + AuditLogReason = + $"Bulkdelete by {currentActor.Username} ({currentActor.Id})." + }; + + await channel.DeleteMessagesAsync(toDelete, options); + toDelete.Clear(); + break; + } case > 0: await toDelete.First().DeleteAsync(); toDelete.Clear();