2017-07-18 51 views
0

我正在製作一個簡單的不和諧bot,並試圖找出郵件的頻道和發件人,因此,例如某些類型的d!salute blah,它將以"<SENDER> saluted blah!"回覆,並伴有圖片。我目前只知道如何使用client.say,它爲我找到了渠道。我想知道的是如何檢索發送消息的通道以及命令的發送者。謝謝Discord.py - 查找有關發件人的信息

回答

1

您需要傳遞上下文,以便您可以訪問消息對象。

@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