(guild_admin): Only reset study statistics.

This commit is contained in:
2021-09-30 22:14:17 +03:00
parent eb2e52d15c
commit 2374d3420f

View File

@@ -8,25 +8,25 @@ from core import Lion
from .module import module from .module import module
@module.cmd("statreset", @module.cmd("studyreset",
desc="Perform a complete reset of the server's study statistics.", desc="Perform a reset of the server's study statistics.",
group="Guild Admin") group="Guild Admin")
@guild_admin() @guild_admin()
async def cmd_statreset(ctx): async def cmd_statreset(ctx):
""" """
Usage``: Usage``:
{prefix}statreset {prefix}studyreset
Description: Description:
Perform a complete reset of the server's member statistics. Perform a complete reset of the server's study statistics.
This includes tracked time, coins, and workout counts. That is, deletes the tracked time of all members and removes their study badges.
This may be used to set "seasons" of study. This may be used to set "seasons" of study.
Before the reset, I will send a csv file with the previous member statistics. Before the reset, I will send a csv file with the current member statistics.
**This is not reversible.** **This is not reversible.**
""" """
if not await ctx.ask("Are you sure you want to completely reset the member statistics? " if not await ctx.ask("Are you sure you want to reset the study time and badges for all members? "
"**THIS IS NOT REVERSIBLE!**"): "**THIS IS NOT REVERSIBLE!**"):
return return
# Build the data csv # Build the data csv
@@ -48,18 +48,18 @@ async def cmd_statreset(ctx):
stats_file.write('\n'.join(csv_rows)) stats_file.write('\n'.join(csv_rows))
stats_file.seek(0) stats_file.seek(0)
out_file = discord.File(stats_file, filename="member_statistics.csv") out_file = discord.File(stats_file, filename="guild_{}_member_statistics.csv".format(ctx.guild.id))
await ctx.reply(file=out_file) await ctx.reply(file=out_file)
# Reset the statistics # Reset the statistics
tables.lions.update_where( tables.lions.update_where(
{'tracked_time': 0, 'coins': 0, 'workout_count': 0}, {'tracked_time': 0},
guildid=ctx.guild.id guildid=ctx.guild.id
) )
Lion.sync() Lion.sync()
await ctx.embed_reply( await ctx.embed_reply(
"The server member statistics have been reset!\n" "The member study times have been reset!\n"
"(It may take a while for the member studybadges to update.)" "(It may take a while for the studybadges to update.)"
) )