import discord
from discord.ext import commands
# Replace 'YOUR_BOT_TOKEN' with the actual bot token
TOKEN = 'YOUR_BOT_TOKEN'
WELCOME_MESSAGE = "Welcome to the server! We're glad to have you here 🎉"
# Set up the bot with appropriate intents
intents = discord.Intents.default()
intents.members = True # Needed to listen for member join events
bot = commands.Bot(command_prefix="!", intents=intents)
@

.event
async def on_ready():
print(f'Bot is ready! Logged in as {bot.user}')
@

.event
async def on_member_join(member):
try:
# Send a DM to the new member
await member.send(WELCOME_MESSAGE)
print(f"Sent welcome message to {member.name}")
except Exception as e:
print(f"Could not send message to {member.name}: {e}")
# Run the bot
bot.run(TOKEN)