diff --git a/PluralKit.Bot/CommandMeta/CommandTree.cs b/PluralKit.Bot/CommandMeta/CommandTree.cs index 210c36a0..20cfb7d2 100644 --- a/PluralKit.Bot/CommandMeta/CommandTree.cs +++ b/PluralKit.Bot/CommandMeta/CommandTree.cs @@ -237,10 +237,10 @@ public partial class CommandTree Commands.GroupClearName(var param, var flags) => ctx.Execute(GroupRename, g => g.RenameGroup(ctx, param.target, null)), Commands.GroupRename(var param, var flags) => ctx.Execute(GroupRename, g => g.RenameGroup(ctx, param.target, param.name, flags.yes)), Commands.GroupShowDisplayName(var param, var flags) => ctx.Execute(GroupDisplayName, g => g.ShowGroupDisplayName(ctx, param.target, flags.GetReplyFormat())), - Commands.GroupClearDisplayName(var param, var flags) => ctx.Execute(GroupDisplayName, g => g.ClearGroupDisplayName(ctx, param.target)), + Commands.GroupClearDisplayName(var param, var flags) => ctx.Execute(GroupDisplayName, g => g.ClearGroupDisplayName(ctx, param.target, flags.yes)), Commands.GroupChangeDisplayName(var param, _) => ctx.Execute(GroupDisplayName, g => g.ChangeGroupDisplayName(ctx, param.target, param.name)), Commands.GroupShowDescription(var param, var flags) => ctx.Execute(GroupDesc, g => g.ShowGroupDescription(ctx, param.target, flags.GetReplyFormat())), - Commands.GroupClearDescription(var param, var flags) => ctx.Execute(GroupDesc, g => g.ClearGroupDescription(ctx, param.target)), + Commands.GroupClearDescription(var param, var flags) => ctx.Execute(GroupDesc, g => g.ClearGroupDescription(ctx, param.target, flags.yes)), Commands.GroupChangeDescription(var param, _) => ctx.Execute(GroupDesc, g => g.ChangeGroupDescription(ctx, param.target, param.description)), Commands.GroupShowIcon(var param, var flags) => ctx.Execute(GroupIcon, g => g.ShowGroupIcon(ctx, param.target, flags.GetReplyFormat())), Commands.GroupClearIcon(var param, var flags) => ctx.Execute(GroupIcon, g => g.ClearGroupIcon(ctx, param.target, flags.yes)), @@ -249,7 +249,7 @@ public partial class CommandTree Commands.GroupClearBanner(var param, var flags) => ctx.Execute(GroupBannerImage, g => g.ClearGroupBanner(ctx, param.target, flags.yes)), Commands.GroupChangeBanner(var param, _) => ctx.Execute(GroupBannerImage, g => g.ChangeGroupBanner(ctx, param.target, param.banner)), Commands.GroupShowColor(var param, var flags) => ctx.Execute(GroupColor, g => g.ShowGroupColor(ctx, param.target, flags.GetReplyFormat())), - Commands.GroupClearColor(var param, var flags) => ctx.Execute(GroupColor, g => g.ClearGroupColor(ctx, param.target)), + Commands.GroupClearColor(var param, var flags) => ctx.Execute(GroupColor, g => g.ClearGroupColor(ctx, param.target, flags.yes)), Commands.GroupChangeColor(var param, _) => ctx.Execute(GroupColor, g => g.ChangeGroupColor(ctx, param.target, param.color)), Commands.GroupAddMember(var param, var flags) => ctx.Execute(GroupAdd, g => g.AddRemoveMembers(ctx, param.target, param.targets, Groups.AddRemoveOperation.Add, flags.all)), Commands.GroupRemoveMember(var param, var flags) => ctx.Execute(GroupRemove, g => g.AddRemoveMembers(ctx, param.target, param.targets, Groups.AddRemoveOperation.Remove, flags.all, flags.yes)), diff --git a/PluralKit.Bot/Commands/Groups.cs b/PluralKit.Bot/Commands/Groups.cs index aa2d67b9..5b672176 100644 --- a/PluralKit.Bot/Commands/Groups.cs +++ b/PluralKit.Bot/Commands/Groups.cs @@ -174,10 +174,13 @@ public class Groups await ctx.Reply(embed: eb2.Build()); } - public async Task ClearGroupDisplayName(Context ctx, PKGroup target) + public async Task ClearGroupDisplayName(Context ctx, PKGroup target, bool confirmYes = false) { ctx.CheckOwnGroup(target); + if (!await ctx.ConfirmClear("this group's display name", confirmYes)) + return; + var patch = new GroupPatch { DisplayName = Partial.Null() }; await ctx.Repository.UpdateGroup(target.Id, patch); @@ -253,10 +256,13 @@ public class Groups await ctx.Reply(embed: eb2.Build()); } - public async Task ClearGroupDescription(Context ctx, PKGroup target) + public async Task ClearGroupDescription(Context ctx, PKGroup target, bool confirmYes = false) { ctx.CheckOwnGroup(target); + if (!await ctx.ConfirmClear("this group's description", confirmYes)) + return; + var patch = new GroupPatch { Description = Partial.Null() }; await ctx.Repository.UpdateGroup(target.Id, patch); @@ -479,10 +485,13 @@ public class Groups await ctx.Reply(embed: eb.Build(), files: [MiscUtils.GenerateColorPreview(target.Color)]); } - public async Task ClearGroupColor(Context ctx, PKGroup target) + public async Task ClearGroupColor(Context ctx, PKGroup target, bool confirmYes = false) { ctx.CheckOwnGroup(target); + if (!await ctx.ConfirmClear("this group's color", confirmYes)) + return; + await ctx.Repository.UpdateGroup(target.Id, new GroupPatch { Color = Partial.Null() }); await ctx.Reply($"{Emojis.Success} Group color cleared."); diff --git a/crates/command_definitions/src/group.rs b/crates/command_definitions/src/group.rs index 449bc26e..32ffe96a 100644 --- a/crates/command_definitions/src/group.rs +++ b/crates/command_definitions/src/group.rs @@ -38,6 +38,7 @@ pub fn cmds() -> impl Iterator { let group_name_cmd = [ command!(group_name => "group_show_name").help("Shows the group's name"), command!(group_name, CLEAR => "group_clear_name") + .flag(YES) .help("Clears the group's name"), command!(group_name, Remainder(("name", OpaqueString)) => "group_rename") .flag(YES) @@ -49,6 +50,7 @@ pub fn cmds() -> impl Iterator { command!(group_display_name => "group_show_display_name") .help("Shows the group's display name"), command!(group_display_name, CLEAR => "group_clear_display_name") + .flag(YES) .help("Clears the group's display name"), command!(group_display_name, Remainder(("name", OpaqueString)) => "group_change_display_name") .help("Changes the group's display name"), @@ -65,6 +67,7 @@ pub fn cmds() -> impl Iterator { command!(group_description => "group_show_description") .help("Shows the group's description"), command!(group_description, CLEAR => "group_clear_description") + .flag(YES) .help("Clears the group's description"), command!(group_description, Remainder(("description", OpaqueString)) => "group_change_description") .help("Changes the group's description"), @@ -97,6 +100,7 @@ pub fn cmds() -> impl Iterator { let group_color_cmd = [ command!(group_color => "group_show_color").help("Shows the group's color"), command!(group_color, CLEAR => "group_clear_color") + .flag(YES) .help("Clears the group's color"), command!(group_color, ("color", OpaqueString) => "group_change_color") .help("Changes a group's color"),