title: show user level system Discord.py
body: <p>i'm working on add level system</p>
  
  <pre><code>import discord
  from discord.ext.commands import Bot
  from discord.ext import commands
  import json
  import os
  import asyncio
  import time
  import random
  from discord import Game
  import math, time
  
  Client = discord.client
  client = commands.Bot(command_prefix = '!')
  Clientdiscord = discord.Client()
  
  os.chdir(r'C:\Users\Hema\Desktop\Level')
  
  @client.event
  async def on_ready():
  print('lvl ready')
  
  @client.event
  async def on_message(message):
  
  with open('users.json', 'r') as f:
      users = json.load(f)
  
      #code
      await update_data(users, message.author)
      await add_experience(users, message.author, 5)
      await level_up(users, message.author, message.channel)
  
  
  
  with open('users.json','w') as f:
      json.dump(users, f)
  
  
  if message.content == 'system lvl':
      await client.send_message(message.channel, '{} level up {}'.format(message.author.mention, lvl_end))
      users[message.author.id]['level'] = lvl_end
  
  @client.event
  async def on_member_join(member):
  with open('users.json', 'r') as f:
      users = json.load(f)
  
  #code
  
  await update_data(users, member)
  
  with open('users.json','w') as f:
      json.dump(users, f)
  
  async def update_data(users, user):
  if not user.id in users:
      users[user.id] = {}
      users[user.id]['experience'] = 0
      users[user.id]['level'] = 1
  
  async def add_experience(users, user, exp):
  users[user.id]['experience'] += exp
  
  async def level_up(users, user, channel):
  experience = users[user.id]['experience']
  lvl_start = users[user.id]['level']
  lvl_end = int(users[message.author.id]["experience"] ** (1/4))
  
  if lvl_start &lt; lvl_end:
      await client.send_message(channel, '{} level up {}'.format(user.mention, lvl_end))
      users[user.id]['level'] = lvl_end
  
  
  client.run("Token")
  </code></pre>
  
  <p>work perfectly ^)</p>
  
  <p>but problem showing when i want to know user level, by typing "system lvl"
  showing this error</p>
  
  <pre><code>=========== RESTART: C:\Users\Darzy\Desktop\Level\Bot_lvl.py ===========
  
  lvl ready
  Ignoring exception in on_message
  Traceback (most recent call last):
  File "C:\Users\Darzy\AppData\Local\Programs\Python\Python36-32\lib\site- 
  packages\discord\client.py", line 307, in _run_event
  yield from getattr(self, event)(*args, **kwargs)
  File "C:\Users\Darzy\Desktop\Level\Bot_lvl.py", line 31, in on_message
  await level_up(users, message.author, message.channel)
  File "C:\Users\Darzy\Desktop\Level\Bot_lvl.py", line 67, in level_up
  lvl_end = int(users[message.author.id]["experience"] ** (1/4))
  NameError: name 'message' is not defined.
  </code></pre>
  
  <p>i just wounder if it possible to fix that problem, i tried many methods, not worked:
  beside that, just modified author for user and still the same problem.
  i believe in stackoverflow. developers community ^)</p>