This also removes the encoding on the top, since Python 3 does it by default. It also changes some methods to use `yield from`.
24 lines
604 B
Python
24 lines
604 B
Python
# This example requires the 'members' privileged intents
|
|
|
|
import discord
|
|
|
|
class MyClient(discord.Client):
|
|
async def on_ready(self):
|
|
print('Logged in as')
|
|
print(self.user.name)
|
|
print(self.user.id)
|
|
print('------')
|
|
|
|
async def on_member_join(self, member):
|
|
guild = member.guild
|
|
if guild.system_channel is not None:
|
|
to_send = f'Welcome {member.mention} to {guild.name}!'
|
|
await guild.system_channel.send(to_send)
|
|
|
|
|
|
intents = discord.Intents.default()
|
|
intents.members = True
|
|
|
|
client = MyClient(intents=intents)
|
|
client.run('token')
|