【问题标题】:send() takes from 1 to 2 positional arguments but 3 were givensend() 接受 1 到 2 个位置参数,但给出了 3 个
【发布时间】:2021-01-08 02:52:33
【问题描述】:
@bot.event
async def on_message(message):
    channel = bot.get_channel('757774774075261051')
    if message.guild is None and message.author != bot.user:
        await message.channel.send(channel, message.content)
    await bot.process_commands(message)

由于某种原因我得到这个错误有什么帮助吗?

错误:

    await message.channel.send(channel, message.content)
TypeError: send() takes from 1 to 2 positional arguments but 3 were given

【问题讨论】:

    标签: error-handling discord.py-rewrite


    【解决方案1】:

    使用 new(v1.0 之后)Messageable.send() 方法,您不再需要通道作为参数,因此您只需编写:

    await message.channel.send(message.content)
    

    如果您想知道discord.py(v1.0 之前)和discord.py rewrite(v1.0 之后)之间的变化,here's a link

    【讨论】:

      猜你喜欢
      • 2022-01-04
      • 1970-01-01
      • 2020-07-22
      • 2019-06-28
      • 1970-01-01
      • 2023-03-03
      • 2016-10-13
      • 2019-03-12
      • 2019-04-20
      相关资源
      最近更新 更多