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

  command, discord, discord.py, discord.py-rewrite, python

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. (:

Source: Python Questions

LEAVE A COMMENT