From 1ec068371396a76412953a5923907601a35ba487 Mon Sep 17 00:00:00 2001 From: xBelladonna Date: Sat, 8 Jun 2019 10:48:20 +0930 Subject: [PATCH] Display front history with `pk;switch` Display system front history when the command `pk;switch` is issued without any arguments --- src/pluralkit/bot/commands/switch_commands.py | 6 ++++-- src/pluralkit/bot/commands/system_commands.py | 2 +- src/pluralkit/bot/help.json | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pluralkit/bot/commands/switch_commands.py b/src/pluralkit/bot/commands/switch_commands.py index 0a4df74e..ed65a61f 100644 --- a/src/pluralkit/bot/commands/switch_commands.py +++ b/src/pluralkit/bot/commands/switch_commands.py @@ -5,14 +5,16 @@ import dateparser import pytz from pluralkit.bot.commands import * +from pluralkit.bot.commands.system_commands import system_fronthistory from pluralkit.member import Member from pluralkit.utils import display_relative async def switch_root(ctx: CommandContext): if not ctx.has_next(): - raise CommandError("You must use a subcommand. For a list of subcommands, type `pk;help member`.") - + # We could raise an error here, but we display the system front history instead as a shortcut + #raise CommandError("You must use a subcommand. For a list of subcommands, type `pk;help member`.") + await system_fronthistory(ctx, await ctx.ensure_system()) if ctx.match("out"): await switch_out(ctx) elif ctx.match("move"): diff --git a/src/pluralkit/bot/commands/system_commands.py b/src/pluralkit/bot/commands/system_commands.py index fa9c1576..80403994 100644 --- a/src/pluralkit/bot/commands/system_commands.py +++ b/src/pluralkit/bot/commands/system_commands.py @@ -244,7 +244,7 @@ async def system_fronthistory(ctx: CommandContext, system: System): front_history = await pluralkit.utils.get_front_history(ctx.conn, system.id, count=10) if not front_history: - raise CommandError("You have no logged switches. Use `pk;switch´ to start logging.") + raise CommandError("You have no logged switches. Use `pk;switch [member] [extra members...]` to start logging.") for i, (timestamp, members) in enumerate(front_history): # Special case when no one's fronting diff --git a/src/pluralkit/bot/help.json b/src/pluralkit/bot/help.json index 2978cf04..f38c6dbf 100644 --- a/src/pluralkit/bot/help.json +++ b/src/pluralkit/bot/help.json @@ -201,11 +201,11 @@ { "name": "switch", "aliases": ["sw"], - "usage": "switch [member...]", + "usage": "switch [member] [extra members...]", "category": "Switching", - "description": "Registers a switch with the given members.", - "longdesc": "You may specify multiple members to indicate cofronting.", - "examples": ["switch Jack", "switch Jack Jill"], + "description": "Registers a switch with the given members, or displays a list of logged switches if no members are given.", + "longdesc": "You may specify multiple members to indicate cofronting. Shows the last 10 switches of a system if no members are given.", + "examples": ["switch Jack", "switch Jack Jill", "switch"], "subcommands": [ { "name": "move",