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
        await guild.default_channel.send('Welcome {0.mention} to {1.name}!'.format(member, guild))

client = MyClient()
client.run('token')

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 = 'Welcome {0.mention} to {1.name}!'.format(member, guild)
            await guild.system_channel.send(to_send)


client = MyClient()
client.run('token')

Update new member example to not be broken.
Update new member example to not be broken.

Took forever but better late than never.

  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:
-         await guild.default_channel.send('Welcome {0.mention} to {1.name}!'.format(member, guild))
+             to_send = 'Welcome {0.mention} to {1.name}!'.format(member, guild)
+             await guild.system_channel.send(to_send)
+ 
  
  client = MyClient()
  client.run('token')
  
Update new member example to not be broken.
## Code Before:
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
        await guild.default_channel.send('Welcome {0.mention} to {1.name}!'.format(member, guild))

client = MyClient()
client.run('token')

## Instruction:
Update new member example to not be broken.
## Code After:
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 = 'Welcome {0.mention} to {1.name}!'.format(member, guild)
            await guild.system_channel.send(to_send)


client = MyClient()
client.run('token')
