Add pk;member group

This commit is contained in:
spiral
2020-11-22 19:57:01 -05:00
parent 7f82a3e63a
commit 115017980e
6 changed files with 180 additions and 7 deletions

View File

@@ -86,8 +86,33 @@ namespace PluralKit.Bot
members.Add(member); // Then add to the final output list
}
if (members.Count == 0) throw new PKSyntaxError($"You must input at least one member.");
return members;
}
public static async Task<List<PKGroup>> ParseGroupList(this Context ctx, SystemId? restrictToSystem)
{
var groups = new List<PKGroup>();
// Loop through all the given arguments
while (ctx.HasNext())
{
// and attempt to match a group
var group = await ctx.MatchGroup();
if (group == null)
// if we can't, big error. Every group name must be valid.
throw new PKError(ctx.CreateGroupNotFoundError(ctx.PopArgument()));
if (restrictToSystem != null && group.System != restrictToSystem)
throw Errors.NotOwnGroupError; // TODO: name *which* group?
groups.Add(group); // Then add to the final output list
}
if (groups.Count == 0) throw new PKSyntaxError($"You must input at least one group.");
return groups;
}
}
}