-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
34 lines (27 loc) · 920 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# bot.py
import os
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
WELCOME_CHID = int(os.getenv('WELCOME_CHID'))
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
guild = discord.utils.get(client.guilds, name=GUILD)
print(
f'{client.user} is connected to the following guild:\n'
f'{guild.name}(id: {guild.id})'
)
for ch in guild.channels:
print(ch.name, ch.id)
@client.event
async def on_member_join(member):
print(member.name, "This person has joined!!")
channel = client.get_channel(WELCOME_CHID) # replace id with the welcome channel's id
await channel.send(f"Welcome {member.mention} to scire-kila-kitu!")
# await member.send(f"Thank you for joining {member.guild.name}!")
client.run(TOKEN)