且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

discord.py如何检查用户是否在服务器上?

更新时间:2023-11-30 12:07:40

您可以使用

You can search a guild by ID for a member by ID using discord.Guild.get_member(), which returns a discord.Member object if found, and None if not found.

@bot.event
async def on_ready():
    guild = bot.get_guild(ID_OF_GUILD) # find ID by right clicking on server icon and choosing "copy id" at the bottom
    if guild.get_member(ID_OF_MEMBER) is not None: # find ID by right clicking on a user and choosing "copy id" at the bottom
        # the member is in the server, do something #
    else:
        # the member is not in the server, do something #