Discord Selfbot 无法获得所有成员,只是其中的一部分

2022-01-15 00:00:00 python discord.py

问题描述

嘿,我试图让所有用户都在一个特定的指南中,我得到了部分用户,而不是所有用户,为什么?像这样所以请帮忙告诉我不和谐规则,因为我很了解,这是我做的代码,

Hey i am trying to get all the users in a specific guide, and i am getting part of the users and not all of them, why?, And i dont care about discord terms, i am not gonna spam servers or something like this so please help instead telling me the discord rules because i am know it well, This is the code i did,

import discord
import asyncio

intents = discord.Intents(messages=True, guilds=True, members=True)

client = discord.Client(intents=intents)


token = ""



@client.event
async def on_ready():
    print("Bot Is Ready!")
    guild = client.get_guild(328154277111398403)
    for member in guild.members:
        print(member)
        await asyncio.sleep(0.1)




client.run(token, bot=False)


解决方案

在 selfbots/userbots 的上下文中,discord.py 实际上并没有获取成员列表的能力(或者,至少,很大一部分它),因此不适合此任务.相反,您要么必须使用不同的库,要么编写自己的解决方案.继续阅读一些代码:)

in the context of selfbots/userbots, discord.py doesn't actually have the ability to get the member list (or, at least, a significant portion of it), and therefore is not suited for this task. Instead, you'll either have to use a different library or code your own solution. Keep on reading for some code :)

代码:
具有此支持的 python 库是 discum.
以下是使用 discum 获取成员列表所需的最少代码量:

Code:
A python lib with this support is discum.
Here's the least amount of code required to get the member list with discum:

import discum
bot = discum.Client(token='blah blah blah')

@bot.gateway.command
def helloworld(resp):
    if resp.event.ready_supplemental: 
        bot.gateway.fetchMembers("GUILD_ID_HERE", "CHANNEL_ID_HERE")

bot.gateway.run()

这是另一个创建名为 get_members 的函数的示例,该函数返回成员列表:https://github.com/Merubokkusu/Discord-SCUM/blob/master/examples/gettingGuildMembers.py

And here's another example that creates a function called get_members that returns the member list: https://github.com/Merubokkusu/Discord-S.C.U.M/blob/master/examples/gettingGuildMembers.py

还有更多示例:https://github.com/Merubokkusu/Discord-SCUM/blob/master/docs/fetchingGuildMembers.md

它是如何工作的?
由于我们不能像机器人帐户那样请求成员列表,因此我们需要利用成员列表(是的,您在去公会时看到的右侧的成员侧边栏).我们需要逐条阅读整篇文章.

How does it work?
Since we can't request for the member list the same way bot accounts can, we instead need to exploit the member list (yea, that members sidebar on the right that you see when going to a guild). We need to read that entire thing, piece by piece.

基本上它是如何完成的,客户首先订阅公会频道中的成员事件(Luna 在她的非官方 Discord 文档中对此进行了一些讨论,但遗漏了很多).然后,当用户滚动成员列表时,会发送更多惰性请求来获取成员列表的每个块.这就是 discum 中发生的情况:发送延迟请求,直到获取整个成员列表.这里有更多信息.

Essentially how it's done is the client first subscribes to member events in a channel in a guild (Luna somewhat went over this in her unofficial discord docs, but left out a lot). Then, as the user scrolls through the member list, more lazy requests are sent to get each chunk of the member list. And this is what happens in discum: lazy requests are sent until the entire member list is fetched. Here's some more info.

相关文章