简体   繁体   English

如何使用来自 discord.py 的用户输入对 discord 用户进行 DM

[英]How to DM a discord user with user input from discord.py

def check2(msg):
    return msg.author == ctx.author and msg.channel == ctx.channel

msg = await client.wait_for("message", check=check2, timeout=30)
member = ???
await member.send("test")

When it asks for a user input, I say, for example, @Bob.当它要求用户输入时,我会说,例如,@Bob。 How do I make it DM @Bob given that I mentioned them?鉴于我提到了他们,我如何使它成为 DM @Bob?

you can use the attribute mentions which will give you a list of users the message mentions您可以使用属性提及,这将为您提供消息提及的用户列表

for ex if u want to mention multiple users:-例如,如果您想提及多个用户:-

msg = await client.wait_for("message", check=check2, timeout=30)
mentions = msg.mentions
for users in mentions:
    await user.send("test")

or else if you just wanna send one user then:-或者,如果您只想发送一个用户,那么:-

msg = await client.wait_for("message", check=check2, timeout=30)
mentions = msg.mentions
user = msg.mentions[0]
await user.send("test")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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