on_member_join()缺少一个仅关键字参数:“ member”

时间:2020-09-04 09:14:36

标签: discord.py

因此,我正在制作一个如下所示的欢迎命令:

@client.event
async def on_member_join(self, *, member: discord.Member):
meant = member.mention
    member = discord.Guild.member
    guild = discord.Guild
    welcomz = [
        ', welcome to the server!',
        ' joined the party!',
        ' came just for the cake.',
        ', everyone welcomes you to the server!',
        ', go do some stuff here.',
        ', so you do know how an invite link works!',
        ', took you long enough!',
    ]
    try:
        await self.client.get_channel(guild.text_channel.id).send(f"{meant}" + random.choice(welcomz))
    except:
        print(f"Error occurred when welcoming member:{meant}")

,它带有错误。 我不太确定哪里出了问题。

1 个答案:

答案 0 :(得分:1)

请查看discord.py文档。 on_member_join()事件仅采用一个参数,即member

@client.event
async def on_member_join(member):
    channel = client.get_channel(730064641857683581)  # ID for your welcome channel.
    welcomz = [
        ', welcome to the server!',
        ' joined the party!',
        ' came just for the cake.',
        ', everyone welcomes you to the server!',
        ', go do some stuff here.',
        ', so you do know how an invite link works!',
        ', took you long enough!',
    ]
    try:
        await channel.send(f"{member.mention}, {random.choice(welcomz)}")
    except:
        print(f"Error occurred when welcoming member: {member}")