有没有办法通过DM发送嵌入消息?

时间:2020-08-10 22:32:37

标签: python discord discord.py

我正在discord.py中制作机器人,该机器人可以禁止踢球或其他任何动作。我被卡在当用户被踢时应该发送嵌入消息的位置,并且出现了一些语法错误({ “ resource”:“是私人的”, “ owner”:“ python”, “ code”:“语法错误”, “严重程度”:8 “ message”:“语法无效(第64行)”, “ source”:“ pylint”, “ startLineNumber”:64, “ startColumn”:22, “ endLineNumber”:64, “ endColumn”:22 })

我在互联网上找不到任何东西...

@commands.has_permissions(kick_members=True)
async def kick(ctx, member :discord.Member, *, reason=None):
    await member.kick(reason=reason)
    await ctx.channel.purge(limit=1)
    await client.get_user(member)
    await user.send(embed=discord.Embed(title=f"You have been banned from {ctx.message.guild.name}.", desctription=False, color=0xff6161)
                    embed.add_field(name=f"Reason: {reason}"))```

2 个答案:

答案 0 :(得分:0)

您应将其编辑为以下内容:

@commands.has_permissions(kick_members=True)
async def kick(ctx, member :discord.Member, *, reason=None):
    await member.kick(reason=reason)
    await ctx.channel.purge(limit=1)
    await client.get_user(member)
    embed = discord.Embed(title=f"You have been banned from {ctx.message.guild.name}.", color=0xff6161)
    embed.add_field(name="Reason: ", value = reason)
    await user.send(embed=embed)
    

答案 1 :(得分:0)

# create the embed
embed = discord.Embed(title=f"You have been banned from {ctx.message.guild.name}.", color=0xff6161)
    embed.add_field(name="Reason: {reason}")

# send member the embed
await member.send(embed=embed)