Python Twitch Bot - Message Object Send Method Not Working

I’m building a chat moderation bot for Twitch using Python and having trouble with the message handling. When someone types a banned word, my bot detects it correctly but throws an error when trying to send a response.

Here’s the code I’m using:

@bot.event()
async def handle_chat_message(msg):
    print(f"Chat message received:\nUser: {msg.author.name}\nText: {msg.content}")
    
    for prohibited_word in blacklist:
        if prohibited_word in msg.content.lower():
            print("Deleting inappropriate message.")
            
            await msg.send(f"/timeout {msg.author.name} 5s Please keep chat family-friendly.")
            await msg.send("Moderation action taken.")

The error I get is:

Chat message received:
User: testuser123
Text: [inappropriate content]
Deleting inappropriate message.
Traceback (most recent call last):
  File "/lib/python3.8/site-packages/twitchio/client.py", line 190, in wrapped
    await func(*args)
  File "bot.py", line 32, in handle_chat_message
    await msg.send(f"/timeout {msg.author.name} 5s Please keep chat family-friendly.")
AttributeError: 'Message' object has no attribute 'send'

I’m confused because the Message object should have a send method. I also tried using different approaches but get the same error. What am I missing here?

hey, you’re def on the right track! the error is 'cause msg.send() ain’t valid; msg is a Message obj. try using msg.channel.send() to send your response. good luck with your bot!