I made this small discord bot to show a friend how to do it, exactly how I have done it before. But it doesnt answer my message in discord, and I cant find the error.
import discord
import os
client = discord.Client()
@client.event
async def on_ready():
print('Online as {0.user}'.format(client))
@client.event
async def in_message(message):
if message.author == client.user:
return
if message.content.startswith('Hello'):
await message.channel.send('Hello! {message.author.mention}')
client.run(os.getenv('TOKEN'))
Sorry if its obvious, I just cant see it.
CodePudding user response:
- Use
on_message
instead ofin_message
. - Format string
'Hello! {message.author.mention}'
likef'Hello! {message.author.mention}'
.