【问题标题】:Can't send private messages from my discord bot to user?无法从我的不和谐机器人向用户发送私人消息?
【发布时间】:2020-05-31 08:55:26
【问题描述】:

我想使用我的 discord 机器人向特定用户发送私人消息。我正在使用不和谐==1.0.1 不和谐.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}')

【问题讨论】:

    标签: python bots discord dm


    【解决方案1】:

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

    根据文档

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

    应该是这样的

    ctx.author.send('Hi')
    

    【讨论】:

      猜你喜欢
      • 2022-01-08
      • 2018-11-19
      • 2020-11-12
      • 2020-07-28
      • 2021-04-03
      • 2012-09-21
      • 2018-01-13
      • 1970-01-01
      • 2019-10-28
      相关资源
      最近更新 更多