discord.py如何检查用户是否在服务器上? [英] discord.py How to check if user is on server?
本文介绍了discord.py如何检查用户是否在服务器上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要检查用户是否在服务器上.请帮我
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 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 #
这篇关于discord.py如何检查用户是否在服务器上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文