title: Trying to create a Discord Welcome/Leave Bot
body: <p>I'm trying to create a bot that publicly and privately (via DM) welcomes a new user to a Discord server <strong>AND</strong> sends a message to the Moderator channel when a user leaves the server.</p>
  
  <p>I can get the welcome dm and welcome message working, but when I add the code after #Mod Leave Announcement nothing happens.</p>
  
  <pre><code>import all necessary commands and libraries
  import discord
  import asyncio
  import logging
  
  @client.event
  async def on_ready():
  print('logged in as')
  print(client.user.name)
  print(client.user.id)
  print('-----')
  newUserDMMessage = "Welcome DM"
  
  #Public Welcome
  @client.event
  async def on_member_join(member):
  print("Recognised that a member called " + member.name + " joined")
  await client.send_message(member, newUserDMMessage)
  await client.send_message(discord.Object(id='CHANNELID'), 'Welcome!')
  print("Sent message to " + member.name)
  print("Sent message about " + member.name + " to #CHANNEL")
  
  #Mod Leave Announcement
  @client.event
  async def on_member_remove(member):
  print("Recognised that a member called " + member.name + " left")
  await client.send_message(discord.Object(id='CHANNELID'), member.name + ' left')
  print("Sent message to #CHANNEL")
  
  client.run('Token')
  </code></pre>