Skip to content
Snippets Groups Projects
Commit ca49a9b2 authored by dnns01's avatar dnns01
Browse files

Add countdown timer

parent 9e6fe999
No related branches found
No related tags found
No related merge requests found
......@@ -3,5 +3,5 @@
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (strolchibot)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (strolchibot)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
......@@ -18,7 +18,7 @@
<sourceFolder url="file://$MODULE_DIR$/strolchguru" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.9 (strolchibot)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.10 (strolchibot)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
......
from asyncio import sleep
from datetime import datetime
from twitchio.ext import commands, routines
class Countdown(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.timer.start()
self.until = datetime(year=2022, month=4, day=5, hour=20)
@routines.routine(minutes=1)
async def timer(self):
now = datetime.now()
diff = (self.until - now).seconds // 60 + 1
if diff > 0:
await self.bot.channel().send(str(diff))
@timer.before_routine
async def timer_before(self):
await sleep(60 - datetime.now().second)
......@@ -9,7 +9,7 @@ from twitchio import Channel, Message
from twitchio.ext import commands
from twitchio.ext.commands import Context
import chat_commands, giveaway, klassenbuch, link_protection, spotify_cog, vote_cog
import chat_commands, giveaway, klassenbuch, link_protection, spotify_cog, vote_cog, countdown
load_dotenv()
......@@ -34,6 +34,7 @@ class StrolchiBot(commands.Bot, ABC):
self.add_cog(link_protection.LinkProtection(self))
self.add_cog(giveaway.Giveaway(self))
self.add_cog(chat_commands.Commands(self))
self.add_cog(countdown.Countdown(self))
@staticmethod
async def send_me(ctx, content):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment