i cant count the full list bot discord python
Question:
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'nn{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)
Answers:
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)
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'nn{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)
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)