Samuel Nababan
Samuel Nababan

Reputation: 1

discord.py - bot not responding even though no error messages

I just started learning discordpy but i got stuck after my bot wasn't responding even though i followed the documentation and no error messages. The bot is online but doesn't respond to my messages. Im using python 3.8

import discord

client = discord.Client()


@client.event
async def onmessage(message):
    message.content.lower()
    if message.content.startswith("hello"):
        await message.channel.send("Hello!")

client.run('token')

Upvotes: 0

Views: 250

Answers (2)

Sir Darren
Sir Darren

Reputation: 1

Change onmessage to on_message. Also do from discord.ext import commands. That is what you are missing because in order to use @client.event you must have discord.ext imported...Your code should work after that

Upvotes: 0

Jawad
Jawad

Reputation: 2041

Change onmessage to on_message

Upvotes: 1

Related Questions