如何让机器人在另一个频道上说话? (discord.py)
How to make the bot speak on another channel? (with discord.py)
我想让我的机器人向某个频道发送消息,(但我没有输入 id,因为我的机器人将是 public)
我使用了这个命令:
await client.send_message(destination=teste, content='oi (hello)')
但它没有任何结果并给出以下错误:
Ignoring exception in on_message
Traceback (most recent call last):
File "PycharmProjects\LennieBot\venv\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "PycharmProjects/LennieBot/main.py", line 42, in on_message
if message.content.lower().startswith((prefix) + 'botavatar'):
NameError: name 'teste' is not defined
有人可以帮助我(不要用另一种语言来称呼这些词,我是葡萄牙语c:)
您可能没有定义变量“teste”。假设您想将消息发送到服务器频道,您必须先获得该频道:
teste = client.get_channel(“id”)
其中“id”是您要发送消息的频道 ID。请注意,这必须是字符串,而不是整数。
我想让我的机器人向某个频道发送消息,(但我没有输入 id,因为我的机器人将是 public) 我使用了这个命令:
await client.send_message(destination=teste, content='oi (hello)')
但它没有任何结果并给出以下错误:
Ignoring exception in on_message
Traceback (most recent call last):
File "PycharmProjects\LennieBot\venv\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "PycharmProjects/LennieBot/main.py", line 42, in on_message
if message.content.lower().startswith((prefix) + 'botavatar'):
NameError: name 'teste' is not defined
有人可以帮助我(不要用另一种语言来称呼这些词,我是葡萄牙语c:)
您可能没有定义变量“teste”。假设您想将消息发送到服务器频道,您必须先获得该频道:
teste = client.get_channel(“id”)
其中“id”是您要发送消息的频道 ID。请注意,这必须是字符串,而不是整数。