3
votes

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
Could you supply a snippet of the code you are using? - sommervold
Edited it into the post - Tazgirl
Correct me if I'm wrong here but you have not defined the message variable? You can also use ctx.author to fetch the author. You can also directly use ctx.send() to respond. More info in the docs here - sommervold

2 Answers

1
votes

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

0
votes

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.