Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature added message when a new member joins #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
import discord
import os
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()

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

client = discord.Client(intents=intents)

bot = commands.Bot(command_prefix='!', intents=intents)

@client.event
async def on_ready():
print(f'We have logged in as {client.user}')

@client.event
async def on_member_join(member):

await member.create_dm()
await member.send(
f'Hi {member.name}, welcome to my Discord server!'
)

channel = client.get_channel(476753911819141120) # put your server's channel ID here
print(channel)
await channel.send(f"{member} has arrived!")

@client.event
async def on_message(message):
if message.author == client.user:
return

if message.content.startswith('$hello'):
await message.channel.send('Hello!')

if 'happy birthday' in message.content.lower():
await message.channel.send('Happy Birthday! 🎈🎉')

elif message.content == 'raise-exception':
raise discord.DiscordException

client.run(os.environ.get("TOKEN"))