gpt4 book ai didi

error-handling - send()接受1到2个位置参数,但给出了3个

转载 作者:行者123 更新时间:2023-12-03 08:38:55 25 4
gpt4 key购买 nike

@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

最佳答案

使用新的(在v1.0之后) Messageable.send() 方法,您不再需要将channel作为参数,因此只需编写:

await message.channel.send(message.content)
如果您想知道 discord.py(在v1.0之前)和 discord.py rewrite(在v1.0之后)之间发生了什么变化,请 here's a link

关于error-handling - send()接受1到2个位置参数,但给出了3个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64001950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com