Skip to content
Advertisement

Simple Discord bot not functioning as its supposed to be |Python

I have recently started coding with python and ended up coding a discord bot. This is the code i ran:

import discord
client = discord.Client()


@client.event
async def help(message):
   if message.author == client.user:
    return
if message.content.startswith("!help"):
    await message.channel.send("Commands:!hello, !help ")
client.run(The token im obviously not going to share)

I think this should make the bot say:Commands:!hello, !help, when a user writes !help but in the end nothing happens. Anyone got an idea how i can improve the code so it works?Id love to know

Advertisement

Answer

The event’s name is on_message:

@client.event
async def on_message(message): 
    if message.author == client.user: 
        return 
    if message.content.startswith("!help"):
        await message.channel.send("Commands:!hello, !help ")

Advertisement