This repository was archived by the owner on Dec 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.cs
More file actions
190 lines (165 loc) · 6.95 KB
/
Config.cs
File metadata and controls
190 lines (165 loc) · 6.95 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
using CatBot.Extensions;
using DSharpPlus.Entities;
using Newtonsoft.Json;
using System;
using System.IO;
namespace CatBot
{
internal class Config
{
internal static Config singletonInstance = new Config();
internal static Config gI() => singletonInstance;
/// <summary>
/// ID Server chính dùng để điều khiển bot (dùng lệnh admin, báo lỗi, cache ảnh cho <see cref="Music.Local.LocalMusic"/>)
/// </summary>
[JsonProperty("MainServer")]
internal ulong MainServerID { get; set; }
internal DiscordGuild mainServer;
/// <summary>
/// Danh sách các thành viên được sử dụng SFX đặc biệt
/// </summary>
[JsonProperty("AdminUsers")]
internal ulong[] AdminUserIDs { get; set; } = [];
/// <summary>
/// ID kênh cache ảnh
/// </summary>
[JsonProperty("CacheImageChannel")]
internal ulong CacheImageChannelID { get; set; }
internal DiscordChannel cacheImageChannel;
/// <summary>
/// ID kênh báo lỗi bot
/// </summary>
[JsonProperty("LogExceptionChannel")]
internal ulong LogExceptionChannelID { get; set; }
internal DiscordChannel exceptionReportChannel;
/// <summary>
/// Kênh log lỗi
/// </summary>
[JsonProperty("DebugChannel")]
internal ulong DebugChannelID { get; set; }
internal DiscordChannel debugChannel;
/// <summary>
/// ID chủ của bot
/// </summary>
[JsonProperty("BotOwners")]
internal ulong[] BotOwnerIDs { get; set; } = [];
/// <summary>
/// ID bot loại trừ
/// </summary>
[JsonProperty("ExcludeBots")]
internal ulong[] ExcludeBotIDs { get; set; } = [];
/// <summary>
/// Đường dẫn tới thư mục chứa nhạc
/// </summary>
[JsonProperty(nameof(MusicFolder))]
internal string MusicFolder { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
/// <summary>
/// Đường dẫn tới thư mục chứa SFX
/// </summary>
[JsonProperty(nameof(SFXFolder))]
internal string SFXFolder { get; set; } = "Files\\SFX";
/// <summary>
/// Đường dẫn tới thư mục chứa SFX đặc biệt
/// </summary>
[JsonProperty(nameof(SFXFolderSpecial))]
internal string SFXFolderSpecial { get; set; } = "Files\\SFX\\Special";
#region Zing MP3
/// <summary>
/// Mã khóa bí mật Zing MP3
/// </summary>
[JsonProperty(nameof(ZingMP3SecretKey))]
internal string ZingMP3SecretKey { get; set; } = "";
/// <summary>
/// API key Zing MP3
/// </summary>
[JsonProperty(nameof(ZingMP3APIKey))]
internal string ZingMP3APIKey { get; set; } = "";
/// <summary>
/// Cookie Zing MP3
/// </summary>
[JsonProperty(nameof(ZingMP3Cookie))]
internal string ZingMP3Cookie { get; set; } = "";
#endregion
#region YouTube & YouTube Music
/// <summary>
/// API key Google
/// </summary>
[JsonProperty(nameof(GoogleAPIKey))]
internal string GoogleAPIKey { get; set; } = "";
#endregion
#region Spotify
/// <summary>
/// Spotify cookie
/// </summary>
[JsonProperty(nameof(SpotifyCookie))]
internal string SpotifyCookie { get; set; } = "";
/// <summary>
/// Spotify Client ID
/// </summary>
[JsonProperty(nameof(SpotifyClientID))]
internal string SpotifyClientID { get; set; } = "";
/// <summary>
/// Spotify Client Secret
/// </summary>
[JsonProperty(nameof(SpotifyClientSecret))]
internal string SpotifyClientSecret { get; set; } = "";
#endregion
#region SoundCloud
/// <summary>
/// Client ID SoundCloud
/// </summary>
[JsonProperty(nameof(SoundCloudClientID))]
internal string SoundCloudClientID { get; set; } = "";
#endregion
/// <summary>
/// User agent
/// </summary>
[JsonProperty(nameof(UserAgent))]
internal string UserAgent { get; set; } = "";
[JsonProperty(nameof(NCTIcon))]
internal string NCTIcon { get; set; } = "";
[JsonProperty(nameof(ZingMP3Icon))]
internal string ZingMP3Icon { get; set; } = "";
[JsonProperty(nameof(YouTubeIcon))]
internal string YouTubeIcon { get; set; } = "";
[JsonProperty(nameof(YouTubeMusicIcon))]
internal string YouTubeMusicIcon { get; set; } = "";
[JsonProperty(nameof(SoundCloudIcon))]
internal string SoundCloudIcon { get; set; } = "";
[JsonProperty(nameof(SpotifyIcon))]
internal string SpotifyIcon { get; set; } = "";
/// <summary>
/// Token bot
/// </summary>
[JsonProperty(nameof(BotToken))]
internal string BotToken { get; set; } = "";
/// <summary>
/// Prefix lệnh mặc định
/// </summary>
[JsonProperty(nameof(DefaultPrefix))]
internal string DefaultPrefix { get; set; } = "";
/// <summary>
/// Trạng thái mặc định của bot
/// </summary>
[JsonProperty(nameof(DefaultPresences))]
internal CustomDiscordActivity[] DefaultPresences { get; set; } =
[
new CustomDiscordActivity(0, DiscordActivityType.ListeningTo, "Zing MP3"),
new CustomDiscordActivity(0, DiscordActivityType.ListeningTo, "NhacCuaTui"),
new CustomDiscordActivity(0, DiscordActivityType.ListeningTo, "YouTube Music"),
new CustomDiscordActivity(0, DiscordActivityType.ListeningTo, "SoundCloud"),
new CustomDiscordActivity(0, DiscordActivityType.ListeningTo, "Spotify"),
new CustomDiscordActivity(0, DiscordActivityType.Watching, "YouTube")
];
internal string LyricAPI => "https://lrclib.net/api/";
internal static void ImportConfig(string configPath)
{
singletonInstance = JsonConvert.DeserializeObject<Config>(File.ReadAllText(configPath)) ?? throw new NullReferenceException();
if (!Directory.Exists(singletonInstance.MusicFolder))
singletonInstance.MusicFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
}
internal static void ExportConfig(string configPath) => File.WriteAllText(configPath, JsonConvert.SerializeObject(singletonInstance, Formatting.Indented));
}
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.