user15261001
user15261001

Reputation:

Discord.py welcomer doesn't work and I don't receive any errors. How to solve it?

I can't understand why my code doesn't work... I mean, when a member join the server, the BOT doesn't do anything, and I don't receive any error from the terminal. Please help me I'm desperate.

import asyncio
import discord
from discord import client, message
from discord.ext import commands
from discord.utils import get

client = commands.Bot(command_prefix="!")


@client.event
async def on_ready():
    print(f"{client.user} is now online! ID: {client.user.id}")
    activity = discord.Game(name="!help")
    await client.change_presence(status=discord.Status.idle, activity=activity)


@client.event
async def on_member_join(ctx, member):
    await ctx.send(f'Welcome {member.mention}')

#I made it as simple as possible, but it still doesn't work.

client.run(token="tokentokentokentokentokentoken")

Upvotes: 0

Views: 185

Answers (2)

stijndcl
stijndcl

Reputation: 5647

on_member_join only takes 1 argument.

Also, you need to enable the Members Intent for this to work.

import discord

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix="!", intents=intents)

Then enable it on your bot's dashboard. More info on how to do that in the docs.

Upvotes: 1

sahasrara62
sahasrara62

Reputation: 11247

discord.on_member_join(member) Documentation only accept one parameter member.

do implement following code

@client.event
async def on_member_join( member):
    await member.send(f'Welcome {member.mention}')

Upvotes: 0

Related Questions