Enhance shop item creation process to support new shop creation. Update user prompts to inform about existing shops and allow for the creation of new shops if none exist. Streamline message handling and improve user experience during item addition.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run

This commit is contained in:
Valerie 2025-05-26 20:21:26 -04:00
parent f80c66e1c1
commit 224a01ad89

View file

@ -1641,12 +1641,25 @@ class ItemManager:
msg = "What shop would you like to add this item to?\n"
shops = await self.instance.Shops()
msg += "Current shops are: "
msg += humanize_list([f"`{shopname}`" for shopname in sorted(shops.keys())])
if shops:
msg += "Current shops are: "
msg += humanize_list([f"`{shopname}`" for shopname in sorted(shops.keys())])
msg += "\nYou can also enter a new shop name to create a new shop."
else:
msg += "No shops exist yet. Enter a name for your new shop."
await self.ctx.send(msg)
shop = await self.ctx.bot.wait_for("message", timeout=25, check=Checks(self.ctx, custom=shops.keys()).content)
await self.add(data, shop.content, name)
await self.ctx.send("Item creation complete. Check your logs to ensure it went to the approriate shop.")
# Remove the check for existing shops to allow new shop creation
shop = await self.ctx.bot.wait_for("message", timeout=25, check=Checks(self.ctx, length=25).length_under)
if shop.content not in shops:
# Create new shop with @everyone role
async with self.instance.Shops() as shops:
shops[shop.content] = {"Items": {}, "Role": "@everyone"}
await self.ctx.send(f"Created new shop: {shop.content}")
await self.add(data, shop.content, name, new_allowed=True)
await self.ctx.send("Item creation complete. Check your logs to ensure it went to the appropriate shop.")
async def delete(self):
shop_list = await self.instance.Shops.all()