如何使用来自 discord.py 的用户输入 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")
当它要求用户输入时,我说,例如,@Bob。既然我提到了他们,我该如何让它成为 DM @Bob?
您可以使用 mentions 属性,这将为您提供消息提及的用户列表
for ex 如果您想提及多个用户:-
msg = await client.wait_for("message", check=check2, timeout=30)
mentions = msg.mentions
for users in mentions:
await user.send("test")
否则,如果您只想发送一个用户,那么:-
msg = await client.wait_for("message", check=check2, timeout=30)
mentions = msg.mentions
user = msg.mentions[0]
await user.send("test")
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")
当它要求用户输入时,我说,例如,@Bob。既然我提到了他们,我该如何让它成为 DM @Bob?
您可以使用 mentions 属性,这将为您提供消息提及的用户列表
for ex 如果您想提及多个用户:-
msg = await client.wait_for("message", check=check2, timeout=30)
mentions = msg.mentions
for users in mentions:
await user.send("test")
否则,如果您只想发送一个用户,那么:-
msg = await client.wait_for("message", check=check2, timeout=30)
mentions = msg.mentions
user = msg.mentions[0]
await user.send("test")