discord.py - 如何向服务器所有者发送私人消息?

discord.py - How to send a private message to a server owner?

我正在尝试让我的 bot dm 在加入新服务器时成为服务器所有者。我试过这个:

@client.event
async def on_guild_join(guild):
     user = await client.fetch_user(guild.owner)
     await client.send_message(user,"hi there!")

但它给出了这个错误信息:

In user_id: Value "myname" is not snowflake

我不知道如何获取公会所有者的用户 ID,我查看了文档但找不到任何内容。

这是一个解决方案。您可以调用 owner argument on a Guild:

@client.event
async def on_guild_join(guild):
    owner = guild.owner
    await owner.send("hi there!")