async def customcounter_create(self, ctx, name, *args): """Creates a new custom counter. __Valid Arguments__ `-reset <short|long|none>` - Counter will reset to max on a short/long rest, or not ever when "none". Default - will reset on a call of `!cc reset`. `-max <max value>` - The maximum value of the counter. `-min <min value>` - The minimum value of the counter. `-type <bubble|default>` - Whether the counter displays bubbles to show remaining uses or numbers. Default - numbers.""" character: Character = await Character.from_ctx(ctx) conflict = next((c for c in character.consumables if c.name.lower() == name.lower()), None) if conflict: if await confirm(ctx, "Warning: This will overwrite an existing consumable. Continue?"): character.consumables.remove(conflict) else: return await ctx.send("Overwrite unconfirmed. Aborting.") args = argparse(args) _reset = args.last('reset') _max = args.last('max') _min = args.last('min') _type = args.last('type') try: new_counter = CustomCounter.new(character, name, maxv=_max, minv=_min, reset=_reset, display_type=_type) character.consumables.append(new_counter) await character.commit(ctx) except InvalidArgument as e: return await ctx.send(f"Failed to create counter: {e}") else: await ctx.send(f"Custom counter created.")
async def customcounter_create(self, ctx, name, *args): """ Creates a new custom counter. __Valid Arguments__ `-title <title>` - Sets the title when setting or viewing the counter. `[name]` will be replaced with the player's name. `-desc <desc>` - Sets the description when setting or viewing the counter. `-reset <short|long|none>` - Counter will reset to max on a short/long rest, or not ever when "none". Default - will reset on a call of `!cc reset`. `-max <max value>` - The maximum value of the counter. `-min <min value>` - The minimum value of the counter. `-type <bubble|default>` - Whether the counter displays bubbles to show remaining uses or numbers. Default - numbers. `-resetto <value>` - The value to reset the counter to. Default - maximum. `-resetby <value>` - Rather than resetting to a certain value, modify the counter by this much per reset. Supports dice. """ character: Character = await Character.from_ctx(ctx) conflict = next( (c for c in character.consumables if c.name.lower() == name.lower()), None) if conflict: if await confirm( ctx, "Warning: This will overwrite an existing consumable. Continue?" ): character.consumables.remove(conflict) else: return await ctx.send("Overwrite unconfirmed. Aborting.") args = argparse(args) _reset = args.last('reset') _max = args.last('max') _min = args.last('min') _type = args.last('type') reset_to = args.last('resetto') reset_by = args.last('resetby') title = args.last('title') desc = args.last('desc') try: new_counter = CustomCounter.new(character, name, maxv=_max, minv=_min, reset=_reset, display_type=_type, reset_to=reset_to, reset_by=reset_by, title=title, desc=desc) character.consumables.append(new_counter) await character.commit(ctx) except InvalidArgument as e: return await ctx.send(f"Failed to create counter: {e}") else: await ctx.send(f"Custom counter created.")