diff --git a/ConsoleService.cs b/ConsoleService.cs index 25e7244..2dc42bc 100644 --- a/ConsoleService.cs +++ b/ConsoleService.cs @@ -12,6 +12,7 @@ namespace vassago public ConsoleService(IConfiguration aspConfig) { Shared.DBConnectionString = aspConfig["DBConnectionString"]; + Shared.SetupSlashCommands = aspConfig["SetupSlashCommands"]?.ToLower() == "true"; DiscordTokens = aspConfig.GetSection("DiscordTokens").Get>(); TwitchConfigs = aspConfig.GetSection("TwitchConfigs").Get>(); Conversion.Converter.Load(aspConfig["ExchangePairsLocation"]); diff --git a/Conversion/Converter.cs b/Conversion/Converter.cs index c6fb706..cacf43b 100644 --- a/Conversion/Converter.cs +++ b/Conversion/Converter.cs @@ -80,12 +80,12 @@ namespace vassago.Conversion public static string Convert(decimal numericTerm, string sourceunit, string destinationUnit) { - var normalizedSourceUnit = normalizeUnit(sourceunit); + var normalizedSourceUnit = NormalizeUnit(sourceunit); if (string.IsNullOrWhiteSpace(normalizedSourceUnit)) { return $"parse failure: what's {sourceunit}?"; } - var normalizedDestUnit = normalizeUnit(destinationUnit); + var normalizedDestUnit = NormalizeUnit(destinationUnit); if (string.IsNullOrWhiteSpace(normalizedDestUnit)) { return $"parse failure: what's {destinationUnit}?"; @@ -127,11 +127,10 @@ namespace vassago.Conversion return $"{String.Format("{0:N}", accumulator)} {normalizedDestUnit}"; } } - return "you can never read this."; } return "dimensional analysis failure - I know those units but can't find a path between them."; } - private static string normalizeUnit(string unit) + private static string NormalizeUnit(string unit) { if(string.IsNullOrWhiteSpace(unit)) return null; @@ -150,11 +149,11 @@ namespace vassago.Conversion } if (normalizedUnit.EndsWith("es")) { - return normalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 2)); + return NormalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 2)); } else if (normalizedUnit.EndsWith('s')) { - return normalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 1)); + return NormalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 1)); } return null; } diff --git a/Migrations/20230704160720_initial.Designer.cs b/Migrations/20230704160720_initial.Designer.cs index 851e4d9..8c8fcc6 100644 --- a/Migrations/20230704160720_initial.Designer.cs +++ b/Migrations/20230704160720_initial.Designer.cs @@ -13,7 +13,7 @@ namespace vassago.Migrations { [DbContext(typeof(ChattingContext))] [Migration("20230704160720_initial")] - partial class initial + partial class Initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/Migrations/20230704160720_initial.cs b/Migrations/20230704160720_initial.cs index 36ae1bb..f7d14e9 100644 --- a/Migrations/20230704160720_initial.cs +++ b/Migrations/20230704160720_initial.cs @@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace vassago.Migrations { /// - public partial class initial : Migration + public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) diff --git a/Migrations/20231203193139_channeltype.Designer.cs b/Migrations/20231203193139_channeltype.Designer.cs index fe7ab7b..9564825 100644 --- a/Migrations/20231203193139_channeltype.Designer.cs +++ b/Migrations/20231203193139_channeltype.Designer.cs @@ -13,7 +13,7 @@ namespace vassago.Migrations { [DbContext(typeof(ChattingContext))] [Migration("20231203193139_channeltype")] - partial class channeltype + partial class ChannelType { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/Migrations/20231203193139_channeltype.cs b/Migrations/20231203193139_channeltype.cs index e9ede1d..6616110 100644 --- a/Migrations/20231203193139_channeltype.cs +++ b/Migrations/20231203193139_channeltype.cs @@ -5,7 +5,7 @@ namespace vassago.Migrations { /// - public partial class channeltype : Migration + public partial class ChannelType : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) diff --git a/Migrations/20240510202057_channelpermissions_partofchannel.Designer.cs b/Migrations/20240510202057_channelpermissions_partofchannel.Designer.cs index b952ab0..dd30fcf 100644 --- a/Migrations/20240510202057_channelpermissions_partofchannel.Designer.cs +++ b/Migrations/20240510202057_channelpermissions_partofchannel.Designer.cs @@ -13,7 +13,7 @@ namespace vassago.Migrations { [DbContext(typeof(ChattingContext))] [Migration("20240510202057_channelpermissions_partofchannel")] - partial class channelpermissions_partofchannel + partial class Channelpermissions_partofchannel { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/Migrations/20240510202057_channelpermissions_partofchannel.cs b/Migrations/20240510202057_channelpermissions_partofchannel.cs index 7a8ef41..0b152f4 100644 --- a/Migrations/20240510202057_channelpermissions_partofchannel.cs +++ b/Migrations/20240510202057_channelpermissions_partofchannel.cs @@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace vassago.Migrations { /// - public partial class channelpermissions_partofchannel : Migration + public partial class Channelpermissions_partofchannel : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) diff --git a/Migrations/20250204004906_cascade.Designer.cs b/Migrations/20250204004906_cascade.Designer.cs index b1dc86b..9909403 100644 --- a/Migrations/20250204004906_cascade.Designer.cs +++ b/Migrations/20250204004906_cascade.Designer.cs @@ -13,7 +13,7 @@ namespace vassago.Migrations { [DbContext(typeof(ChattingContext))] [Migration("20250204004906_cascade")] - partial class cascade + partial class Cascade { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/Migrations/20250204004906_cascade.cs b/Migrations/20250204004906_cascade.cs index bafb6d6..708078b 100644 --- a/Migrations/20250204004906_cascade.cs +++ b/Migrations/20250204004906_cascade.cs @@ -5,7 +5,7 @@ namespace vassago.Migrations { /// - public partial class cascade : Migration + public partial class Cascade : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -130,4 +130,4 @@ namespace vassago.Migrations principalColumn: "Id"); } } -} +} \ No newline at end of file diff --git a/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs b/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs index a1cba8f..088c2b2 100644 --- a/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs +++ b/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs @@ -17,23 +17,25 @@ namespace vassago.ProtocolInterfaces.DiscordInterface Id = "freedomunits", UpdatedAt = new DateTime(2023, 5, 21, 13, 3, 0), guild = 825293851110801428, //TODO: demagic this magic number - register = register_FreedomUnits + register = Register_FreedomUnits } }; public static async Task Register(DiscordSocketClient client) { - return; - var commandsInContext = await client.GetGlobalApplicationCommandsAsync(); - await Register(client, commandsInContext, null); - foreach (var guild in client.Guilds) + if(Shared.SetupSlashCommands) { - try + var commandsInContext = await client.GetGlobalApplicationCommandsAsync(); + await Register(client, commandsInContext, null); + foreach (var guild in client.Guilds) { - await Register(client, await guild.GetApplicationCommandsAsync(), guild); - } - catch (HttpException ex) - { - Console.Error.WriteLine($"error registering slash commands for guild {guild.Name} (id {guild.Id}) - {ex.Message}"); + try + { + await Register(client, await guild.GetApplicationCommandsAsync(), guild); + } + catch (HttpException ex) + { + Console.Error.WriteLine($"error registering slash commands for guild {guild.Name} (id {guild.Id}) - {ex.Message}"); + } } } } @@ -66,7 +68,7 @@ namespace vassago.ProtocolInterfaces.DiscordInterface } } - private static async Task register_FreedomUnits(bool isNew, DiscordSocketClient client, SocketGuild guild) + private static async Task Register_FreedomUnits(bool isNew, DiscordSocketClient client, SocketGuild guild) { var builtCommand = new SlashCommandBuilder() .WithName("freedomunits") diff --git a/Shared.cs b/Shared.cs index 39228f0..6c4b66d 100644 --- a/Shared.cs +++ b/Shared.cs @@ -10,4 +10,5 @@ public static class Shared public static Random r = new Random(); public static string DBConnectionString { get; set; } public static HttpClient HttpClient { get; internal set; } = new HttpClient(); + public static bool SetupSlashCommands { get; set; } } diff --git a/WebInterface/Controllers/ChannelsController.cs b/WebInterface/Controllers/ChannelsController.cs index a5c4c95..44efc0c 100644 --- a/WebInterface/Controllers/ChannelsController.cs +++ b/WebInterface/Controllers/ChannelsController.cs @@ -10,7 +10,7 @@ namespace vassago.WebInterface.Controllers; public class ChannelsController() : Controller { - public async Task Details(Guid id) + public IActionResult Details(Guid id) { var allChannels = Rememberer.ChannelsOverview(); if(allChannels == null) diff --git a/WebInterface/Views/Channels/Details.cshtml b/WebInterface/Views/Channels/Details.cshtml index 4a40142..fbdd57b 100644 --- a/WebInterface/Views/Channels/Details.cshtml +++ b/WebInterface/Views/Channels/Details.cshtml @@ -19,7 +19,7 @@ Channel type - @(ThisChannel.ChannelType != null ? Enumerations.GetDescription(ThisChannel.ChannelType) : "?") + @(Enumerations.GetDescription(ThisChannel.ChannelType)) Lewdness Filter Level diff --git a/appsettings.json b/appsettings.json index 143a993..51f6b4d 100644 --- a/appsettings.json +++ b/appsettings.json @@ -13,5 +13,6 @@ "TwitchConfigs": [ ], "exchangePairsLocation": "assets/exchangepairs.json", - "DBConnectionString": "Host=azure.club;Database=db;Username=user;Password=password" + "DBConnectionString": "Host=azure.club;Database=db;Username=user;Password=password", + "SetupSlashCommands": false } diff --git a/vassago.csproj b/vassago.csproj index dae7d44..e68e0b4 100644 --- a/vassago.csproj +++ b/vassago.csproj @@ -20,7 +20,7 @@ - +