So basically what I want is whenever my bot joins any guild it should send a message to a particular channel in my server stating that it is invited to a server with its name and if possible also the invite link of that server. I tried a few things but they never really worked.
@client.event
async def on_guild_join(guild):
channel = client.get_channel('736984092368830468')
await channel.send(f"Bot was added to {guild.name}")
It didn't work and throws the following error:
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'
And I really don't have any idea how to make the bot send invite link of the guild with the guild name.
channel = client.get_channel(736984092368830468)
with channel as an integer. – ThRnk