'get members of any server discord. python
I am trying to get user ids from any server. This script worked before for me now it is giving two or three ids but no error. I know that discord has changed some policies to stop it. But I need it very badly. I kind of stuck with it. If there is a way to do it with requests please provide me guide for that.
import discord
token = ""
intents = discord.Intents.default()
intents.presences = True
intents.members = True
client = discord.Client(intents=intents)
global guild_id
guild_id = 905022021841338419
id_file = open("result.txt","a")
@client.event
async def on_ready():
guild = client.get_guild(guild_id)
print(guild)
for member in guild.members:
a = member.id
print(a)
a = str(a)+"\n"
id_file.write(a)
print("Online and ready")
id_file.close()
client.run(token,bot=False)
Solution 1:[1]
Your code should work if you remove the bot argument from you client.run.
Make sure you have enabled the SERVER MEMBERS INTENT on discord developers for your application.
More details about intents can be found on the discord.py documentation.
Solution 2:[2]
Well... you kind of need access to the server - "just saying". sarcasm
no but seriously, please don't do anything illegal, and if you really need to, make sure you join the server using https://discord.com/api/oauth2/authorize?client_id=**BOTID**&permissions=0&scope=bot
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Paul |
| Solution 2 | Anony Mous |
