Answer the question
In order to leave comments, you need to log in
The function with viewing all server users does not work. What is the problem?
Hello. In general, you need to display the nickname of each user on the server in the console.
I am using this loop:
@bot.event
async def on_ready():
for guild in bot.guilds:
for member in guild.members:
print(member)
Answer the question
In order to leave comments, you need to log in
In general, I solved the problem.
The point was that Discord introduced Intents . This is a radical change in how bots are written. The intent basically allows the bot to subscribe to certain event segments. The events corresponding to each intent are documented in a separate intent documentation attribute.
To get started, you need to:
1. Go to discord.com/developers
2. Select your App
3. Go to the Bot section
4. Scroll to Privileged Gateway Intents and enable two items there.
After granting these "permissions" in Discord Developers, they must also be granted in the code itself and confirmed there, in my case it looked like this:
intents = discord.Intents(messages=True, guilds=True, members=True)
bot = commands.Bot(command_prefix = "-", intents=intents)
@bot.event
async def on_ready():
for member in bot.get_all_members():
print(member)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question