Python 3.x 如何通过dm';s Discord.py重写

Python 3.x 如何通过dm';s Discord.py重写,python-3.x,discord.py,Python 3.x,Discord.py,我正在使用discord.py rewrite中的一个bot,并试图通过dm发出一个命令来进行嵌入。问题是bot没有等待消息。这是我的代码,谢谢 @client.command() async def c_embed(ctx): user = ctx.author perms = ctx.author.permissions_in(ctx.channel) if perms.administrator: em = discord.Embed(description='What

我正在使用discord.py rewrite中的一个bot,并试图通过dm发出一个命令来进行嵌入。问题是bot没有等待消息。这是我的代码,谢谢

@client.command()
async def c_embed(ctx):
  user = ctx.author
  perms = ctx.author.permissions_in(ctx.channel)
  if perms.administrator:
    em = discord.Embed(description='What would you like the title to be?', color = discord.Colour.red())
    await user.send(embed=em)
    msg = await client.wait_for('message')
    title = msg.content
    em = discord.Embed(description='What would you like the Description to be?', color = discord.Colour.red())
    await user.send(embed=em)
    msg = await client.wait_for('message')
    desc = msg.content
    em = discord.Embed(title = "**Confirm Channel**", description = "Choose a channel for this msg to be in. Put Channel ID")
    em = discord.Embed(title=title, description=desc,color=discord.Colour.red())
    channel = msg.content
    await ctx.channel.send(embed=em)
    return

由于大量阅读文档和测试,现在这个问题已经解决了 机器人不只是等待响应,而是等待用户的响应

通过使用:

msg = await client.wait_for('message', check = lambda message: message.author == ctx.author)
它只接受作者的回复,这使得它在dm中等待

@client.command()
async def c_embed(ctx):
  user = ctx.author
  perms = ctx.author.permissions_in(ctx.channel)
  if perms.administrator:
    em = discord.Embed(description='What would you like the title to be?', color = discord.Colour.red())
    await user.send(embed=em)
    msg = await client.wait_for('message', check=lambda message: message.author == ctx.author)
    title = msg.content
    em = discord.Embed(description='What would you like the Description to be?', color = discord.Colour.red())
    await user.send(embed=em)
    msg = await client.wait_for('message', check=lambda message: message.author == ctx.author)
    desc = msg.content
    em = discord.Embed(title = "**Confirm Channel**", description = "Choose a channel for this msg to be in. Put Channel ID", color = discord.Colour.red())
    await user.send(embed=em)
    msg = await client.wait_for('message', check=lambda message: message.author == ctx.author)
    channel = msg.content
    em = discord.Embed(title=title, description=desc,color=discord.Colour.red())
    await ctx.channel.send(embed=em)
    return

这里的问题是什么?你只是放了一堆代码,我们该怎么处理?有任何错误/回溯吗?结果如何?预期的结果是什么。请在测试完你的代码后看一看,我没有看到任何错误。请更详细地解释一下,正如Łukasz Kwieciński所提到的,哪里出了问题。我运行它时没有错误。但是当我使用这个命令时,它不会等待用户的消息。也许用户不允许DMsNo,我在自己身上测试这个命令,我打开了我的dm。