-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issues: - Method has non-nullable return type but returns null CS-W1029 (ConfigManager.cs) - Found the usage of DateTime.Now that relies on system-specific information CS-W1091 (Program.cs) - Use File Scoped namespaces instead of typical namespaces CS-R1062 (CommandManager.cs, ConfigManager.cs) - Classes and structs should be declared within a namespace CS-W1061 (Program.cs) - Fields initialized only in constructors can be made readonly CS-R1137 (CommandManager.cs) - Abrupt application exit CS-W1005 (ConfigManager.cs) - #2 Methods that deal with async should have their names suffixed with Async CS-R1073 (CommandManager.cs, Program.cs) - Also moved QuickEdit.Config namespace to QuickEdit, so Config is now reference by QuickEdit.Config instead of QuickEdit.Config.Config (ConfigManager.cs)
- Loading branch information
Showing
3 changed files
with
83 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
using Discord; | ||
using Newtonsoft.Json; | ||
|
||
namespace QuickEdit.Config | ||
namespace QuickEdit; | ||
public class Config | ||
{ | ||
public class Config | ||
{ | ||
public required string token; | ||
public ulong logChannel; | ||
public ulong guildID; | ||
public ActivityType statusType; | ||
public string status = string.Empty; | ||
public bool debug = false; | ||
public required string token; | ||
public ulong logChannel; | ||
public ulong guildID; | ||
public ActivityType statusType; | ||
public string status = string.Empty; | ||
public bool debug = false; | ||
|
||
public static Config GetConfig() | ||
public static Config? GetConfig() | ||
{ | ||
string path = "./config.json"; | ||
if (!File.Exists(path)) | ||
{ | ||
string path = "./config.json"; | ||
if (!File.Exists(path)) | ||
{ | ||
Program.Log("Config", $"Config file not found at: {path}", LogSeverity.Critical); | ||
Environment.Exit(1); | ||
} | ||
Program.LogAsync("Config", $"Config file not found at: {path}", LogSeverity.Critical); | ||
return null; | ||
} | ||
|
||
try { | ||
return JsonConvert.DeserializeObject<Config>(File.ReadAllText(path))!; | ||
} catch { | ||
Program.Log("Config" , "Failed to parse config file.", LogSeverity.Critical); | ||
Environment.Exit(1); | ||
return null; | ||
} | ||
try { | ||
return JsonConvert.DeserializeObject<Config>(File.ReadAllText(path))!; | ||
} catch { | ||
Program.LogAsync("Config" , "Failed to parse config file.", LogSeverity.Critical); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters