简体   繁体   中英

Is it possible for me with discord.py to be able to have my bot DM someone when I mention them?

更具体地说,我希望在使用我的命令前缀和我分配给它的任何命令后,告诉机器人向我提到的用户发送消息。

Yes. If you're using the commands extension , you can use a MemberConverter or UserConverter to get the Member or User object, respectively. Otherwise, you can use the Message.mentions attribute of the Message object to get a list of the Member s that were mentioned in the message. Then, you can use the Member.send / User.send method to DM them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM