我正在使用 discord.py 重写一个机器人,并且正在尝试发出命令以通过 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')
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
答案 0 :(得分:0)
由于大量阅读文档和测试,现在已解决 机器人不只是等待响应,而是等待用户响应。
通过使用:
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