Python Discord.py是否在不使用on message函数的情况下返回用户名?

Python Discord.py是否在不使用on message函数的情况下返回用户名?,python,discord,discord.py,Python,Discord,Discord.py,我最近开始改进我的discord bots,不再使用on_message函数和一长串if语句,但现在我开始使用@bot.command(name=“”)如果我尝试使用message.author,它没有一条消息来检查作者。我怎样才能解决这个问题 @bot.command(name="start") async def some_crazy_function_name(ctx): if not currentcreator == 0:

我最近开始改进我的discord bots,不再使用
on_message
函数和一长串if语句,但现在我开始使用
@bot.command(name=“”)
如果我尝试使用message.author,它没有一条消息来检查作者。我怎样才能解决这个问题

@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

这是更新后的代码,如果你懒惰,我不建议复制这些代码

@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)

完成。

ctx是您的命令。 例如,图像中有大量的方法

ctx.author |命令作者

ctx.channel.guild |公会

看看这些文件


但是您要求的是ctx.author

您可以提供您正在使用的代码片段吗?如果我在这里出错,请将其编辑到postCorrect me中,但您尚未定义
message
变量?您还可以使用
ctx.author
获取作者。您也可以直接使用
ctx.send()
进行响应。更多信息请参阅文档