Files
bot.py
requirements.txt
Code
2 47
bot.py
import logging
import os
import discord
from dotenv import load_dotenv
load_dotenv()
logging.basicConfig(level=logging.INFO)
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_ready() -> None:
logging.info("Logged in as %s", client.user)
@client.event
async def on_member_join(member: discord.Member) -> None:
channel = member.guild.system_channel
if channel is None:
channel = next(
(
text_channel
for text_channel in member.guild.text_channels
if text_channel.permissions_for(member.guild.me).send_messages
),
None,
)
if channel is not None:
await channel.send("heyyyyy")
token = os.getenv("DISCORD_TOKEN")
if not token:
raise RuntimeError("DISCORD_TOKEN is not set in the environment")
client.run(token)