-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBotConfig.cs
More file actions
65 lines (58 loc) · 1.83 KB
/
BotConfig.cs
File metadata and controls
65 lines (58 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using Discord;
using Newtonsoft.Json;
namespace QuaverBot;
public struct BotConfig
{
public string Token;
[JsonConverter(typeof(LogSeverityConverter))]
public LogSeverity LogLevel;
public ulong GuildId;
public ulong ModlogChannelId;
public string MacroPrefix;
public ulong MutedRole;
public ulong[] ModRoles;
public CleanConfig Clean;
public LogConfig Log;
public static BotConfig Default => new BotConfig
{
Token = "YOUR_TOKEN",
LogLevel = LogSeverity.Info,
MacroPrefix = "!",
ModRoles = Array.Empty<ulong>(),
Clean = new CleanConfig
{
Channels = Array.Empty<ulong>(),
IgnoreMessages = Array.Empty<ulong>(),
IgnoreUsers = Array.Empty<ulong>(),
IgnoreRoles = Array.Empty<ulong>(),
AfterHours = 6,
},
Log = new LogConfig
{
CacheAttachments = true,
MaxCacheSize = 1024 * 1024 * 1024, // 1 GiB
},
};
}
public struct CleanConfig
{
public ulong[] Channels;
public ulong[] IgnoreMessages;
public ulong[] IgnoreUsers;
public ulong[] IgnoreRoles;
public int AfterHours;
}
public struct LogConfig
{
public ulong ChannelId;
public bool CacheAttachments;
public long MaxCacheSize;
}
public class LogSeverityConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) => writer.WriteValue(value?.ToString());
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
=> Enum.Parse<LogSeverity>(reader.Value?.ToString() ?? throw new InvalidOperationException("LogSeverity value is null."));
public override bool CanConvert(Type objectType) => objectType == typeof(LogSeverity);
}