<filename>main.py
import discord
from collections import Counter
import pandas
import os

client = discord.Client()

@client.event
async def on_ready():
    print('Bot is ready')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('$boss'):
        await message.channel.send('Hello!')

    if message.content.startswith('$UserAnalyze'):
        if message.author.guild_permissions.manage_messages != True:
            return await message.channel.send('You do not have the permissions necessary to view the report!')
        data = []
        async for mesg in message.channel.history(limit = 1000):
            if mesg.author != client.user:
                data.append(mesg.author)
        
       
        count = dict(Counter(data))
        count = {'Author' : list(count.keys()), 'Count' : list(count.values())}
        count = pandas.DataFrame.from_dict(count)

        if len(count) == 0:
            await message.author.send('Nobody here')

        else: 
            txt = ''
            count = count.sort_values(by = 'Count', ascending = False).reset_index(inplace = False)
            count['Rank'] = list(i +1 for i in range(len(count)))
            for i in range(len(count)):
                txt += str(count.Author[i]) + ' - ' + str(count.Rank[i]) + ', '
                        
            await message.channel.send('Check your DMs!')
            await message.author.send(txt)

TOKEN = os.getenv("TOKEN")
client.run(TOKEN)

<filename>main.py
import discord
from collections import Counter
import pandas
import os

client = discord.Client()

@client.event
async def on_ready():
    print('Bot is ready')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('$boss'):
        await message.channel.send('Hello!')

    if message.content.startswith('$UserAnalyze'):
        if message.author.guild_permissions.manage_messages != True:
            return await message.channel.send('You do not have the permissions necessary to view the report!')
        data = []
        async for mesg in message.channel.history(limit = 1000):
            if mesg.author != client.user:
                data.append(mesg.author)
        
       
        count = dict(Counter(data))
        count = {'Author' : list(count.keys()), 'Count' : list(count.values())}
        count = pandas.DataFrame.from_dict(count)

        if len(count) == 0:
            await message.author.send('Nobody here')

        else: 
            txt = ''
            count = count.sort_values(by = 'Count', ascending = False).reset_index(inplace = False)
            count['Rank'] = list(i +1 for i in range(len(count)))
            for i in range(len(count)):
                txt += str(count.Author[i]) + ' - ' + str(count.Rank[i]) + ', '
                        
            await message.channel.send('Check your DMs!')
            await message.author.send(txt)

TOKEN = os.getenv("TOKEN")
client.run(TOKEN)
