更新时间: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 #