如何让 discord.py 机器人向特定用户发送 DM

How to get discord.py bot to DM a specific user

我为这个答案搜索了很多,但我没有找到。我想使用一个建议命令,每当有人使用它提出一个想法时,它就会私信给我,而且只私信我。

您必须使用 send_message 方法。在此之前,你得先找到自己对应的User

@client.event
async def on_message(message):
    # we do not want the bot to reply to itself
    if message.author == client.user:
        return

    # can be cached...
    me = await client.get_user_info('MY_SNOWFLAKE_ID')
    await client.send_message(me, "Hello!")
@client.event
async def on_message(message):
    if message.content.startswith("#whatever you want it to be")
        await client.send_message(message.author, "#The message")

用你想要的词替换标签的东西。例如:#whatever you want it be could be "!help". #消息可以是"The commands are...".