Categories
Mastering Development

Using random.choice for discord.py within embed

I am not sure if this is the correct code, but I am trying to return a random rating when an user types the command "?rating". I have created a variable_list containing the rating numbers that the bot is supposed to return. But I am also using embed. And I am not able to get the random.choice working inside the embed.

@client.command()
async def rating(ctx, *):
    variable_list = [
        '1',
        '2',
        '3',
        '4',
    ]

    embed = discord.Embed(
        colour=0xc81f9f,
        title="Rating",
        description=f"{ctx.author.mention} (random.choice(variable_list)) is your rating"
    )
    embed.set_footer(text=f"{ctx.message.guild.name}")
    embed.timestamp = datetime.datetime.utcnow()

    await ctx.send(embed=embed)

Leave a Reply

Your email address will not be published. Required fields are marked *