0
votes
import discord
from discord.ext import commands

intents = discord.Intents(
                          messages = True, 
                          guilds = True, reactions = True, 
                          members = True, presences = True
                          )
bot = commands.Bot(command_prefix = "[", intents = intents)

@bot.event
async def on_ready():
    print("Bot ready")

@bot.event
async def on_member_join(member):
    print(f"{member} is ___")
    


@bot.event
async def on_member_remove():
    print("xxx")
    if member.id == 341212492212600832:
        invitelink = discord.TextChannel.create_invite(max_uses=1,unique=True)
        await member.send(f"you ___ bro. Here u go {inviteLink}")

bot.run("TOKEN")

Ignoring exception in on_member_remove Traceback (most recent call last): File "C:\Users\Filbert\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) TypeError: on_member_remove() takes 0 positional arguments but 1 was given

2

2 Answers

3
votes

As the error said, on_member_remove takes 1 positional argument member

@bot.event
async def on_member_remove(member): # You forgot to pass it
    # ...

Reference:

0
votes

Similar to on_member_join, on_member_remove gets passed member, as said in the docs. After fixing this issue, regenerate your token, as you included it in the original post.
Another issue: You shouldn't be creating an instance of discord.TextChannel. Instead, get that channel using bot.get_channel(id), and call create_invite on the TextChannel instance that get_channel returns.