anonymousEROS
anonymousEROS

Reputation: 13

Python Bot command not working but event is

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?')
    

Upvotes: 1

Views: 965

Answers (1)

Bagle
Bagle

Reputation: 2346

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:

Upvotes: 2

Related Questions