-
Notifications
You must be signed in to change notification settings - Fork 9
/
welcome.py
46 lines (39 loc) · 1.67 KB
/
welcome.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
35
36
37
38
39
40
41
42
43
44
45
46
BOT_PREFIX = "Your Bot's Prefix Here"
BOT_TOKEN = "Your Bot Token Here"
WELCOME_CHANNEL_ID = Welcome Channel ID Here #Put it without " " Ex - 620498262436347905
LEAVE_CHANNEL_ID = Leave Channel ID Here #Put it without " " Ex - 620363449879052624
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix=BOT_PREFIX, intents=discord.Intents.all())
@bot.event
async def on_ready():
print("Logged in as", bot.user.name)
@bot.event
async def on_member_join(member):
try:
channel = bot.get_channel(WELCOME_CHANNEL_ID)
try:
embed = discord.Embed(colour=discord.Colour.green())
embed.set_author(name=member.name, icon_url=member.avatar.url)
embed.add_field(name="Welcome" ,value=f"**Hey,{member.mention}! Welcome to {member.guild.name}\nI hope you enjoy your stay here!\nThanks for joining**", inline=False)
embed.set_thumbnail(url=member.guild.icon.url)
await channel.send(embed=embed)
except Exception as e:
raise e
except Exception as e:
raise e
@bot.event
async def on_member_remove(member):
try:
channel = bot.get_channel(LEAVE_CHANNEL_ID)
try:
embed = discord.Embed(colour=discord.Colour.red())
embed.set_author(name=member.name, icon_url=member.avatar_url)
embed.add_field(name="Good Bye", value=f"**{member.mention} just left us.**", inline=False)
embed.set_thumbnail(url=member.guild.icon_url)
await channel.send(embed=embed)
except Exception as e:
raise e
except Exception as e:
raise e
bot.run(BOT_TOKEN)