Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
How can I make a bot that listens for events but also has commands in discord?

I need my discord bot to listen for events and I need it to have commands. Here is an example of my problem

import os
from keepalive import keep_alive
from discord.ext import commands

client = commands.Bot(command_prefix = "$")

banned_words = [
"blah", "blahh", "blahhh"
]

@client.event
async def on_message(message):

    msg = message.content
    msgsend = message.channel.send

    if any(word in msg.lower() for word in banned_words):
        await message.channel.purge(limit=1)
        await msgsend("Please don't use banned words!")

@client.command()
async def dice(message, amount:int):
    await message.channel.send("blah blah blah")
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Add await client.process_commands(message) at the beggining of your on_message event. This code process commands and allow users to invoke/use them.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!