Added global toggle [partially]. Need to fix removing global prefix when no Guild Prefix is defined.

This commit is contained in:
Christopher Darnell committed 2021-04-19 16:43:16 -07:00
1 parent 7a868c8ce8
commit cb75dc1f5a
2 files changed
+41 -21

No files matched your search

+14 -3
View File
@@ -22,7 +22,7 @@ using System.Threading;
namespace StarsiegeBot
{
[Group("ex")]
[Group("bot")]
class BotSettings : BaseCommandModule
{
public static Dictionary<string, GuildSettings> GuildSettings;
@@ -47,8 +47,10 @@ namespace StarsiegeBot
item.Prefixes.Add(">");
// this line... is a test line.
GuildSettings = new Dictionary<string, GuildSettings>();
GuildSettings.Add("default", item);
GuildSettings = new Dictionary<string, GuildSettings>
{
{ "default", item }
};
string output = JsonConvert.SerializeObject(GuildSettings);
File.WriteAllTextAsync("guildSettings.json", output);
@@ -108,6 +110,15 @@ namespace StarsiegeBot
GuildSettings.Remove(prefix);
await ctx.RespondAsync($"Removed `{prefix}` as a command prefix.");
}
[Command("global"), Aliases("g")]
public async Task UseGlobalPrefixes(CommandContext ctx, bool isEnabled)
{
await ctx.TriggerTypingAsync();
GuildSettings[ctx.Guild.Id.ToString()].UseGlobalPrefix = isEnabled;
await ctx.RespondAsync($"Global Prefix usage has been turned **{(isEnabled ? "on":"off")}**");
}
}
}