File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change 1
- # This example requires the 'members' privileged intent to use the Member converter.
2
-
3
1
import discord
4
2
3
+ intents = discord .Intents .default ()
4
+ intents .members = True # This intent requires "Server Member Intent" to be enabled at https://discord.com/developers
5
+ # ^ This may give you `read-only` warning, just ignore it.
5
6
6
- class MyClient (discord .Client ):
7
- async def on_ready (self ):
8
- print (f"Logged in as { self .user } (ID: { self .user .id } )" )
9
- print ("------" )
7
+ bot = discord .Bot (intents = intents )
10
8
11
- async def on_member_join (self , member : discord .Member ):
12
- guild = member .guild
13
- if guild .system_channel is not None :
14
- to_send = f"Welcome { member .mention } to { guild .name } !"
15
- await guild .system_channel .send (to_send )
16
9
10
+ @bot .event
11
+ async def on_ready ():
12
+ print ('Ready!' )
13
+
14
+
15
+ @bot .event
16
+ async def on_member_join (member : discord .Member ):
17
+ guild = member .guild
18
+ if guild .system_channel is not None : # For this to work, System Messages Channel should be set in guild settings.
19
+ await guild .system_channel .send (f"Welcome { member .mention } to { guild .name } !" )
17
20
18
- intents = discord .Intents .default ()
19
- intents .members = True
20
21
21
- client = MyClient (intents = intents )
22
- client .run ("TOKEN" )
22
+ bot .run ("TOKEN" )
You can’t perform that action at this time.
0 commit comments