Reputation: 11
I'm currently programming a bot and my first goal is to make the bot welcome and say goodbye to members that join or leave, but the bot sends nothing, not even showing any error.
@client.event
async def on_member_join(member):
print(" System: A member has joined the server!")
def sprint(str):
for c in str + '\n':
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(3./90)
sprint(" Bot: Oh hey, looks like "+member.name+" has joined..")
#send message to a specific channel
channel = client.get_channel(channel id from the welcome channel)
await channel.send("Hey! Welcome to the server, "+member.mention+"! I hope you read the #rules before doing anything, otherwise have fun and enjoy your stay!")
I did it last time before I recreated the script, but the on_member_join
thing doesn't work, not even on_member_leave
! (I'm doing the on_member_join
first to check if it's working)
My alternate account rejoined my server, but the bot (except MEE6) didn't send anything.. Is there anything you guys can help me?
Upvotes: 1
Views: 225
Reputation: 281
You'll need to enable the member intent by creating an instance of discord.Intents.default
, setting Intents.members to True, and passing the instance into your commands.Bot or discord.Client constructor, like:
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(intents=intents)
You'll also need to enable the members intent in the Discord dev portal (https://discord.com/developers). Go to that url, click on your application, go to the Bot tab, scroll down to the 'privileged gateway intents' section, and enable the members intent. Then, restart your bot, and member events should work. (for more info, look at https://discordpy.readthedocs.io/en/latest/intents.html)
Upvotes: 3