I'm making a bot that, when it detects you are using a banned word, it will delete your message. Simple enough but, when I do that. The on_message function is repeating itself. I don't know why but I hope you can answer my question
@client.event
async def on_message(msg):
contents = msg.content.split(" ")
for word in contents:
if word.lower() in chat_filter: #ChatFilter is a list of words that cannot be used
try:
await msg.delete()
await msg.channel.send("**YOU ARE NOT ALLOWED TO USE THIS WORD!!!**")
except discord.errors.NotFound:
return
repeats itself
? – user10417531chat_filter
also in the message? You can add a check to ignore your own messages:if msg.author == client.user: return
– Patrick Haugh