cleaned up and added aliases to highscores

This commit is contained in:
phixxy 2024-01-21 00:19:28 -08:00
parent 5764767236
commit 274bfe9834
2 changed files with 9 additions and 5 deletions

View file

@ -17,7 +17,8 @@ async def handle_error(error):
@commands.command( @commands.command(
description="Highscores", description="Highscores",
help="Shows a bar graph of users in this channel and how many messages they have sent.", help="Shows a bar graph of users in this channel and how many messages they have sent.",
brief="Display chat highscores" brief="Display chat highscores",
aliases=["highscore"]
) )
async def highscores(ctx, limit=0): async def highscores(ctx, limit=0):
filename = str(ctx.channel.id) + ".log" filename = str(ctx.channel.id) + ".log"
@ -71,7 +72,8 @@ async def highscores(ctx, limit=0):
@commands.command( @commands.command(
description="Highscores Server", description="Highscores Server",
help="Shows a bar graph of users across all servers I am in and how many messages they have sent.", help="Shows a bar graph of users across all servers I am in and how many messages they have sent.",
brief="Display chat highscores" brief="Display chat highscores",
aliases=["highscore_server"]
) )
async def highscores_server(ctx, limit=0): async def highscores_server(ctx, limit=0):
@ -111,8 +113,10 @@ async def highscores_server(ctx, limit=0):
print(user_message_counts) print(user_message_counts)
print("printed") print("printed")
user_message_counts = remove_dict_keys_if_less_than_x(user_message_counts,limit) user_message_counts = remove_dict_keys_if_less_than_x(user_message_counts,limit)
keys = list(user_message_counts.keys()) keys = user_message_counts.keys()
values = list(user_message_counts.values()) print(keys)
values = user_message_counts.values()
print(values)
fig, ax = plt.subplots() fig, ax = plt.subplots()
bar_container = ax.barh(keys, values) bar_container = ax.barh(keys, values)
ax.set_xlabel("Message Count") ax.set_xlabel("Message Count")

View file

@ -159,7 +159,7 @@ async def folder_setup():
os.mkdir(folder_name) os.mkdir(folder_name)
return folder_names return folder_names
async def delete_all_files(path, safe_folders): async def delete_all_files(path, safe_folders=None):
for filename in os.listdir(path): for filename in os.listdir(path):
if os.path.isdir(path+filename) and not path+filename in safe_folders: if os.path.isdir(path+filename) and not path+filename in safe_folders:
shutil.rmtree(path+filename) shutil.rmtree(path+filename)