Reputation: 53
Hello I am starting to program my first bot for discord in python, and I find myself with a small problem and it is that although it seems that the code is correct it seems that it is not doing anything at all.
The idea is that the bot listens when a new user joins the server and then greets them on a specific channel
This is the code: Edit: I have added the new code that I have right now, however the problem persists, the intirenances are also activated from the discord developer portal.
I also want to add that the bot has an on_ready with a print ("Is working") to check if the bot is started correctly.
import discord
from discord.ext import commands
from discord.utils import get
intents = discord.Intents.default()
intents.members = True
#Bot prefix
bot=commands.Bot(command_prefix='>', intents=intents)
#Event
@bot.event
async def on_member_join(member):
get(member.guild.channels, id=768670193379049483)
await channel.send(f"{member} Welcome") ```
Upvotes: 0
Views: 1326
Reputation: 15728
You need to enable intents.members
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='>', intents=intents)
Also make sure to enable them in the developer portal
Edit:
channel = bot.get_channel(id)
# or
channel = get(member.guild.channels, id=some_id)
So your code would look like this:
@bot.event
async def on_member_join(member):
channel = get(member.guild.channels, id=768670193379049483)
await channel.send(f'{member} welcome')
Upvotes: 1