async def view(self, ctx, store=None): """ View store """ user = await author.get(ctx.author) store_list = '' stores = StoreModel.find() loaded_store = None if store is None: if not stores: return await ctx.send(f'```fix\nThere are no stores setup"\n```') if stores.count() == 1: loaded_store = Prodict.from_dict(stores[0]) item_list = '' loaded_store.inventory = sorted(loaded_store.inventory, key=curried.get_in(['price']), reverse=False) for i, item in enumerate(loaded_store.inventory): item = Prodict.from_dict(item) if user['quote_to'] != 'USD': rates = await coins.rate_convert() item.price = rates[user['quote_to']] * item.price item.payout = rates[user['quote_to']] * item.payout formatted_price = currency.symbol(user["quote_to"]) + '{0:.2f}'.format(item.price) formatted_payout = "{0:.2f}".format(item.payout) item_list += f'{i + 1}. {item.name}{" " * (15 - len(item.name))}{formatted_price}{" " * (10 - len(formatted_price))}{item.about.format(payout=formatted_payout, rate=str(item.rate) + " minutes")}\n' return await ctx.send( f'```py\n{user.quote_to}\nStore name: {loaded_store.name}\n\nItem{" " * (18 - len("item"))}Price{" " * (10 - len("price"))}Description\n\n{item_list}\n\nQoins represent a USD value by default, the prices will convert depending upon what quote currency you have set on your account. Use the "{self.config.prefix[0]}sq <currency symbol>" command to change it```') for i, _store in enumerate(stores): _store = Prodict.from_dict(_store) item_count = len(_store.inventory) store_list += f'\n{i + 1}. {_store.name}{" " * (12 - len("Name"))}{item_count}{" " * (10 - len(str(item_count)))}{_store.about}' store_list_head = f'\nName{" " * (15 - len("Name"))}Item Count{" " * (10 - len("item"))}Description' await ctx.send(f'```diff\nStore list:\n{store_list_head}{store_list}\n```') return await ctx.send_help('view') store_list = [] for i, _store in enumerate(stores): store_list.append(_store) if store.isnumeric(): if int(store) - 1 in range(len(store_list)): loaded_store = store_list[int(store) - 1] else: loaded_store = StoreModel.find_one({'name': store}) if not loaded_store: return await ctx.send(f'```fix\nCould not find store "{store}"\n```') loaded_store = Prodict.from_dict(loaded_store) item_list = '' for i, item in enumerate(loaded_store.inventory): item = Prodict.from_dict(item) if user['quote_to'] != 'USD': rates = await coins.rate_convert() item.price = rates[user['quote_to']] * item.price item.payout = rates[user['quote_to']] * item.payout formatted_price = currency.symbol(user["quote_to"]) + '{0:.2f}'.format(item.price) formatted_payout = "{0:.2f}".format(item.payout) item_list += f'{i + 1}. {item.name}{" " * (18 - len(item.name))}{formatted_price}{" " * (10 - len(formatted_price))}{item.about.format(payout=formatted_payout)}\n' await ctx.send( f'```py\n{user.quote_to}\n{loaded_store.name}\n\nItem{" " * (21 - len("item"))}Price{" " * (10 - len("price"))}Description\n\n{item_list}```')