Add reset command / module

This commit is contained in:
c0de 2022-12-09 23:20:20 -06:00
parent ff5e7f310a
commit 9702e1e77a
3 changed files with 25 additions and 1 deletions

View File

@ -27,6 +27,7 @@ class HelpManager(BaseGameManager):
+ " You can also add a batter's guess with: " + " You can also add a batter's guess with: "
+ "!resolve <value> <discord id #> <guess>\n" + "!resolve <value> <discord id #> <guess>\n"
+ "!points - Shows a table of the most recent players, and their scores\n" + "!points - Shows a table of the most recent players, and their scores\n"
+ "!reset - Removes all the guesses"
+ "!help - Shows this message" + "!help - Shows this message"
) )

View File

@ -14,11 +14,12 @@ from game.new_game import NewGameManager
from game.end_game import EndGameManager from game.end_game import EndGameManager
from game.guess import GuessManager from game.guess import GuessManager
from game.points import PointsManager from game.points import PointsManager
from game.reset import ResetManager
from game.help import HelpManager from game.help import HelpManager
class GameManager( class GameManager(
NewGameManager, EndGameManager, GuessManager, PointsManager, HelpManager NewGameManager, EndGameManager, GuessManager, PointsManager, ResetManager, HelpManager
): ):
""" """
Represents what this bot is able to do on a channel (or DMs) Represents what this bot is able to do on a channel (or DMs)

22
game/reset.py Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python3
# Copyright 2022 - c0de <c0de@c0de.dev>
# Licensed under the MIT License (https://opensource.org/licenses/MIT)
# pylint: disable=missing-module-docstring,too-few-public-methods
from database.models import GuessModel as Guess
from game.base import BaseGameManager
class ResetManager(BaseGameManager):
"""Commands that run when a player asks for help"""
def __init__(self):
super().__init__()
self.commands.append(("reset", self.reset))
async def reset(self):
"""Reset command purges all guesses"""
Guess.delete().where(True).execute()
return await self.message.channel.send("ok")