A
A
AdvoKappa2020-05-29 22:18:12
Python
AdvoKappa, 2020-05-29 22:18:12

TypeError: on_message() missing 1 required positional argument: 'message', what should I do?

@bot.event
async def on_member_join(member):
with open('С:\Sublime Text 3\Level', 'r') as f:
    users = json.load(f)

@bot.event
async def on_message(ctx,message):

if message.content == 'system lvl':
    await ctx.send(message.channel, '{} level up {}'.format(user.mention, 
lvl_end))
    users[user.id]['level'] = lvl_end

with open('С:\Sublime Text 3\Level', 'r') as f:
    users = json.load(f)

await update_data(users, message.author)
await add_experience(users, message.author, 5)
await level_up(users, message.author, message.channel)

with open('С:\Sublime Text 3\Level','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(experience ** (1/4))

if lvl_start < lvl_end:
    await bot.send_message(channel, '{} level up {}'.format(user.mention, 
lvl_end))
    users[user.id]['level'] = lvl_end


Gives an error when writing system lvl = TypeError: on_message() missing 1 required positional argument: 'message', how to fix? Discord.py, Python.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-05-29
@AdvoKappa

The function takes only one parameter, message. You passed two
https://discordpy.readthedocs.io/en/latest/api.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question