Added fileName properties/fields to all classes that have an accompanying JSON file
This commit is contained in:
1 parent
cf036c534f
commit
c55c8c061e
3 files changed
+20
-18
No files matched your search
@@ -18,17 +18,17 @@ namespace StarsiegeBot
|
||||
{
|
||||
private Dictionary<string, SSFunction> ssFunctions;
|
||||
private bool FunctionsEnabled;
|
||||
|
||||
private static readonly string fileName = "functions.json";
|
||||
public Functions()
|
||||
{
|
||||
Console.WriteLine("Starsiege Function Commands Loaded");
|
||||
|
||||
// Check for file, if not there, disable commands.
|
||||
if (File.Exists("functions.json"))
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
// Load the Functions JSON file. Has all information regarding Starsiege in-game Functions.
|
||||
var json = "";
|
||||
using (var fs = File.OpenRead("functions.json"))
|
||||
using (var fs = File.OpenRead(fileName))
|
||||
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||
json = sr.ReadToEnd();
|
||||
ssFunctions = JsonConvert.DeserializeObject<Dictionary<string, SSFunction>>(json);
|
||||
@@ -135,7 +135,7 @@ namespace StarsiegeBot
|
||||
string[] turnOn = { "on", "true", "1" };
|
||||
string[] turnOff = { "off", "false", "0" };
|
||||
|
||||
if (File.Exists("functions.json"))
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
if (turnOn.Contains(isEnabled))
|
||||
{
|
||||
@@ -154,7 +154,7 @@ namespace StarsiegeBot
|
||||
else
|
||||
{
|
||||
FunctionsEnabled = false;
|
||||
output = "Functions.json file is missing, and it can not be enabled.";
|
||||
output = $"{fileName} file is missing, and it can not be enabled.";
|
||||
}
|
||||
await ctx.RespondAsync(output);
|
||||
}
|
||||
@@ -164,11 +164,11 @@ namespace StarsiegeBot
|
||||
await ctx.TriggerTypingAsync();
|
||||
|
||||
// Check for file, if not there, disable commands.
|
||||
if (File.Exists("functions.json"))
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
// Load the Functions JSON file. Has all information regarding Starsiege in-game Functions.
|
||||
var json = "";
|
||||
using (var fs = File.OpenRead("functions.json"))
|
||||
using (var fs = File.OpenRead(fileName))
|
||||
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||
json = sr.ReadToEnd();
|
||||
ssFunctions = JsonConvert.DeserializeObject<Dictionary<string, SSFunction>>(json);
|
||||
|
||||
Reference in new issue
Block a user