0

我想使用我的不和谐机器人向特定用户发送私人消息。我正在使用 discord==1.0.1 discord.py==1.3.1。我已经尝试使用文档(https://discordpy.readthedocs.io/en/latest/api.html?highlight=private%20message#discord.DMChannel),但我不明白。我尝试了以下代码,但没有奏效:

@client.command()
async def cmds(ctx):
    embed = discord.Embed(title='Discord Server Befehle',
                          description='Description',
                          color=0x374883)

    [...]

    msg = await ctx.send(embed=embed)
    await ctx.author.create_dm('Hi')
    print(f'{command_prefix}help ausgeführt von {ctx.author}')
4

1 回答 1

1

尝试使用 send 函数而不是 create_dm。create_dm 仅在两个用户之间创建频道,据我所知,discord 会自动创建频道。

根据文件

This should be rarely called, as this is done transparently for most people.

所以应该是

ctx.author.send('Hi')
于 2020-02-16T10:09:03.327 回答