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
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 ")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.