所以我有这个代码:
import discord
client = discord.Client()
token = "token"
@client.event
async def on_message(message):
if (message.channel.id == "channel"):
target_channel = client.get_channel("target")
await target_channel.send(message.content)
client.run(token, bot=False)
基本上应该获取一个服务器频道的消息并将它们发送到另一台服务器的频道。如果我在此频道中以我的用户身份编写代码,则代码运行良好,但是如果其他人在此频道中编写代码,我会收到此错误:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\haide\AppData\Roaming\Python\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\haide\PycharmProjects\pythonProject13\main.py", line 12, in on_message
await target_channel.send(message.content)
File "C:\Users\haide\AppData\Roaming\Python\Python39\site-packages\discord\abc.py", line 1064, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "C:\Users\haide\AppData\Roaming\Python\Python39\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message
有什么解决办法吗?