Skip to content

Commit fe0ecbe

Browse files
committed
use snowflake in config types
1 parent ce2ca50 commit fe0ecbe

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/Bot/Helpers/Logger.Internal.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ internal static void PrintHeader()
4545
internal static void LogFileRestartNotice()
4646
{
4747
if (!VolteBot.IsHeadless || _logFileNoticePrinted || Config.EnabledFeatures?.LogToFile is not true) return;
48-
48+
4949
GetLogFilePath(DateTime.Now).AppendAllText($"{Side}RESTARTING{Side}\n");
50-
50+
5151
_logFileNoticePrinted = true;
5252
}
53-
53+
5454
public static void Log(LogSeverity s, LogSource from, string message, Exception e = null, InvocationInfo caller = default) =>
5555
Log(new VolteLogEventArgs
5656
{
@@ -60,7 +60,7 @@ public static void Log(LogSeverity s, LogSource from, string message, Exception
6060
Error = e,
6161
Invocation = caller
6262
});
63-
63+
6464
private static StringBuilder _logFileBuilder = new();
6565

6666
private static void Execute(LogSeverity s, LogSource src, string message, Exception e, InvocationInfo caller)

src/Bot/Systems/Configuration/Config.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ public static class Config
1212
public static readonly FilePath Path = FilePath.Data / "volte.json";
1313

1414
private static JsonSerializerOptions CreateSerializerOptions(bool writeIndented)
15-
=> new()
15+
=> new JsonSerializerOptions
1616
{
1717
ReadCommentHandling = JsonCommentHandling.Skip,
1818
WriteIndented = writeIndented,
1919
PropertyNameCaseInsensitive = true,
2020
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
2121
AllowTrailingCommas = true
22-
};
22+
}.Apply(opt =>
23+
{
24+
opt.Converters.Add(new Snowflake.JsonConverter());
25+
});
2326

2427

2528
private static bool IsValidConfig()
@@ -135,7 +138,7 @@ public static bool IsValidToken()
135138

136139
public static string SentryDsn => _configuration.SentryDsn;
137140

138-
public static ulong Owner => _configuration.Owner;
141+
public static Snowflake Owner => _configuration.Owner;
139142

140143
public static string Game => _configuration.Game;
141144

@@ -153,7 +156,7 @@ public static bool IsValidToken()
153156

154157
public static bool LogAllCommands => _configuration.LogAllCommands;
155158

156-
public static HashSet<ulong> BlacklistedOwners => _configuration.BlacklistedGuildOwners;
159+
public static HashSet<Snowflake> BlacklistedOwners => _configuration.BlacklistedGuildOwners;
157160

158161
public static EnabledFeatures EnabledFeatures => _configuration?.EnabledFeatures;
159162
}

src/Bot/Systems/Configuration/Types/HeadlessBotConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct HeadlessBotConfig : IVolteConfig
1414
public string CommandPrefix { get; set; }
1515

1616
[JsonPropertyName("bot_owner")]
17-
public ulong Owner { get; set; }
17+
public Snowflake Owner { get; set; }
1818

1919
[JsonPropertyName("status_game")]
2020
public string Game { get; set; }
@@ -38,7 +38,7 @@ public struct HeadlessBotConfig : IVolteConfig
3838
public bool LogAllCommands { get; set; }
3939

4040
[JsonPropertyName("blacklisted_guild_owners")]
41-
public HashSet<ulong> BlacklistedGuildOwners { get; set; }
41+
public HashSet<Snowflake> BlacklistedGuildOwners { get; set; }
4242

4343
[JsonPropertyName("enabled_features")]
4444
public EnabledFeatures EnabledFeatures { get; set; }

src/Bot/Systems/Configuration/Types/IVolteConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface IVolteConfig
1414
public string CommandPrefix { get; set; }
1515

1616
[JsonPropertyName("bot_owner")]
17-
public ulong Owner { get; set; }
17+
public Snowflake Owner { get; set; }
1818

1919
[JsonPropertyName("status_game")]
2020
public string Game { get; set; }
@@ -38,7 +38,7 @@ public interface IVolteConfig
3838
public bool LogAllCommands { get; set; }
3939

4040
[JsonPropertyName("blacklisted_guild_owners")]
41-
public HashSet<ulong> BlacklistedGuildOwners { get; set; }
41+
public HashSet<Snowflake> BlacklistedGuildOwners { get; set; }
4242

4343
[JsonPropertyName("enabled_features")]
4444
public EnabledFeatures EnabledFeatures { get; set; }

0 commit comments

Comments
 (0)