Discord.py returning users name without using the on-message function?

Viewed 257

I've recently started revamping my discord bots by not using the on_message function plus a long list of if statements, but now that I've started using @bot.command(name=" ") if I try and use message.author it doesn't have a message to check for an Author. How can I fix this?

@bot.command(name="start")
async def some_crazy_function_name(ctx):
        if not currentcreator == 0:
                await message.channel.send("Someone is already making a profile, 
                please wait")
                currentcreater = message.author
                dir = r'C:\\Users\\User\Desktop\DiscordMMO\User-Profiles'
                MessageAuthor = str(message.author)
                ProfileDIR = os.path.join(dir,MessageAuthor)
                doesExist = os.path.exists(ProfileDIR)
               if doesExist == False:
               embed=discord.Embed(title="Creating Profile", url="", description=MessageAuthor+", your profile is being create
2 Answers

ctx is your command. Image you have loads of methods inside of this for example.

ctx.author | The command author

ctx.channel.guild | The guild.

Have a look at the docs.

But what you're asking for is ctx.author

Here's the updated code, if you're lazy, I don't recommend copying tho.

@bot.command(name="start")
async def some_crazy_function_name(ctx):
        if currentcreator != 0:
                await ctx.send("Someone is already making a profile, 
                please wait")
                currentcreater = ctx.author
                dir = r'C:\\Users\\User\Desktop\DiscordMMO\User-Profiles'
                MessageAuthor = str(ctx.author)
                ProfileDIR = os.path.join(dir,MessageAuthor)
                doesExist = os.path.exists(ProfileDIR)
               if doesExist == False:
                   embed=discord.Embed(title="Creating Profile", description=f"{MessageAuthor}, your profile is being created.")
                   await ctx.send(embed=embed)

and done.

Related