import discord
import sys
import time
import random

url = "https://youtu.be/skCQISEUVXM"

client = discord.Client()
active = True
token = ""
shamed = []
channels = []
timer = 0

@client.event
async def on_ready():
	global active
	channel = client.get_channel("429742815111544833")
	#await client.send_message(channel, "Old men, being taught a lesson")
	#await client.send_message(channel, str(active))

@client.event
async def on_message(message):
	global active
	global timer
	if(message.author.id in shamed and message.channel.id == 429742815111544833):
		await message.channel.send("Correct")
	if (message.author.id in shamed and message.channel.id in channels): #test serv
		sendmsg = False
		if(active):
			if len(message.attachments) > 0:
				for i in message.attachments:
					#print(i)
					if(i.url.lower().endswith(('.png', '.jpg', '.jpeg', '.gif'))):
						if (random.randint(0,2) == 0):
							sendmsg = True
			if(len(message.embeds) > 0):
				for i in message.embeds:
					#print(i)
					if(i.type.lower() == "image" or i.type.lower() == "rich"):
						if (random.randint(0,2) == 0):
							sendmsg = True
			if sendmsg:
				await message.channel.send(url)
	if(message.content.lower().startswith("!off")):
		await message.channel.send("Old men, running the world")
		await client.logout()
		sys.exit(0)
	if(message.content.lower().startswith("!active")):
		active = not active
		status = "Disabled"
		if (active):
			status = "Enabled"
		await message.channel.send("Harold is now " + status)
	if(message.content.lower().startswith("!harold")):
		newtime = int(time.time())
		#await message.channel.send(str(timer))
		#await message.channel.send(str(newtime))
		#print(client.emojis)
		if (newtime - timer > 300):
			timer = newtime
			await message.channel.send("Woe, harold upon ye " + url)
		else:
			await message.add_reaction(random.choice(client.emojis))

client.run(token)
sys.exit(1)
