From 4aa5dce40af0ea138aeed1d4a03fd4452a349934 Mon Sep 17 00:00:00 2001 From: "Tobias Burdow [Kaleidox]" Date: Wed, 15 Nov 2023 16:39:31 +0100 Subject: [PATCH] Update BigotryFilter.cs --- common/BigotryFilter.cs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/common/BigotryFilter.cs b/common/BigotryFilter.cs index 6f0ff10..c81eef1 100644 --- a/common/BigotryFilter.cs +++ b/common/BigotryFilter.cs @@ -11,19 +11,28 @@ public sealed class BigotryFilter static BigotryFilter() { - var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "comroid", "pronouns.txt"); + try + { + var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "comroid", "pronouns.txt"); - string content; - if (File.Exists(path)) - content = File.ReadAllText(path); - else + string content; + if (File.Exists(path)) + content = File.ReadAllText(path); + else + { + Console.Write("Please enter your preferred pronouns: "); + content = Console.ReadLine() ?? throw new NullReferenceException("No input detected"); + File.WriteAllText(path, content); + } + if (content == string.Empty) + throw new ArgumentException("Please enter your pronouns"); + Pronouns = content.Split(Separators, StringSplitOptions.RemoveEmptyEntries); + Log.Config("Found Pronouns: " + string.Join("/", Pronouns)); + } + catch (Exception e) { - Console.Write("Please enter your preferred pronouns: "); - content = Console.ReadLine() ?? throw new NullReferenceException("No input detected"); - File.WriteAllText(path, content); + Log.Error("Could not obtain pronouns", e); } - Pronouns = content.Split(Separators, StringSplitOptions.RemoveEmptyEntries); - Log.Config("Found Pronouns: " + string.Join("/", Pronouns)); } public static void Init()