1 回答

TA貢獻1853條經驗 獲得超9個贊
在 Discordpy 文檔中并沒有真正找到任何允許獲取成員的特定內容。
所以我決定在服務器中獲取整個成員列表,并通過機器人過濾列表。
if message.content.startswith('<count'):
membersInServer = message.guild.members
# Filter to the list, returns a list of bot-members
botsInServer = list(filter(filterOnlyBots, membersInServer))
botsInServerCount = len(botsInServer)
# (Total Member count - bot count) = Total user count
usersInServerCount = message.guild.member_count - botsInServerCount
# Whatever you want to do with the count here
# Put this function somewhere...
# Filter the member list to only bots
def filterOnlyBots(member):
return member.bot
隨著服務器變得更大(更多成員),速度/性能可能是不利的,希望有人發布比我更好的解決方案。
添加回答
舉報