0
votes

i want to make a bot that say bruh when your mesage is equal to the word in bruh.txt

my code:

bruh_file = open("bruh.txt", "r")
bruh_mo = [(line.strip()).split() for line in bruh_file]
bruh_file.close()

@client.event
async def on_message(message):
  msg = message.content
  if message.author == client.user:
    return
  if any(word in msg for word in bruh_mo):
    await message.channel.send("bruh")

but when i try it , it did'nt responed and i get this:

Ignoring exception in on_message Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "main.py", line 53, in on_message if any(word in msg for word in bruh_mo): File "main.py", line 53, in if any(word in msg for word in bruh_mo): TypeError: 'in ' requires string as left operand, not list Ignoring exception in on_message Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "main.py", line 53, in on_message if any(word in msg for word in bruh_mo): File "main.py", line 53, in if any(word in msg for word in bruh_mo): TypeError: 'in ' requires string as left operand, not list 172.18.0.1 - - [30/Dec/2021 09:27:25] "HEAD / HTTP/1.1" 200 -

can someone help me

1

1 Answers

0
votes

The line bruh_mo = [(line.strip()).split() for line in bruh_file] makes bruh_mo a list of lists, so when you do any(word in msg for word in bruh_mo) you're basically checking if a list (i.e. word) exists in a string (i.e. msg). Hence the error TypeError: 'in ' requires string as left operand, not list.