P
P
pythonMyLife2020-11-30 20:19:04
Python
pythonMyLife, 2020-11-30 20:19:04

Why are events not working in discord.py?

I am writing a discord bot in python, I want to display a welcome message when a user logs into the server.

import discord
from discord.ext import commands

TOKEN = settings ['token']

bot = commands.Bot (command_prefix = settings ['prefix'])

@bot.event
async def on_member_join (member):
    print(f'Присоединился {member.user}')
    await member.send("Hi!")

bot.run (TOKEN)


There are no errors on startup... and the code doesn't work. Please, help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-12-01
@pythonMyLife

Event on_member_joinrequires members intent: https://discordpy.readthedocs.io/en/stable/api.htm...
9PpDNep.png
Enable required intents in bot control panel:
4JFTsbb.png
And then add argument intentsto bot constructor:
https://discordpy.readthedocs.io /en/stable/intents...

intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(..., intents=intents)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question