【发布时间】:2020-12-09 22:14:47
【问题描述】:
所以基本上我想要的是每当我的机器人加入任何公会时,它应该向我服务器中的特定频道发送一条消息,说明它被邀请到具有其名称的服务器,如果可能的话,还包括该服务器的邀请链接。我尝试了一些方法,但它们从未真正奏效。
@client.event
async def on_guild_join(guild):
channel = client.get_channel('736984092368830468')
await channel.send(f"Bot was added to {guild.name}")
它不起作用并引发以下错误:
Ignoring exception in on_guild_join
Traceback (most recent call last):
File "C:\Users\Rohit\AppData\Roaming\Python\Python37\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "c:\Users\Rohit\Desktop\discord bots\test bot\main.py", line 70, in on_guild_join
await channel.send(f"Bot was added to {guild.name}")
AttributeError: 'NoneType' object has no attribute 'send'
而且我真的不知道如何让机器人发送带有公会名称的公会邀请链接。
【问题讨论】:
-
尝试
channel = client.get_channel(736984092368830468)将频道作为整数。 -
不起作用@ThRnk 已经尝试过了
标签: python discord.py