I am trying to create a discord bot and I want it to create an invite to any server it joins. All I need help with is one line of code. I need to actually create the invite but I get:
Atribute Error: 'Guild' object has no attribute 'channel'
It happens on this line:
invite = await guild.channel.create_invite(reason=None, max_age=0, max_uses=0, temporary=False, unique=True)
The full block:
@client.event
async def on_guild_join(guild):
invite = await guild.channel.create_invite(reason=None, max_age=0, max_uses=0, temporary=False, unique=True)
with open("invites.json", "r") as f:
invites = json.load(f)
invites[guild.name] = invite # This line might have an issue but i havent got to test it yet
with open("invites.json", "w") as f:
json.dump(invites, f)
I know how to create an invite with a command but theres no ctx on on_guild_join (i dont think). Would i just have to add 'ctx' somewhere in the event arguments?