Python Discord py如何获取消息的作者并在dm中回复?
我正在尝试创建一个用户报告系统,自动向discord版主发送消息 我希望,除了发送上述信息外,它还获得了该信息的原始创建者,以防止系统可能被滥用,或与制作报告的用户取得联系 现在,我有代码将消息及其内容发送给版主,但是我找不到获取命令调用程序的正确方法 这就是我的代码:Python Discord py如何获取消息的作者并在dm中回复?,python,discord,discord.py,Python,Discord,Discord.py,我正在尝试创建一个用户报告系统,自动向discord版主发送消息 我希望,除了发送上述信息外,它还获得了该信息的原始创建者,以防止系统可能被滥用,或与制作报告的用户取得联系 现在,我有代码将消息及其内容发送给版主,但是我找不到获取命令调用程序的正确方法 这就是我的代码: #Commands @bot.command(pass_context=True) async def dm(ctx,*, message): author = bot.get_user(ctx.author) #Thi
#Commands
@bot.command(pass_context=True)
async def dm(ctx,*, message):
author = bot.get_user(ctx.author) #This try to get the author of the command
await ctx.message.delete() #This delete the message from the discord channel in which it was invoked
mod = bot.get_user(715816993969930311) #The Mod that will receive the message
await mod.send("Report: " + message + author)
您可以使用
ctx.author
属性,不必“获取”,因为它已经是discord.Member
对象
author=ctx.author
以下是的特点请原谅我的无知,但我想我不明白他想告诉我什么。我试图为
author=ctx.author
更改author=bot.get\u user(ctx.author)
,但它继续,无法发送调用它的用户。我还尝试将member属性添加到类中,并在稍后使用{author.idention}
引用它。是否启用了意图。members
呢?好的,我很傻,非常感谢您再次帮助我,解决方案是等待用户。发送(f“report:{author.idention}+message)
而不是使用+author