1
0

fix Config.json

This commit is contained in:
Oreh 2023-07-25 17:11:00 +08:00
parent 784ece36cd
commit cb33113e8a
3 changed files with 25 additions and 2 deletions

View File

@ -13,4 +13,11 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="../Config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>Config.json</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
</Project>

View File

@ -51,8 +51,14 @@ namespace Discord_Bot
public static JObject GetConfig()
{
using StreamReader configJson = new StreamReader(Directory.GetCurrentDirectory() + @"/Config.json");
return (JObject)JsonConvert.DeserializeObject(configJson.ReadToEnd());
string path = Directory.GetCurrentDirectory() + @"/Config.json";
if (!File.Exists(path))
{
throw new FileNotFoundException("gde config?");
}
using StreamReader configJson = new StreamReader(path);
return (JObject)JsonConvert.DeserializeObject(configJson.ReadToEnd());
}
public static void SaveConfig(JObject config)

10
Config.json Normal file
View File

@ -0,0 +1,10 @@
{
"version": "1.0",
"token": "MTA4NDA5MTA4OTE1NTI4MDkxNw.G77VAz.3O8uS-D4nwp1Ax8iZMBIx0Z9gsYNNOwPFfGRl8",
"prefixes": ["."],
"join_message": "Hello, I'm Discord Bot! :heart:",
"currently": "playing|listening|watching|streaming",
"playing_status": "майныч",
"status": "online|dnd|idle|offline",
"reminderTime": "1:12"
}