【发布时间】:2021-07-24 13:06:11
【问题描述】:
很抱歉打扰大家,我知道这是重复的,但我没有评论的等级,所以我不得不再问一次,我看过其他一些关于这个的帖子,他们都说你手动获取公会 ID并在 on_ready() 中定义它:
@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 #
但是如何在 on_message() 中自动获取公会的 id,我希望我的机器人可以在各种服务器上运行,正如你所理解的那样,这不会真正起作用。
如果您需要更多上下文,它是一个您拥有货币并且可以在用户之间转移它们的机器人,我想检查 message.author 想要转移资金的用户是否真的存在。
提前致谢, 诺埃尔。
【问题讨论】:
标签: python python-3.x discord discord.py