Discord bot only responds to one command

I’m setting up a simple Python Discord bot, but it only seems to respond to one event/command. It only responds to when someone says "supreme sauce" it sends "raw sauce" but doesn’t respond to anything else such as ".ping" or ".clear".

Is there anything that I’m doing wrong?

My code:

import discord from discord.ext import commands import time  client = commands.Bot(command_prefix = '.')  @client.event async def on_ready():     print(f'{client.user} has successfully connected to Discord!')  @client.event async def on_message(message):     if 'supreme sauce' in message.content:         await message.channel.send('raw sauce')  @client.command() async def ping(ctx):     await ctx.send(f'Pong! {round(client.latency * 1000)}ms')  @client.command async def clear(ctx, amount=10):     await ctx.channel.purge(limit=amount)      client.run('My Token') 
Add Comment
1 Answer(s)

on_message takes priority over commands. If you want both things to happen, do like this:

async def on_message(message):      if message.author == bot.user: return #Makes sure it can't loop itself when making messages     await bot.process_commands(message)     #rest of your code here 

This makes it so that when a message is sent, it will check if that message is a command and go from there, then it will execute the on_message code like normal

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.