1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Display the currently active character in dndactive if it receives no parameters

This commit is contained in:
Steffo 2019-10-25 13:33:40 +02:00
parent beb670eb89
commit d788057e15

View file

@ -16,9 +16,14 @@ class DndactiveCommand(Command):
async def run(self, args: CommandArgs, data: CommandData) -> None: async def run(self, args: CommandArgs, data: CommandData) -> None:
identifier = args.optional(0) identifier = args.optional(0)
author = await data.get_author(error_if_none=True)
if identifier is None: if identifier is None:
# Display the active character identifiers # Display the active character
... if author.dnd_active_character is None:
await data.reply(" You have no active characters.")
else:
await data.reply(f" You currently have [b]{author.dnd_active_character}[/b] as active character.")
return
try: try:
identifier = int(identifier) identifier = int(identifier)
except ValueError: except ValueError:
@ -40,7 +45,6 @@ class DndactiveCommand(Command):
if char is None: if char is None:
raise CommandError("No character found.") raise CommandError("No character found.")
# Check if the player already has an active character # Check if the player already has an active character
author = await data.get_author(error_if_none=True)
if author.dnd_active_character is None: if author.dnd_active_character is None:
# Create a new active character # Create a new active character
achar = self.alchemy.DndActiveCharacter(character=char, user=author) achar = self.alchemy.DndActiveCharacter(character=char, user=author)