I need to check if the user is on the server. Please help me
I need to check if the user is on the server. Please help me
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 bottomif 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 #