feat: config setting to automatically set members/groups to private when creating

This commit is contained in:
spiral
2021-12-01 11:48:49 -05:00
parent 7c37726afb
commit 1ff6bb76cd
10 changed files with 140 additions and 24 deletions

View File

@@ -23,6 +23,8 @@ public partial class CommandTree
public static Command ConfigPing = new Command("config ping", "config ping <enable|disable>", "Changes your system's ping preferences");
public static Command ConfigAutoproxyAccount = new Command("config autoproxy account", "autoproxy account [on|off]", "Toggles autoproxy globally for the current account");
public static Command ConfigAutoproxyTimeout = new Command("config autoproxy timeout", "autoproxy timeout [<duration>|off|reset]", "Sets the latch timeout duration for your system");
public static Command ConfigMemberDefaultPrivacy = new("config member private", "config member private [on|off]", "Sets whether member privacy is automatically set to private when creating a new member");
public static Command ConfigGroupDefaultPrivacy = new("config group private", "config group private [on|off]", "Sets whether group privacy is automatically set to private when creating a new group");
public static Command AutoproxySet = new Command("autoproxy", "autoproxy [off|front|latch|member]", "Sets your system's autoproxy mode for the current server");
public static Command MemberInfo = new Command("member", "member <member>", "Looks up information about a member");
public static Command MemberNew = new Command("member new", "member new <name>", "Creates a new member");
@@ -125,7 +127,8 @@ public partial class CommandTree
public static Command[] ConfigCommands =
{
ConfigTimezone, ConfigPing, ConfigAutoproxyAccount, ConfigAutoproxyTimeout
ConfigTimezone, ConfigPing, ConfigAutoproxyAccount, ConfigAutoproxyTimeout,
ConfigMemberDefaultPrivacy, ConfigGroupDefaultPrivacy
};
public static Command[] LogCommands = { LogChannel, LogChannelClear, LogEnable, LogDisable };

View File

@@ -481,6 +481,10 @@ public partial class CommandTree
return ctx.Execute<Config>(null, m => m.SystemTimezone(ctx));
if (ctx.Match("ping"))
return ctx.Execute<Config>(null, m => m.SystemPing(ctx));
if (ctx.MatchMultiple(new[] { "private member" }) || ctx.Match("mp"))
return ctx.Execute<Config>(null, m => m.MemberDefaultPrivacy(ctx));
if (ctx.MatchMultiple(new[] { "private group" }) || ctx.Match("gp"))
return ctx.Execute<Config>(null, m => m.GroupDefaultPrivacy(ctx));
// todo: maybe add the list of configuration keys here?
return ctx.Reply($"{Emojis.Error} Could not find a setting with that name. Please see `pk;commands config` for the list of possible config settings.");
@@ -492,7 +496,6 @@ public partial class CommandTree
await ctx.Reply(
$"{Emojis.Error} Unknown command `pk;{ctx.FullCommand().Truncate(100)}`. Perhaps you meant to use one of the following commands?\n{commandListStr}\n\nFor a full list of possible commands, see <https://pluralkit.me/commands>.");
}
private async Task PrintCommandExpectedError(Context ctx, params Command[] potentialCommands)
{
var commandListStr = CreatePotentialCommandList(potentialCommands);