为discord.py bot启用意图 [英] Enable intents for discord.py bot
Im making a discord bot, and every time it joins a new server, the bot sends me the server info and an invite. However, when I've tested this, it always shows one member which is itself. I have both presence and members intents enabled in the discord developer portal, but it still isn't working.
I then changed some code to
Guild.fetch_members() to which I received the error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Intents.members must be enabled to use this.
As I said before, on the discord developers website member intents are enabled and I have had this code before without this issue.
When I had this code working before, it was using 1.5.x (I cant remember exactly) and now its using 1.6.0, so something in the new update may prevent this from working, but this is unusual to me, so how can I resolve this issue?
intents were introduced in
1.5.0 so I don't think they were working before, but answering your question
intents = discord.Intents.default() intents.members = True bot = commands.Bot(..., intents=intents)
Also remember to enable privileged member intents in the developer portal