'Command to show set prefix in discord.py (rewrite)

I'm trying to make a help command that sends the current server-prefixes for the bot in an embed. I'm having some trouble trying to figure out how to code this, and I would love some help. I have tried doing:

@bot.command()
async def help(ctx):
    embed = discord.Embed(
        title='Help', description='', colour=discord.Colour.blue())
    embed.set_footer(text='Have fun!')

    prefix = command_prefix

    embed.add_field(
        name='Prefix',
        value=
        f'The current prefix for this server is {prefix}',
        inline=True)

    await ctx.send(embed=embed)

However when I do this I get the error:

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'command_prefix' is not defined

I'm not sure what I'm doing wrong, any help would be appreciated. (:



Solution 1:[1]

If anyone is still interested in the question, you can do:

client.commmand_prefix #if u use bot, just use bot.command_prefix

in this case it would be:

@bot.command()
async def help(ctx):
    embed = discord.Embed(
        title='Help', description='', colour=discord.Colour.blue())
    embed.set_footer(text='Have fun!')

    prefix = command_prefix

    embed.add_field(
        name='Prefix',
        value=
        f'The current prefix for this server is {bot.command_prefix}',
        inline=True)

    await ctx.send(embed=embed)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Baby Yoda