I have recently started coding with python and ended up coding a discord bot. This is the code i ran:
JavaScript
x
12
12
1
import discord
2
client = discord.Client()
3
4
5
@client.event
6
async def help(message):
7
if message.author == client.user:
8
return
9
if message.content.startswith("!help"):
10
await message.channel.send("Commands:!hello, !help ")
11
client.run(The token im obviously not going to share)
12
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
:
JavaScript
1
8
1
@client.event
2
async def on_message(message):
3
if message.author == client.user:
4
return
5
if message.content.startswith("!help"):
6
await message.channel.send("Commands:!hello, !help ")
7
8