'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
Solution 1:[1]
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 ")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 3nws |
