discord.py commands aren't working (no errors given)

Question:

(Code below is just for entertaining purposes only. Do not use this in discord servers). I honestly have no clue why it isn’t working. When I open a new python file with the exact same code, it works. However if I put it in my file with all the code it doesn’t for some reason. No output, no errors.

from discord.ext import commands

#Settings
KICK_ON_MESSAGE = False

TOKEN = "Token goes here"


client = commands.Bot(command_prefix="/")



@client.event
async def on_ready():
    print('Logged in!')


@client.event
async def on_message(message):
    if KICK_ON_MESSAGE == True:
        member = message.author
        await member.kick()
        print(str(member)+' has been succesfully kicked!')


@client.command()
async def test(ctx):
    await ctx.send('hi!')



client.run(TOKEN)



Thanks in advance.

Answers:

It might be because you didn’t process the commands at the on_message event.
Simply add await client.process_commands(message) at the end of the on_message event (outside the if statement) and it should start working.

Read this for reference: https://discordpy.readthedocs.io/en/latest/faq.html#why-does-on-message-make-my-commands-stop-working

Answered By: Libby

This happend!

Traceback (most recent call last):
  File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagesdiscordclient.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "c:UsersUserDesktopbotMaxRobot.py", line 79, in on_message
    await client.process_commands(message)
NameError: name 'message' is not defined
Answered By: Jonian B