added bigspenders command to guilt people into donating
This commit is contained in:
parent
5c38fed167
commit
6e74ac1fd5
1 changed files with 48 additions and 1 deletions
|
|
@ -403,6 +403,53 @@ class ChatGPT(commands.Cog):
|
|||
log_filepath.writelines(log_data)
|
||||
await ctx.send(f'Generated by: {ctx.author.name}\nPrompt: {prompt}', file=f)
|
||||
|
||||
@commands.command(
|
||||
description="Big Spenders",
|
||||
help="Generate a list of the biggest spenders. Usage: !bigspenders",
|
||||
brief="Generate list of big spenders"
|
||||
)
|
||||
async def bigspenders(self, ctx):
|
||||
filenames = os.listdir(self.data_dir + "logs/")
|
||||
user_cost_dict = {}
|
||||
for filename in filenames:
|
||||
if ".log" in filename:
|
||||
with open(f"{self.data_dir}logs/{filename}", 'r', encoding="utf-8") as f:
|
||||
for line in f:
|
||||
try:
|
||||
if "!dalle3hd" in line:
|
||||
cost = 0.08
|
||||
username = line[0:line.index(':')]
|
||||
if " " in username:
|
||||
break
|
||||
if username not in user_cost_dict:
|
||||
user_cost_dict[username] = 0
|
||||
user_cost_dict[username] += cost
|
||||
elif "!dalle2" in line:
|
||||
cost = 0.02
|
||||
username = line[0:line.index(':')]
|
||||
if " " in username:
|
||||
break
|
||||
if username not in user_cost_dict:
|
||||
user_cost_dict[username] = 0
|
||||
user_cost_dict[username] += cost
|
||||
if "!dalle" in line or "!dalle3" in line:
|
||||
cost = 0.04
|
||||
username = line[0:line.index(':')]
|
||||
if " " in username:
|
||||
break
|
||||
if username not in user_cost_dict:
|
||||
user_cost_dict[username] = 0
|
||||
user_cost_dict[username] += cost
|
||||
else:
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
message = "Big Spenders:\n"
|
||||
sorted_dictionary = sorted(user_cost_dict.items(), key=lambda x: x[1], reverse=True)
|
||||
for user in sorted_dictionary:
|
||||
message += f"{user[0]}: ${user[1]:.2f}\n"
|
||||
await ctx.send(message)
|
||||
|
||||
|
||||
@commands.command(
|
||||
description="Dalle 2",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue