我正在开发一个支持机器人,但它并不完全符合预期。机器人不会直接进入 DMS,而是在触发器中发送消息。当我运行命令时,我必须在它 DMS 我之前放置一条消息。然后它运行所有步骤,但在我 dm 它其他东西之后,它发送原始上下文消息。
@bot.command()
async def contact(ctx, *, message):
channel = bot.get_channel(766311471063498852)
embed1 = discord.Embed(colour=discord.Colour.blue())
embed1.add_field(name="Your support lays behind this bot.", value="Do you need support?", inline=True)
embed_1sent = await ctx.author.send(embed=embed1)
embed2 = discord.Embed(colour=discord.Colour.blue())
embed2.add_field(name="Alright.", value="What would you like to send to staff?", inline=True)
await embed_1sent.add_reaction("<a:CheckMark:768095274949935146>")
await embed_1sent.add_reaction("<a:XMark:768095331555606528>")
def check(reaction, member):
return member == member and str(reaction.emoji)== "<a:CheckMark:768095274949935146>"
try:
reaction, member = await bot.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.Timeout.Error:
await member.send("You took too long. Command cancelled.")
else:
await member.send(embed=embed2)
await channel.send(f"From: {member} {message}")
def check(reaction, member):
return member == member and str(reaction.emoji)== "<a:XMark:768095331555606528"
try:
reaction, member = await bot.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.Timeout.Error:
await member.send("You took too long. Command cancelled.")
else:
await member.send("Command promt cancelled.")
答案 0 :(得分:0)
向用户发送消息的正确方法是使用 .create_dm()
方法。所以在发送你的嵌入时,你应该有更多这样的东西。
embedOne = discord.Embed(
color = discord.Color.Blue()
)
embedOneadd_field(name = "Your support lays behind this bot.", value = "Do you need support?", inline = True)
userDM = ctx.author.create_dm()
embedOneMessage = await userDM.send(embed = embedOne)