更新时间:2023-11-19 12:38:58
您不能在命令之外使用 bot.say
.
我可以在命令之外的其他地方使用 bot.say 吗?
没有.由于所涉及的魔法工作方式,它们只能在命令内部工作.
要让机器人重复发送的每条消息,您可以使用 send_message
.下面是一个例子.
@client.eventasync def on_message(消息):等待 client.send_message(message.channel, message.content)
I am writing a Discord bot using Python (v. 3.6.1). One of its functions detects all messages sent in a channel, processes them, and then responds to the messages in said channel. (At least, that's what I want it to do.)
I have tried this:
@bot.event
async def on_message(message):
await bot.say(message.content)
The function responds when a message is sent, but not in the way that I want it to. I instead get an error:
discord.errors.InvalidArgument: Destination must be Channel, PrivateChannel, User, or Object. Received NoneType
How would I fix this? Many thanks!
You cannot use bot.say
outside of a command.
Can I use bot.say in other places aside from commands?
No. They only work inside commands due to the way the magic involved works.
To have the bot repeat every message sent, you can use send_message
. Below is an example.
@client.event
async def on_message(message):
await client.send_message(message.channel, message.content)