I'm writing a profile command using Discord.py which prints out information about the specified user.
I would like to pass the message author as the default argument, so if the user just writes the command and nothing else, the bot will send their profile.
@bot.command()
async def profile(ctx, *, user: discord.Member = ctx.message.author):
The above code doesn't work. It errors out with the following error:
Traceback (most recent call last):
File "bot.py", line 50, in <module>
async def profile(ctx, *, user: discord.Member = ctx.message.author.name):
NameError: name 'ctx' is not defined
Can anybody tell me what I am doing wrong and how to make my code work?
EDIT:
I sort of bypassed the problem with:
@bot.command()
async def profile(ctx, *, user: discord.Member=None):
if(user == None):
user = ctx.message.author
My question still remains, is there any way to pass ctx as a default argument?