我想使用 discord.py 为特定用户创建一个 DM,当他们响应时,它会在 DM 中将他们的消息发送回我。我该怎么做?我试图搜索,但找不到任何东西。
答案 0 :(得分:0)
您可以使用 wait_for
@bot.command()
async def dm_user(ctx, member: discord.Member):
try:
await member.send('Hi yo have 30 seconds to respond')
except discord.HTTPException:
await ctx.send('unable to message')
else:
try:
msg = await bot.wait_for('message', check = lambda x: x.channel == member.dm_channel and x.author == member, timeout=30)
except asyncio.TimeoutError:
await ctx.send('timed out')
finally:
await ctx.author.send(msg.content)