首页 > 解决方案 > 我的 on_member_join 没有发送欢迎消息

问题描述

所以,我正在为我所在的服务器制作一个机器人,并尝试在成员加入时添加欢迎消息。到目前为止,它一直没有工作,也没有给出错误。有什么问题吗?

async def on_member_join(member):
    print("working") #I have this here to check to see if its being called, but no message is printed.
    rules = client.get_channel(772263419210235916)
    verify = client.get_channel(772995392521895937)
    channel = client.get_channel(772583213797212211)
    embed=discord.Embed(title="Welcome to Delight Stuidos!",
                        description=f"""{member.mention} has joined! \nDon't forget to read the {rules.mention}, and react with the purple star in {verify.mention}!
                        Enjoy your stay ^^""",
                        color = discord.Colour.orange())
    embed.set_thumbnail(url=f"https://i.ibb.co/NC2Wgnk/DS.png")
    await channel.send(embed=embed)

还启用了意图,所以我不知道发生了什么。

标签: pythondiscorddiscord.py

解决方案


更改了一些可能导致错误的内容

async def on_member_join(member):
    try:
        print("working") #I have this here to check to see if its being called, but no message is printed.
        rules = member.guild.get_channel(772263419210235916)
        verify =  member.guild.get_channel(772995392521895937)
        channel =  member.guild.get_channel(772583213797212211)
        embed=discord.Embed(title="Welcome to Delight Stuidos!",
                        description=f"{member.mention} has joined! \nDon't forget to read the {rules.mention}, and react with the purple star in {verify.mention}!\n Enjoy your stay ^^",
                        color = discord.Colour.orange())
        embed.set_thumbnail(url="https://i.ibb.co/NC2Wgnk/DS.png")
        await channel.send(embed=embed)
    except Exception as e:
        print(e)

推荐阅读