Reputation: 17
I'm trying to create a help command with a dict and some message editing for each items of the dict with a loop, but when I use the help command it returns the error AttributeError: 'NoneType' object has no attribute 'edit'
when it comes to the ping command and I don't understand why help_msg
becomes a 'NoneType' object...
Here's the code:
@bot.command(aliases = ['h','aide'])
async def help(ctx):
help_msg = await ctx.send("__**Available commands:**__")
for commande, info in help_list.items():
help_msg = await help_msg.edit(content=str(help_msg.content)+commande+info)
@bot.command(pass_context=True)
async def ping(ctx, message=None):
await ctx.send(f":ping_pong: Pong! `{round(bot.latency*1000)}ms`")
p = bot.command_prefix
help_list = {
f"``` {p}help | Alias: {', '.join(help.aliases)}```" : "Affiche la liste des commandes | ?help <commande>",
f"``` {p}ping | Alias: {', '.join(ping.aliases)}```" : "Affiche le ping du bot en ms | ?ping"
}
Upvotes: 0
Views: 92
Reputation: 2455
message.edit
has no return value, so help_msg
is set to none.
I believe it should work if you just remove the assignment.
for commande, info in help_list.items():
await help_msg.edit(content=str(help_msg.content)+commande+info)
Upvotes: 2