From 24304b8b12afc21435ff20fa570a2597924372c6 Mon Sep 17 00:00:00 2001 From: pfero Date: Mon, 1 Apr 2019 00:53:32 +0200 Subject: [PATCH] Add cooldown for the happening --- bot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index a1a3749..4ce43ed 100644 --- a/bot.py +++ b/bot.py @@ -5,6 +5,7 @@ from os import listdir from os.path import splitext, basename from urllib.parse import urlparse from asyncio import Lock +from datetime import datetime, timedelta def url(str): try: @@ -23,6 +24,8 @@ class Client(discord.Client): print("Logged on as", self.user) self.emoji_lock = Lock() + self.lastime = None + async def on_message(self, message): if message.author == self.user: return @@ -32,7 +35,9 @@ class Client(discord.Client): lowermsg = message.content.lower() if "why" in lowermsg and ("happening" in lowermsg or "habbening" in lowermsg): - await message.channel.send("https://i.imgur.com/SFRw7aJ.png") # seedot.png + if not self.lastime or self.lastime + timedelta(hours=1) < datetime.now(): + await message.channel.send("https://i.imgur.com/SFRw7aJ.png") # seedot.png + self.lastime = datetime.now() name = None image_name = None