1

Commands not working but events are tried overriding my on_message but that didn't work. When I comment out the second client.event and down client.command works. Any idea of what I could be doing wrong? am I missing something?

import discord
from discord.ext import commands
import random
import time 
from datetime import date

client = commands.Bot(command_prefix = '.')

#client = discord.Client()



@client.event
async def on_ready():
print('we have logged in as {0.user}'.format(client))


@client.command()
async def clr(ctx, amount=5):
   await ctx.channel.purge(limit=amount)



@client.command(aliases =['should', 'will'])
async def _8ball(ctx):
    responses =['As i see it, yes.',
                'Ask again later.',
                'Better not tell you now.',
                "Don't count on it",
                'Yes!']
    await ctx.send(random.choice(responses))


 @client.event()
async def on_message(message):
  if message.author == client.user:
     return
    
    

  if message.content.startswith('hello'):
     await message.channel.send('Hello how are you?')
    
2

1 Answer 1

2

Based on the docs (the ones mentioned by moinierer3000 in the comments) as well as other questions on stack (listed below), on_message will stop your commands from working if you do not process the commands.

@client.event()
async def on_message(message):
  if message.author == client.user:
     return
  if message.content.startswith('hello'):
     await message.channel.send('Hello how are you?')
  await client.process_commands(message)

Other questions like this:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.