Added Load and Toggle sub commands to [DeathMessages|Functions|QuickChats] commands.

This commit is contained in:
Christopher Darnell committed 2021-04-26 17:59:34 -07:00
1 parent 177a689989
commit b2d6cff5ed
6 files changed
+89 -20

No files matched your search

+25 -2
View File
@@ -30,7 +30,7 @@ namespace StarsiegeBot
DiscordColor.Rose, DiscordColor.SapGreen, DiscordColor.Sienna, DiscordColor.SpringGreen, DiscordColor.Teal, DiscordColor.Turquoise, DiscordColor.VeryDarkGray,
DiscordColor.Violet, DiscordColor.Wheat, DiscordColor.White, DiscordColor.Yellow };
private readonly Random rnd = new Random();
private readonly Dictionary<string, SSFunction> ssFunctions;
private Dictionary<string, SSFunction> ssFunctions;
private bool FunctionsEnabled;
public Functions()
@@ -138,7 +138,7 @@ namespace StarsiegeBot
[Command("toggle"), Aliases("t")]
[RequireOwner]
public async Task ToggleQC(CommandContext ctx, [RemainingText] string isEnabled = null)
public async Task ToggleFunctions(CommandContext ctx, [RemainingText] string isEnabled = null)
{
await ctx.TriggerTypingAsync();
@@ -172,6 +172,29 @@ namespace StarsiegeBot
}
await ctx.RespondAsync(output);
}
[Command("load"), RequireOwner]
public async Task LoadFunctions(CommandContext ctx)
{
await ctx.TriggerTypingAsync();
// Check for file, if not there, disable commands.
if (File.Exists("functions.json"))
{
// Load the Functions JSON file. Has all information regarding Starsiege in-game Functions.
var json = "";
using (var fs = File.OpenRead("functions.json"))
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
json = sr.ReadToEnd();
ssFunctions = JsonConvert.DeserializeObject<Dictionary<string, SSFunction>>(json);
FunctionsEnabled = true;
await ctx.RespondAsync("Loading Quick Chats successul.");
}
else
{
FunctionsEnabled = false;
await ctx.RespondAsync("Loading Functions failed. File does not exist.");
}
}
}
public class SSFunction