diff --git a/PluralKit.Bot/CommandMeta/CommandTree.cs b/PluralKit.Bot/CommandMeta/CommandTree.cs index 6cbf3245..2446940e 100644 --- a/PluralKit.Bot/CommandMeta/CommandTree.cs +++ b/PluralKit.Bot/CommandMeta/CommandTree.cs @@ -31,35 +31,35 @@ public partial class CommandTree Commands.SystemShowNameSelf(_, var flags) => ctx.Execute(SystemRename, m => m.ShowName(ctx, ctx.System, flags.GetReplyFormat())), Commands.SystemShowName(var param, var flags) => ctx.Execute(SystemRename, m => m.ShowName(ctx, param.target, flags.GetReplyFormat())), Commands.SystemRename(var param, _) => ctx.Execute(SystemRename, m => m.Rename(ctx, ctx.System, param.name)), - Commands.SystemClearName(var param, _) => ctx.Execute(SystemRename, m => m.ClearName(ctx, ctx.System)), + Commands.SystemClearName(var param, var flags) => ctx.Execute(SystemRename, m => m.ClearName(ctx, ctx.System, flags.yes)), Commands.SystemShowServerNameSelf(_, var flags) => ctx.Execute(SystemServerName, m => m.ShowServerName(ctx, ctx.System, flags.GetReplyFormat())), Commands.SystemShowServerName(var param, var flags) => ctx.Execute(SystemServerName, m => m.ShowServerName(ctx, param.target, flags.GetReplyFormat())), - Commands.SystemClearServerName(var param, _) => ctx.Execute(SystemServerName, m => m.ClearServerName(ctx, ctx.System)), + Commands.SystemClearServerName(var param, var flags) => ctx.Execute(SystemServerName, m => m.ClearServerName(ctx, ctx.System, flags.yes)), Commands.SystemRenameServerName(var param, _) => ctx.Execute(SystemServerName, m => m.RenameServerName(ctx, ctx.System, param.name)), Commands.SystemShowDescriptionSelf(_, var flags) => ctx.Execute(SystemDesc, m => m.ShowDescription(ctx, ctx.System, flags.GetReplyFormat())), Commands.SystemShowDescription(var param, var flags) => ctx.Execute(SystemDesc, m => m.ShowDescription(ctx, param.target, flags.GetReplyFormat())), - Commands.SystemClearDescription(var param, _) => ctx.Execute(SystemDesc, m => m.ClearDescription(ctx, ctx.System)), + Commands.SystemClearDescription(var param, var flags) => ctx.Execute(SystemDesc, m => m.ClearDescription(ctx, ctx.System, flags.yes)), Commands.SystemChangeDescription(var param, _) => ctx.Execute(SystemDesc, m => m.ChangeDescription(ctx, ctx.System, param.description)), Commands.SystemShowColorSelf(_, var flags) => ctx.Execute(SystemColor, m => m.ShowColor(ctx, ctx.System, flags.GetReplyFormat())), Commands.SystemShowColor(var param, var flags) => ctx.Execute(SystemColor, m => m.ShowColor(ctx, param.target, flags.GetReplyFormat())), - Commands.SystemClearColor(var param, _) => ctx.Execute(SystemColor, m => m.ClearColor(ctx, ctx.System)), + Commands.SystemClearColor(var param, var flags) => ctx.Execute(SystemColor, m => m.ClearColor(ctx, ctx.System, flags.yes)), Commands.SystemChangeColor(var param, _) => ctx.Execute(SystemColor, m => m.ChangeColor(ctx, ctx.System, param.color)), Commands.SystemShowTagSelf(_, var flags) => ctx.Execute(SystemTag, m => m.ShowTag(ctx, ctx.System, flags.GetReplyFormat())), Commands.SystemShowTag(var param, var flags) => ctx.Execute(SystemTag, m => m.ShowTag(ctx, param.target, flags.GetReplyFormat())), - Commands.SystemClearTag(var param, _) => ctx.Execute(SystemTag, m => m.ClearTag(ctx, ctx.System)), + Commands.SystemClearTag(var param, var flags) => ctx.Execute(SystemTag, m => m.ClearTag(ctx, ctx.System, flags.yes)), Commands.SystemChangeTag(var param, _) => ctx.Execute(SystemTag, m => m.ChangeTag(ctx, ctx.System, param.tag)), Commands.SystemShowServerTagSelf(_, var flags) => ctx.Execute(SystemServerTag, m => m.ShowServerTag(ctx, ctx.System, flags.GetReplyFormat())), Commands.SystemShowServerTag(var param, var flags) => ctx.Execute(SystemServerTag, m => m.ShowServerTag(ctx, param.target, flags.GetReplyFormat())), - Commands.SystemClearServerTag(var param, _) => ctx.Execute(SystemServerTag, m => m.ClearServerTag(ctx, ctx.System)), + Commands.SystemClearServerTag(var param, var flags) => ctx.Execute(SystemServerTag, m => m.ClearServerTag(ctx, ctx.System, flags.yes)), Commands.SystemChangeServerTag(var param, _) => ctx.Execute(SystemServerTag, m => m.ChangeServerTag(ctx, ctx.System, param.tag)), Commands.SystemShowPronounsSelf(_, var flags) => ctx.Execute(SystemPronouns, m => m.ShowPronouns(ctx, ctx.System, flags.GetReplyFormat())), Commands.SystemShowPronouns(var param, var flags) => ctx.Execute(SystemPronouns, m => m.ShowPronouns(ctx, param.target, flags.GetReplyFormat())), Commands.SystemClearPronouns(var param, var flags) => ctx.Execute(SystemPronouns, m => m.ClearPronouns(ctx, ctx.System, flags.yes)), Commands.SystemChangePronouns(var param, _) => ctx.Execute(SystemPronouns, m => m.ChangePronouns(ctx, ctx.System, param.pronouns)), _ => - // this should only ever occur when deving if commands are not implemented... - ctx.Reply( - $"{Emojis.Error} Parsed command {ctx.Parameters.Callback().AsCode()} not implemented in PluralKit.Bot!"), + // this should only ever occur when deving if commands are not implemented... + ctx.Reply( + $"{Emojis.Error} Parsed command {ctx.Parameters.Callback().AsCode()} not implemented in PluralKit.Bot!"), }; if (ctx.Match("system", "s")) return HandleSystemCommand(ctx); diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index c0eba729..fd46a6e2 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -64,12 +64,12 @@ public class SystemEdit return; } - public async Task ClearName(Context ctx, PKSystem target) + public async Task ClearName(Context ctx, PKSystem target, bool flagConfirmYes) { ctx.CheckSystemPrivacy(target.Id, target.NamePrivacy); ctx.CheckSystem().CheckOwnSystem(target); - if (await ctx.ConfirmClear("your system's name")) + if (await ctx.ConfirmClear("your system's name", flagConfirmYes)) { await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Name = null }); @@ -128,12 +128,12 @@ public class SystemEdit return; } - public async Task ClearServerName(Context ctx, PKSystem target) + public async Task ClearServerName(Context ctx, PKSystem target, bool flagConfirmYes) { ctx.CheckGuildContext(); ctx.CheckSystem().CheckOwnSystem(target); - if (await ctx.ConfirmClear("your system's name for this server")) + if (await ctx.ConfirmClear("your system's name for this server", flagConfirmYes)) { await ctx.Repository.UpdateSystemGuild(target.Id, ctx.Guild.Id, new SystemGuildPatch { DisplayName = null }); @@ -154,12 +154,12 @@ public class SystemEdit await ctx.Reply($"{Emojis.Success} System name for this server changed (using {newSystemGuildName.Length}/{Limits.MaxSystemNameLength} characters)."); } - public async Task ClearDescription(Context ctx, PKSystem target) + public async Task ClearDescription(Context ctx, PKSystem target, bool flagConfirmYes) { ctx.CheckSystemPrivacy(target.Id, target.DescriptionPrivacy); ctx.CheckSystem().CheckOwnSystem(target); - if (await ctx.ConfirmClear("your system's description")) + if (await ctx.ConfirmClear("your system's description", flagConfirmYes)) { await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Description = null }); @@ -237,12 +237,15 @@ public class SystemEdit .Build()); } - public async Task ClearColor(Context ctx, PKSystem target) + public async Task ClearColor(Context ctx, PKSystem target, bool flagConfirmYes) { ctx.CheckSystem().CheckOwnSystem(target); - await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Color = Partial.Null() }); - await ctx.Reply($"{Emojis.Success} System color cleared."); + if (await ctx.ConfirmClear("your system's color", flagConfirmYes)) + { + await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Color = Partial.Null() }); + await ctx.Reply($"{Emojis.Success} System color cleared."); + } } public async Task ShowColor(Context ctx, PKSystem target, ReplyFormat format) @@ -277,11 +280,11 @@ public class SystemEdit .Build()); } - public async Task ClearTag(Context ctx, PKSystem target) + public async Task ClearTag(Context ctx, PKSystem target, bool flagConfirmYes) { ctx.CheckSystem().CheckOwnSystem(target); - if (await ctx.ConfirmClear("your system's tag")) + if (await ctx.ConfirmClear("your system's tag", flagConfirmYes)) { await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Tag = null }); @@ -402,11 +405,11 @@ public class SystemEdit $"You currently have no system tag specific to the server '{ctx.Guild.Name}'. To set one, type `{ctx.DefaultPrefix}s servertag `. To disable the system tag in the current server, type `{ctx.DefaultPrefix}s servertag -disable`."); } - public async Task ClearServerTag(Context ctx, PKSystem target) + public async Task ClearServerTag(Context ctx, PKSystem target, bool flagConfirmYes) { ctx.CheckSystem().CheckOwnSystem(target).CheckGuildContext(); - if (!await ctx.ConfirmClear("your system's server tag")) + if (!await ctx.ConfirmClear("your system's server tag", flagConfirmYes)) return; var settings = await ctx.Repository.GetSystemGuild(ctx.Guild.Id, target.Id); diff --git a/crates/command_definitions/src/system.rs b/crates/command_definitions/src/system.rs index 133400d0..08386c94 100644 --- a/crates/command_definitions/src/system.rs +++ b/crates/command_definitions/src/system.rs @@ -29,15 +29,14 @@ pub fn edit() -> impl Iterator { }); let system_name = tokens!(system_target, "name"); - let system_name_cmd = [ - command!(system_name => "system_show_name").help("Shows the systems name"), - ] - .into_iter(); + let system_name_cmd = + [command!(system_name => "system_show_name").help("Shows the systems name")].into_iter(); let system_name_self = tokens!(system, "name"); let system_name_self_cmd = [ command!(system_name_self => "system_show_name_self").help("Shows your system's name"), command!(system_name_self, ("clear", ["c"]) => "system_clear_name") + .flag(("yes", ["y"])) .help("Clears your system's name"), command!(system_name_self, ("name", OpaqueString) => "system_rename") .help("Renames your system"), @@ -45,10 +44,8 @@ pub fn edit() -> impl Iterator { .into_iter(); let system_server_name = tokens!(system_target, ("servername", ["sn", "guildname"])); - let system_server_name_cmd = [ - command!(system_server_name => "system_show_server_name") - .help("Shows the system's server name"), - ] + let system_server_name_cmd = [command!(system_server_name => "system_show_server_name") + .help("Shows the system's server name")] .into_iter(); let system_server_name_self = tokens!(system, ("servername", ["sn", "guildname"])); @@ -56,6 +53,7 @@ pub fn edit() -> impl Iterator { command!(system_server_name_self => "system_show_server_name_self") .help("Shows your system's server name"), command!(system_server_name_self, ("clear", ["c"]) => "system_clear_server_name") + .flag(("yes", ["y"])) .help("Clears your system's server name"), command!(system_server_name_self, ("name", OpaqueString) => "system_rename_server_name") .help("Renames your system's server name"), @@ -63,15 +61,15 @@ pub fn edit() -> impl Iterator { .into_iter(); let system_description = tokens!(system_target, ("description", ["desc", "d"])); - let system_description_cmd = [ - command!(system_description => "system_show_description").help("Shows the system's description"), - ] + let system_description_cmd = [command!(system_description => "system_show_description") + .help("Shows the system's description")] .into_iter(); let system_description_self = tokens!(system, ("description", ["desc", "d"])); let system_description_self_cmd = [ command!(system_description_self => "system_show_description_self").help("Shows your system's description"), command!(system_description_self, ("clear", ["c"]) => "system_clear_description") + .flag(("yes", ["y"])) .help("Clears your system's description"), command!(system_description_self, ("description", OpaqueString) => "system_change_description") .help("Changes your system's description"), @@ -79,15 +77,15 @@ pub fn edit() -> impl Iterator { .into_iter(); let system_color = tokens!(system_target, ("color", ["colour"])); - let system_color_cmd = [ - command!(system_color => "system_show_color").help("Shows the system's color"), - ] - .into_iter(); + let system_color_cmd = + [command!(system_color => "system_show_color").help("Shows the system's color")] + .into_iter(); let system_color_self = tokens!(system, ("color", ["colour"])); let system_color_self_cmd = [ command!(system_color_self => "system_show_color_self").help("Shows your system's color"), command!(system_color_self, ("clear", ["c"]) => "system_clear_color") + .flag(("yes", ["y"])) .help("Clears your system's color"), command!(system_color_self, ("color", OpaqueString) => "system_change_color") .help("Changes your system's color"), @@ -95,15 +93,14 @@ pub fn edit() -> impl Iterator { .into_iter(); let system_tag = tokens!(system_target, ("tag", ["suffix"])); - let system_tag_cmd = [ - command!(system_tag => "system_show_tag").help("Shows the system's tag"), - ] - .into_iter(); + let system_tag_cmd = + [command!(system_tag => "system_show_tag").help("Shows the system's tag")].into_iter(); let system_tag_self = tokens!(system, ("tag", ["suffix"])); let system_tag_self_cmd = [ command!(system_tag_self => "system_show_tag_self").help("Shows your system's tag"), command!(system_tag_self, ("clear", ["c"]) => "system_clear_tag") + .flag(("yes", ["y"])) .help("Clears your system's tag"), command!(system_tag_self, ("tag", OpaqueString) => "system_change_tag") .help("Changes your system's tag"), @@ -111,15 +108,16 @@ pub fn edit() -> impl Iterator { .into_iter(); let system_server_tag = tokens!(system_target, ("servertag", ["st", "guildtag"])); - let system_server_tag_cmd = [ - command!(system_server_tag => "system_show_server_tag").help("Shows the system's server tag"), - ] + let system_server_tag_cmd = [command!(system_server_tag => "system_show_server_tag") + .help("Shows the system's server tag")] .into_iter(); let system_server_tag_self = tokens!(system, ("servertag", ["st", "guildtag"])); let system_server_tag_self_cmd = [ - command!(system_server_tag_self => "system_show_server_tag_self").help("Shows your system's server tag"), + command!(system_server_tag_self => "system_show_server_tag_self") + .help("Shows your system's server tag"), command!(system_server_tag_self, ("clear", ["c"]) => "system_clear_server_tag") + .flag(("yes", ["y"])) .help("Clears your system's server tag"), command!(system_server_tag_self, ("tag", OpaqueString) => "system_change_server_tag") .help("Changes your system's server tag"), @@ -127,14 +125,14 @@ pub fn edit() -> impl Iterator { .into_iter(); let system_pronouns = tokens!(system_target, ("pronouns", ["prns"])); - let system_pronouns_cmd = [ - command!(system_pronouns => "system_show_pronouns").help("Shows the system's pronouns"), - ] - .into_iter(); + let system_pronouns_cmd = + [command!(system_pronouns => "system_show_pronouns").help("Shows the system's pronouns")] + .into_iter(); let system_pronouns_self = tokens!(system, ("pronouns", ["prns"])); let system_pronouns_self_cmd = [ - command!(system_pronouns_self => "system_show_pronouns_self").help("Shows your system's pronouns"), + command!(system_pronouns_self => "system_show_pronouns_self") + .help("Shows your system's pronouns"), command!(system_pronouns_self, ("clear", ["c"]) => "system_clear_pronouns") .flag(("yes", ["y"])) .help("Clears your system's pronouns"), @@ -159,4 +157,4 @@ pub fn edit() -> impl Iterator { .chain(system_server_tag_cmd) .chain(system_pronouns_cmd) .chain(system_info_cmd) -} \ No newline at end of file +}