Lacie/events/welcome.py
2026-01-09 15:55:49 +01:00

50 lines
1.9 KiB
Python

import discord
from discord.ext import commands
class Welcome(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_member_join(self, member):
bot_trap_role_id = 1439354601672282335
if any(role.id == bot_trap_role_id for role in member.roles):
return
# Welcome channel
welcome_channel = self.bot.get_channel(876772600704020533)
# Create DM embed with updated message
dm_embed = discord.Embed(
title="Welcome to the server!",
description=(
"Please read <#1241579091597987880> and <#1238234316396429312> if you haven't already. "
"Apart from that, any Paper Lily related discussion should go into the dedicated channel for it - "
"and make sure to claim the spoiler chat role if that's what you want to talk about.\n\n"
"Don't hesitate to ask the mods any questions using <@575252669443211264>, "
"and we hope you enjoy your stay!"
),
color=discord.Color.blurple()
)
dm_embed.set_footer(text=f"Joined {member.guild.name}")
dm_embed.timestamp = discord.utils.utcnow()
# Try to send DM
try:
await member.send(embed=dm_embed)
dm_success = True
except discord.Forbidden:
dm_success = False
except discord.HTTPException as e:
dm_success = False
# Send welcome message in channel
if welcome_channel:
if dm_success:
await welcome_channel.send(f"Welcome {member.mention} to the server!")
else:
await welcome_channel.send(f"Welcome {member.mention} to the server! I couldn't DM you the welcome message, so <@692683410132566016> will do that")
async def setup(bot):
await bot.add_cog(Welcome(bot))