示例#1
0
async def send_listing(product: products.Product, ctx, editing: bool):
    embed = discord.Embed(
        title=product.get_title(),
        url=product.get_url(),
        color=product.get_color(),
    )
    embed.set_thumbnail(url=product.get_thumbnail())
    embed.add_field(name="SKU:", value=product.get_sku(), inline=True)
    embed.add_field(name="⠀", value="⠀", inline=True)
    embed.add_field(name="Retail Price:",
                    value=product.get_retail_price(),
                    inline=True)
    prices = product.get_prices()
    # if the product has asks and bids for each size
    if product.asks_and_bids():
        # if the item has more than one size
        if not product.one_size():
            for size in prices:
                ask = prices[size]["ask"]["listing"]
                bid = prices[size]["bid"]["listing"]
                if ask:
                    ask = f"${ask}"
                if bid:
                    bid = f"${bid}"
                embed.add_field(
                    name=size,
                    value=f"```bash\nAsk: {ask}\nBid: {bid}```",
                    inline=True,
                )
        # if the item has only one size
        else:
            ask = prices[""]["ask"]["listing"]
            bid = prices[""]["bid"]["listing"]
            if ask:
                ask = f"${ask}"
            if bid:
                bid = f"${bid}"
            embed.add_field(
                name="Ask",
                value=f"```bash\n{ask}```",
                inline=True,
            )
            embed.add_field(
                name="Bid",
                value=f"```bash\n{bid}```",
                inline=True,
            )
    # if the item doesn't have asks and bids
    else:
        for size in prices:
            listing = prices[size]["listing"]
            if listing:
                listing = f"${listing}"
            embed.add_field(
                name=size,
                value=f"```bash\n{listing}```",
                inline=True,
            )
    embed.set_footer(
        text=product.get_footer_text(),
        icon_url=product.get_footer_image(),
    )

    if not editing:
        if product.get_footer_text() == "StockX":
            await ctx.send(embed=embed, components=[stockx_button_row])
        elif product.get_footer_text() == "Goat":
            await ctx.send(embed=embed, components=[goat_button_row])
        elif product.get_footer_text() == "Stadium Goods":
            await ctx.send(embed=embed, components=[sg_button_row])
    else:
        await ctx.edit_origin(embed=embed)
示例#2
0
async def send_payout(product: products.Product, ctx, seller_level=1):
    # if the product has no retail price then you can't calculate profit
    if product.get_retail_price() == "N/A":
        raise errors.NoRetailPrice
    embed = discord.Embed(
        title=product.get_title(),
        url=product.get_url(),
        color=product.get_color(),
    )
    embed.set_thumbnail(url=product.get_thumbnail())
    embed.add_field(name="SKU:", value=product.get_sku(), inline=True)
    embed.add_field(
        name="Fees",
        value=str(product.get_fees(seller_level)) + "%",
        inline=True,
    )
    embed.add_field(name="Retail Price:",
                    value=product.get_retail_price(),
                    inline=True)
    prices = product.get_prices()
    # if the product has asks and bids for each size
    if product.asks_and_bids():
        # if the item has more than one size
        if not product.one_size():
            for size in prices:
                ask = prices[size]["ask"]["payouts"][seller_level]
                bid = prices[size]["bid"]["payouts"][seller_level]
                if ask:
                    ask = f"${ask}"
                if bid:
                    bid = f"${bid}"
                embed.add_field(
                    name=size,
                    value=f"```cpp\nAsk: {ask}\nBid: {bid}```",
                    inline=True,
                )
        # if the item has only one size
        else:
            ask = prices[""]["ask"]["payouts"][seller_level]
            bid = prices[""]["bid"]["payouts"][seller_level]
            if ask:
                ask = f"${ask}"
            if bid:
                bid = f"${bid}"
            embed.add_field(
                name="Ask",
                value=f"```cpp\n{ask}```",
                inline=True,
            )
            embed.add_field(
                name="Bid",
                value=f"```cpp\n{bid}```",
                inline=True,
            )
    # if the item doesn't have asks and bids
    else:
        for size in prices:
            listing = prices[size]["payouts"][seller_level]
            if listing:
                listing = f"${listing}"
            embed.add_field(
                name=size,
                value=f"```cpp\n{listing}```",
                inline=True,
            )
    embed.set_footer(
        text=product.get_footer_text(),
        icon_url=product.get_footer_image(),
    )
    await ctx.edit_origin(embed=embed)