Newbie here #370
-
I have 2 questions 1º Can I add a timer and iterations (like in routines), to avoid spamming a command? 2º I'm trying to count how many messages I've sent, but I'm having some issues. Thanks in advance. `from twitchio.ext import commands msg_counter = 0 class Bot(commands.Bot):
bot = Bot() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi, Please do not use time.sleep() as this is blocking the event loop. You should be using asyncio.sleep() if you need to pause a coroutine. I'm also not quite sure why you are calling
Don't forget you can join the Discord support server for further help where examples will most likely have already been posted for this :) |
Beta Was this translation helpful? Give feedback.
-
For reference for others: the goal was to add a cooldown for the commands, which can be achieved using the Cooldown decorator. |
Beta Was this translation helpful? Give feedback.
Hi,
Please do not use time.sleep() as this is blocking the event loop. You should be using asyncio.sleep() if you need to pause a coroutine.
Globals are also a bad practice to use, especially in an OOP style framework. Simply create an attribute of the bot subclass.
I'm also not quite sure why you are calling
list()
on your prefixes when they are already a listtag = ['!', '?']
The same goes for channels.....
self.msg_counter = 0
…