尝试使用 discord.py 创建 ModMail 但我 运行 进入语法错误

Trying to create ModMail using discord.py but I ran into Syntax Error

我正在创建一个类似于 ModMail 的 Discord Bot,但我在编码时 运行 遇到了错误。 代码:

   ​@bot.event
   ​async def on_message(message):
       ​if message.author.id == bot.user.id:
           ​return
   ​
       ​if message.author != message.author.bot:
           ​if not message.guild:
               ​embed= discord.Embed(color=discord.Color.blue())
               ​embed.add_field(name="AOS ModMail Support",
               ​value= (f"User Mention: {message.author.mention}\nUsername: {message.author}\nUser ID: {message.author.id}\n\n**Content**: {message.content}")
               ​await bot.get_guild(1111111111).get_channel(312312312324).
               ​send(embed=embed)

当我使用 DM 发送机器人时,我的终端看起来像这样:

await client.get_guild(832146513270145075).get_channel(841562259657850880).
    ^
SyntaxError: invalid syntax

你不能做这样的事情:

​await bot.get_guild(1111111111).get_channel(312312312324).
               ​send(embed=embed)

如果你想让它工作,把它全部放在一行中

​await bot.get_guild(1111111111).get_channel(312312312324).send(embed=embed)

但这不是很好的做法,您应该获取 guild/channel 并在不同的行中发送消息

guild = bot.get_guild(...)
channel = guild.get_channel(...)
await channel.send(embed=embed)

您也可以使用 bot.get_channel 来获得更短的代码

channel = bot.get_channel(...)
await channel.send(embed=embed)

PS:如果你真的希望它像你的方法一样分成两行,你应该使用反斜杠 \:

​await bot.get_guild(1111111111).get_channel(312312312324) \
    .send(embed=embed)