【问题标题】:Cannot send message to certain channel using discord.py无法使用 discord.py 向特定频道发送消息
【发布时间】:2018-03-27 02:06:44
【问题描述】:

我目前正在开发一个不和谐的机器人,我碰巧遇到了这个问题。我对discord.py 比较陌生,这可能是一个新手问题,但无论如何我都会感谢您的帮助:)

我当前的代码:

@bot.listen()
async def on_message(message):
        messagecontent = message.content
        chan = message.channel
        if messagecontent.startswith("--"):
                pass
        else:
                embed=discord.Embed(title="Gathering Response...", color=0x00ffff)
                msg = bot.send_message(destination=chan,embed=embed)

当我运行它并发送消息时,我没有收到任何错误消息或任何反馈。它什么也不做。对于这个问题,我将不胜感激。

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    send_message() 是一个协程,这意味着你必须await 它。它看起来像:

    msg = await bot.send_message(destination=chan,embed=embed)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-08
      • 2020-12-03
      • 2021-03-24
      • 1970-01-01
      • 2021-05-03
      • 1970-01-01
      相关资源
      最近更新 更多