Remove duplicated code

This commit is contained in:
spiral 2020-11-14 10:51:13 -05:00
parent 537783dd96
commit b522a4c175
No known key found for this signature in database
GPG Key ID: 00C26F208D3FCCAB

View File

@ -320,7 +320,7 @@ namespace PluralKit.Bot
{ {
ctx.CheckOwnGroup(target); ctx.CheckOwnGroup(target);
var members = await ParseMemberList(ctx); var members = await ctx.ParseMemberList(ctx.System.Id);
await using var conn = await _db.Obtain(); await using var conn = await _db.Obtain();
@ -386,26 +386,6 @@ namespace PluralKit.Bot
Remove Remove
} }
private static async Task<List<PKMember>> ParseMemberList(Context ctx)
{
// TODO: move this to a context extension and share with the switch command somewhere, after branch merge?
var members = new List<PKMember>();
while (ctx.HasNext())
{
var member = await ctx.MatchMember();
if (member == null)
throw new PKSyntaxError(ctx.CreateMemberNotFoundError(ctx.PopArgument()));;
if (member.System != ctx.System.Id)
throw new PKError($"Member **{member.Name}** (`{member.Hid}`) is not in your own system, so you can't add it to a group.");
members.Add(member);
}
if (members.Count == 0)
throw new PKSyntaxError("You must pass one or more members.");
return members;
}
public async Task GroupPrivacy(Context ctx, PKGroup target, PrivacyLevel? newValueFromCommand) public async Task GroupPrivacy(Context ctx, PKGroup target, PrivacyLevel? newValueFromCommand)
{ {
ctx.CheckSystem().CheckOwnGroup(target); ctx.CheckSystem().CheckOwnGroup(target);