Home > OS >  Why isnt my discord bot answering to my messages?
Why isnt my discord bot answering to my messages?

Time:12-03

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:

  1. Use on_message instead of in_message.
  2. Format string 'Hello! {message.author.mention}' like f'Hello! {message.author.mention}'.
  • Related