import discord
import logging
import random
import sys

client = discord.Client()
token = ""

nerds = []
dadarray = ["i'm", "im", 'i"m', "i’m"]
greetings = ["Hi ", "Hey there ", "Hi there ", "Hey "]
msgdict = {}

@client.event
async def on_message(message):
	if message.author.bot == True:
		return
	if ("dad" in message.content.lower()):
		await message.add_reaction(":dad:386211313606590475")
	if(len(message.content) > 150):
		return
	msg = message.clean_content.split(" ", 1)
	lastmsg = message.id
	if msg[0].lower() in dadarray:
		if random.randint(0,3) == 0 or str(message.author.id) in nerds:
			dad = random.choice(greetings) + msg[1] + ", I'm Dad"
			dadmsg = await message.channel.send(dad)
			await dadmsg.add_reaction(":dad:386211313606590475")
			dadid = dadmsg.id
			msgdict[lastmsg] = dadid
	else:
		if message.content.lower().startswith("i am "):
			if random.randint(0,3) == 0 or message.author.id in nerds:
				dad = random.choice(greetings) + message.clean_content[5:] + ", I'm Dad"
				dadmsg = await message.channel.send_message(dad)
				await dadmsg.add_reaction(":dad:386211313606590475")
				dadid = dadmsg.id
				msgdict[lastmsg] = dadid

@client.event
async def on_message_delete(message):
	if(message.id) in msgdict:
		dadmsg = await message.channel.fetch_message(msgdict[message.id])
		await dadmsg.delete()
@client.event
async def on_message_edit(message, after):
	if(message.id) in msgdict:
		dadmsg = await message.channel.fetch_message(msgdict[message.id])
		await dadmsg.delete()


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