I am having trouble getting my discord bot in python to see guild members (other than itself) or to trigger an action when a new member joins.
import os import discord intents = discord.Intents.default() intents.members = True from dotenv import load_dotenv load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') client = discord.Client() @client.event async def on_ready(): for guild in client.guilds: print( f'{client.user} is connected to the following guild:\n' f'{guild.name}(id: {guild.id})' ) for member in guild.members: print( f'{member.name}' ) @client.event async def on_member_join(member): print(f'Someone has joined the server.') client.run(TOKEN) The bot has administrator privileges in the guild. I have enabled all Privileged Intents on the bots page.
When run it can see that there are three members in the guild (guild.member_count) but only lists itself. It does absolutely nothing if a member leaves and rejoins.
https://stackoverflow.com/questions/66739466/discord-bot-not-seeing-guild-members-and-new-members-joining March 22, 2021 at 10:05AM
没有评论:
发表评论