【问题标题】:Is there a way to make your bot copy messages to another channel?有没有办法让你的机器人将消息复制到另一个频道?
【发布时间】:2019-09-29 01:21:58
【问题描述】:

问题是我写了一些代码,我认为是正确的,但显然它是不正确的,所以我想问你们,因为你们可以更好地了解

@bot.event
async def on_message(message):

    if message.author == bot.user:
        print(message.author,message.content)
        return


    print(message.author,message.content)

    channel = bot.get_channel(576705173766930433)
    await channel.send('{0.author}: {0.message}'.format(message))

当我发送消息时,控制台会反对: 忽略 on_message 中的异常

Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 255, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\Desktop\Servant_Of_Paschen.py", line 38, in on_message
    await channel.send('{0.author}: {0.message}'.format(message))
AttributeError: 'str' object has no attribute 'author'

【问题讨论】:

    标签: python python-3.x bots discord


    【解决方案1】:

    对不起,我是一个人发现的

    await channel.send('{}: {}'.format(message.author, message.content))
    

    我想我想做的事

    【讨论】:

      猜你喜欢
      • 2021-11-08
      • 2019-12-31
      • 1970-01-01
      • 2021-01-23
      • 2021-01-07
      • 2020-12-31
      • 2023-04-04
      • 1970-01-01
      • 2020-12-28
      相关资源
      最近更新 更多