Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
81 views
in Technique[技术] by (71.8m points)

python - Discord API. exception error on on_member_remove()

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:UsersFilbertAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagesdiscordclient.py", line 343, in _run_event await coro(*args, **kwargs) TypeError: on_member_remove() takes 0 positional arguments but 1 was given

question from:https://stackoverflow.com/questions/65924006/discord-api-exception-error-on-on-member-remove

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...