import argparse
import discord
import asyncio

client = discord.Client()

def parse_cmd_arguments(): #Allow arguments
    parser = argparse.ArgumentParser(description="Maple boss/daily timer")
    parser.add_argument("-test", "--test-run", action="store_true", help="Stop the bot before connecting to discord")
    parser.add_argument("--force-mac", action="store_true", help="forces a mac run")
    parser.add_argument("-r", "--reset-config", action="store_true", help="starts a clean run, reruns the setup/init")
    parser.add_argument("-s", "--silent", action="store_true", help="Suppress all errors")

    return parser
args = parse_cmd_arguments().parse_args()
_test = args.test_run
_force_mac = args.force_mac
_reset_cfg = args.reset_config
_silent = args.silent
_force_admin = False

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

@client.event
async def on_message(message):
    if message.content.startswith('^test'):
        counter = 0
        tmp = await client.send_message(message.channel, 'Calculating messages')
        async for log in client.logs_from(message.channel, limit=100):
            if log.author == message.author:
                counter += 1
        await client.edit_message(tmp, 'You have {} messages'.format(counter))
    elif message.content.startswith('^sleep'):
        tmp = await client.send_message(message.channel, "I am sleeping for 5 seconds!")
        await asyncio.sleep(5)
        await client.edit_message(tmp, "Done sleeping!")

client.run('MzQzMTEyNjY5MjExMTMxOTA3.DGZmww.ZJcXyJTNQfO2ORzVqKrfSWr57aw')