Discord.py - 查找有关发件人的信息

问题描述:

我正在制作一个简单的不和谐bot,并试图找出邮件的频道和发件人,因此,例如某些类型的d!salute blah,它将以"<SENDER> saluted blah!"回复,并伴有图片。我目前只知道如何使用client.say,它为我找到了渠道。我想知道的是如何检索发送消息的通道以及命令的发送者。谢谢Discord.py - 查找有关发件人的信息

您需要传递上下文,以便您可以访问消息对象。

@client.command(pass_context = True) #passing context 
async def salute(ctx): #context gets passed into the first parameter 
    print(str(ctx.message.author)) 
    print(str(ctx.message.channel) 
    print(str(ctx.message.content)) 

等等,你可以找到更多的消息对象在The docs