Browse Source

Add cooldown for the happening

master
pfero 6 years ago
parent
commit
24304b8b12
  1. 5
      bot.py

5
bot.py

@ -5,6 +5,7 @@ from os import listdir
from os.path import splitext, basename from os.path import splitext, basename
from urllib.parse import urlparse from urllib.parse import urlparse
from asyncio import Lock from asyncio import Lock
from datetime import datetime, timedelta
def url(str): def url(str):
try: try:
@ -23,6 +24,8 @@ class Client(discord.Client):
print("Logged on as", self.user) print("Logged on as", self.user)
self.emoji_lock = Lock() self.emoji_lock = Lock()
self.lastime = None
async def on_message(self, message): async def on_message(self, message):
if message.author == self.user: if message.author == self.user:
return return
@ -32,7 +35,9 @@ class Client(discord.Client):
lowermsg = message.content.lower() lowermsg = message.content.lower()
if "why" in lowermsg and ("happening" in lowermsg or "habbening" in lowermsg): if "why" in lowermsg and ("happening" in lowermsg or "habbening" in lowermsg):
if not self.lastime or self.lastime + timedelta(hours=1) < datetime.now():
await message.channel.send("https://i.imgur.com/SFRw7aJ.png") # seedot.png await message.channel.send("https://i.imgur.com/SFRw7aJ.png") # seedot.png
self.lastime = datetime.now()
name = None name = None
image_name = None image_name = None

Loading…
Cancel
Save