mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-17 03:00:13 +00:00
feat: add command to copy a switch and add new members
This commit is contained in:
parent
fc18847ee1
commit
d78de949af
2 changed files with 12 additions and 2 deletions
|
|
@ -430,6 +430,8 @@ public partial class CommandTree
|
||||||
await ctx.Execute<Switch>(SwitchEdit, m => m.SwitchEdit(ctx));
|
await ctx.Execute<Switch>(SwitchEdit, m => m.SwitchEdit(ctx));
|
||||||
else if (ctx.Match("delete", "remove", "erase", "cancel", "yeet"))
|
else if (ctx.Match("delete", "remove", "erase", "cancel", "yeet"))
|
||||||
await ctx.Execute<Switch>(SwitchDelete, m => m.SwitchDelete(ctx));
|
await ctx.Execute<Switch>(SwitchDelete, m => m.SwitchDelete(ctx));
|
||||||
|
else if (ctx.Match("add", "duplicate", "dupe", "copy"))
|
||||||
|
await ctx.Execute<Switch>(SwitchDelete, m => m.SwitchEdit(ctx, true));
|
||||||
else if (ctx.Match("commands", "help"))
|
else if (ctx.Match("commands", "help"))
|
||||||
await PrintCommandList(ctx, "switching", SwitchCommands);
|
await PrintCommandList(ctx, "switching", SwitchCommands);
|
||||||
else if (ctx.HasNext()) // there are following arguments
|
else if (ctx.HasNext()) // there are following arguments
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ public class Switch
|
||||||
await ctx.Reply($"{Emojis.Success} Switch moved to <t:{newSwitchTime}> ({newSwitchDeltaStr} ago).");
|
await ctx.Reply($"{Emojis.Success} Switch moved to <t:{newSwitchTime}> ({newSwitchDeltaStr} ago).");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SwitchEdit(Context ctx)
|
public async Task SwitchEdit(Context ctx, bool newSwitch = false)
|
||||||
{
|
{
|
||||||
ctx.CheckSystem();
|
ctx.CheckSystem();
|
||||||
|
|
||||||
|
|
@ -119,7 +119,15 @@ public class Switch
|
||||||
else if (ctx.MatchFlag("prepend", "p"))
|
else if (ctx.MatchFlag("prepend", "p"))
|
||||||
newMembers = await PrependToSwitch(ctx, newMembers);
|
newMembers = await PrependToSwitch(ctx, newMembers);
|
||||||
|
|
||||||
await DoEditCommand(ctx, newMembers);
|
if (newSwitch)
|
||||||
|
{
|
||||||
|
// if there's no edit flag, assume we're appending
|
||||||
|
if (!ctx.MatchFlag("first", "f", "remove", "r", "append", "a", "prepend", "p"))
|
||||||
|
newMembers = await AppendToSwitch(ctx, newMembers);
|
||||||
|
await DoSwitchCommand(ctx, newMembers);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
await DoEditCommand(ctx, newMembers);
|
||||||
}
|
}
|
||||||
public async Task<List<PKMember>> PrependToSwitch(Context ctx, List<PKMember> members)
|
public async Task<List<PKMember>> PrependToSwitch(Context ctx, List<PKMember> members)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue