juancarlos5487
juancarlos5487

Reputation: 119

i cant count the full list bot discord python

I'm trying to count the entire embed list but it always shows me the same number...

should appear

1 2 3 4 ...

I don't know how to solve this problem

this is the code

@bot.command()
async def habbo(ctx):
    response = requests.get("https://images.habbo.com/habbo-web-leaderboards/hhes/visited-rooms/daily/latest.json")
    data = response.json()
    count=0
    for i in data:
        count=count+1
        
        content = f'\n\n{contar} - '.join(item['name'] for item in data)
    embed = discord.Embed(title=f"", description=f"{content}", color=discord.Colour.random())
    await ctx.send(embed=embed)

Upvotes: 1

Views: 49

Answers (1)

RxiPland
RxiPland

Reputation: 26

This should work. I just removed the .join() function and created the appending with a loop instead.

@bot.command()
async def habbo(ctx):
    response = requests.get("https://images.habbo.com/habbo-web-leaderboards/hhes/visited-rooms/daily/latest.json")
    data = response.json()
    
    count = 0
    content = ""

    for item in data:
        count = count + 1
        item = item["name"]
        content = content + f"\n{count} - {item}\n"

    embed = discord.Embed(title=f"", description=f"{content}", color=discord.Colour.random())
    await ctx.send(embed=embed)

Upvotes: 1

Related Questions