Reputation: 73
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")
Upvotes: 4
Views: 707
Reputation: 2917
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.
Upvotes: 3