mod853
mod853

Reputation: 1

discord.py invalid form of body

code:

@bot.command(name="whois")
async def whois(ctx,user:nextcord.Member=None):

    if user==None:
        user=ctx.author

    rlist = []
    for role in user.roles:
      if role.name != "@everyone":
        rlist.append(role.mention)

    b = ", ".join(rlist)


    embed = nextcord.Embed(colour=user.color,timestamp=ctx.message.created_at)

    embed.set_author(name=f"User Info - {user}"),
    embed.set_thumbnail(url=user.avatar.url),
    embed.set_footer(text=f'Requested by - {ctx.author},
  icon_url=ctx.author.avatar.url)

    embed.add_field(name='ID:',value=user.id,inline=False)
    embed.add_field(name='Name:',value=user.display_name,inline=False)

    embed.add_field(name='Created at:',value=user.created_at,inline=False)
    embed.add_field(name='Joined at:',value=user.joined_at,inline=False)

  
 
    embed.add_field(name='Bot?',value=user.bot,inline=False)

    embed.add_field(name=f'Roles:({len(rlist)})',value=''.join([b]),inline=False)
    embed.add_field(name='Top Role:',value=user.top_role.mention,inline=False)

    await ctx.send(embed=embed)

error:

nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In embeds.0.fields.5.value: Must be 1024 or fewer in length

how do I fix? because my code is shorter than 2000

Upvotes: 0

Views: 1354

Answers (2)

FireDouble
FireDouble

Reputation: 1

In set_footer you forgot to add a second ' so it makes the footer way to long for discord to handle

Upvotes: 0

Bento Bot
Bento Bot

Reputation: 78

I assume it's an issue with you putting too much text into the embed's field. How many roles are in rlist? If it's more than 47 (46.54 ~ 1024 / 22), then it's going to get mad.

You'll need to put a cap on the number of characters/roles that can appear in that field.

edit: Also, why do you cast b to a list and then join it? You're just turning a string into a list, then back into the exact same string.

Upvotes: 1

Related Questions