import discord
import random
from datetime import datetime
import pandas as pd
import matplotlib.pyplot as plt
import csv


async def plot_user_activity(client, ctx):
    plt.style.use('fivethirtyeight')
    df = pd.read_csv('innovators.csv', encoding= 'unicode_escape')

    author = df['author'].to_list()

    message_counter = {}

    for i in author:
        if i in message_counter:
            message_counter[i] += 1
        else:
            message_counter[i] = 1
    
    # for not mentioning the bot in the line graph. 
    message_counter.pop('ninza_bot_test')
    
    authors_in_discord = list(message_counter.keys())
    no_of_messages = list(message_counter.values())

    plt.plot(authors_in_discord, no_of_messages, marker = 'o', markersize=10)
    plt.title('msg sent by author in the server.')
    plt.xlabel('Author')
    plt.ylabel('Message_count')

    plt.savefig('output2.png')
    plt.tight_layout()
    plt.close()

    await ctx.send(file = discord.File('output2.png'))

[((10, 4, 10, 36), 'matplotlib.pyplot.style.use', 'plt.style.use', ({(10, 18, 10, 35): '"""fivethirtyeight"""'}, {}), "('fivethirtyeight')", True, 'import matplotlib.pyplot as plt\n'), ((11, 9, 11, 66), 'pandas.read_csv', 'pd.read_csv', (), '', True, 'import pandas as pd\n'), ((29, 4, 29, 77), 'matplotlib.pyplot.plot', 'plt.plot', (), '', True, 'import matplotlib.pyplot as plt\n'), ((30, 4, 30, 50), 'matplotlib.pyplot.title', 'plt.title', ({(30, 14, 30, 49): '"""msg sent by author in the server."""'}, {}), "('msg sent by author in the server.')", True, 'import matplotlib.pyplot as plt\n'), ((31, 4, 31, 24), 'matplotlib.pyplot.xlabel', 'plt.xlabel', ({(31, 15, 31, 23): '"""Author"""'}, {}), "('Author')", True, 'import matplotlib.pyplot as plt\n'), ((32, 4, 32, 31), 'matplotlib.pyplot.ylabel', 'plt.ylabel', ({(32, 15, 32, 30): '"""Message_count"""'}, {}), "('Message_count')", True, 'import matplotlib.pyplot as plt\n'), ((34, 4, 34, 30), 'matplotlib.pyplot.savefig', 'plt.savefig', ({(34, 16, 34, 29): '"""output2.png"""'}, {}), "('output2.png')", True, 'import matplotlib.pyplot as plt\n'), ((35, 4, 35, 22), 'matplotlib.pyplot.tight_layout', 'plt.tight_layout', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((36, 4, 36, 15), 'matplotlib.pyplot.close', 'plt.close', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((38, 26, 38, 53), 'discord.File', 'discord.File', ({(38, 39, 38, 52): '"""output2.png"""'}, {}), "('output2.png')", False, 'import discord\n')]