Twitch Bot Repeating Timed Loop - Python

So, I have a bot written in python, and I can not seem to get a loop going. What I want to do is have the bot say something in chat every X amount of seconds. For example, let’s say every 10 minutes, so every 600 seconds, I want the bot to say something.

I tried to start a function to do this with asyncio but I keep getting an error saying it’s unable to respond to echo messages.

Any help is greatly appreciated.

Here’s the relevant code I have (I removed the extra functions and such that already work:

import os
from twitchio.ext import commands

set up the bot

TMI_TOKEN=“omitted oauth”
CLIENT_ID=“omitted client id”

bot = commands.Bot(

async def event_ready():
print(f"{BOT_NICK} is alive!")
ws = bot._ws
await ws.send_privmsg(CHANNEL, f"/me is alive!")

async def event_message(ctx):
# make sure the bot ignores itself and the streamer
if == BOT_NICK.lower():

await bot.handle_commands(ctx)

if 'hi' in ctx.content.lower():
    await"Hi, @{}!")

async def looper(ctx):
#this is the function I want to run on a loop
start_forever_function() #or start forever function when bot is ready

async def start_forever_function():
await chan.send("Message " + str(time.gmtime()))

if name == “main”:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.