-3

This is a function for a discord bot, it counts bad words in the BadWords variable, but the console shows me "TypeError: on_message() takes 0 positional arguments but 1 was given". Here is the code:

@bot.event
async def on_message(self):
    BadWords = ["*Bad words string*"]

    if message.content == BadWords:
        await ctx.send("Uh Oh, wacth your vocabulary")
testfile
  • 2,145
  • 1
  • 12
  • 31
Mau_RyT0
  • 3
  • 2
  • 2
    Is this a member function of a class? – ytan11 Jan 14 '22 at 23:51
  • 1
    Does this answer your question? [What is the purpose of the word 'self'?](https://stackoverflow.com/questions/2709821/what-is-the-purpose-of-the-word-self) – ytan11 Jan 14 '22 at 23:56

1 Answers1

3

You should add an argument to your method:

async def on_message(self, message):
Andrey
  • 400
  • 2
  • 8
  • 1
    If you want to use self, than on_message should be a method of a class^ – Andrey Jan 14 '22 at 23:56
  • To add onto the answer, the bad words aren't being counted in `BadWords`, and the code probably isn't going to function as intended as is when comparing the entirety of the message content to a list. OP should also consider that when adding an argument as @Andrey suggested. – metro Jan 14 '22 at 23:57