bottleclip: Add better error handling

This commit is contained in:
polyfloyd 2025-05-06 21:43:09 +02:00
parent 7fc04ccfa2
commit 3a721d9e29

View file

@ -72,7 +72,7 @@ async def state(ctx):
# !co2 # !co2
@HobbyBot.command(description="co2 levels") @HobbyBot.command(description="co2 levels")
async def co2(ctx, where='hoofdruimte'): async def co2(ctx, where="hoofdruimte"):
async with ctx.typing(): async with ctx.typing():
try: try:
msg = await mqtt_get_one(f"bitlair/climate/{where}/co2_ppm") msg = await mqtt_get_one(f"bitlair/climate/{where}/co2_ppm")
@ -115,7 +115,7 @@ async def np(ctx):
# !bottleclip # !bottleclip
@HobbyBot.command(description="Generate a bottle-clip STL file suitable for printing") @HobbyBot.command(description="Generate a bottle-clip STL file suitable for printing")
async def bottleclip(ctx, icon: str, ears: bool = False): async def bottleclip(ctx, icon: str = "", ears: bool = False):
git_api = "https://git.bitlair.nl/api/v1" git_api = "https://git.bitlair.nl/api/v1"
owner = "bitlair" owner = "bitlair"
repo = "bottle-clip" repo = "bottle-clip"
@ -139,7 +139,9 @@ async def bottleclip(ctx, icon: str, ears: bool = False):
"pixel-cats/standing-right.svg", "pixel-cats/standing-right.svg",
} }
if icon not in icons: if icon not in icons:
await ctx.reply(f"arg1 must be one of {', '.join(icons)}") await ctx.reply(
f"usage: `!bottleclip <icon> [<ears y|n>]`\n* `icon` must be one of {', '.join(icons)}"
)
return return
async with ctx.typing(): async with ctx.typing():