diff options
| author | 2019-05-11 04:51:30 +1000 | |
|---|---|---|
| committer | 2019-05-11 04:51:30 +1000 | |
| commit | 0e2c6a1b0daef5b569da7652801b5725bf1ed95b (patch) | |
| tree | c3d57e50f2ba07cb2d9e7476d3b9441c1f671bd9 /bot/seasons/halloween/monstersurvey.py | |
| parent | not importing aiohttp now (diff) | |
| parent | Merge pull request #198 from Suhail6inkling/constants_fix (diff) | |
Merge branch 'master' into hanukkah_embed_iceman
Diffstat (limited to 'bot/seasons/halloween/monstersurvey.py')
| -rw-r--r-- | bot/seasons/halloween/monstersurvey.py | 26 | 
1 files changed, 19 insertions, 7 deletions
diff --git a/bot/seasons/halloween/monstersurvey.py b/bot/seasons/halloween/monstersurvey.py index 2b251b90..2ae98f6e 100644 --- a/bot/seasons/halloween/monstersurvey.py +++ b/bot/seasons/halloween/monstersurvey.py @@ -16,8 +16,10 @@ EMOJIS = {  class MonsterSurvey(Cog):      """ -    Vote for your favorite monster! -    This command allows users to vote for their favorite listed monster. +    Vote for your favorite monster. + +    This Cog allows users to vote for their favorite listed monster. +      Users may change their vote, but only their current vote will be counted.      """ @@ -30,12 +32,18 @@ class MonsterSurvey(Cog):              self.voter_registry = json.load(jason)      def json_write(self): +        """Write voting results to a local JSON file.""" +          log.info("Saved Monster Survey Results")          with open(self.registry_location, 'w') as jason:              json.dump(self.voter_registry, jason, indent=2)      def cast_vote(self, id: int, monster: str):          """ +        Cast a user's vote for the specified monster. + +        If the user has already voted, their existing vote is removed. +          :param id: The id of the person voting          :param monster: the string key of the json that represents a monster          :return: None @@ -50,6 +58,8 @@ class MonsterSurvey(Cog):                      vr[m]['votes'].remove(id)      def get_name_by_leaderboard_index(self, n): +        """Return the monster at the specified leaderboard index.""" +          n = n - 1          vr = self.voter_registry          top = sorted(vr, key=lambda k: len(vr[k]['votes']), reverse=True) @@ -61,9 +71,7 @@ class MonsterSurvey(Cog):          aliases=('ms',)      )      async def monster_group(self, ctx: Context): -        """ -        The base voting command. If nothing is called, then it will return an embed. -        """ +        """The base voting command. If nothing is called, then it will return an embed."""          if ctx.invoked_subcommand is None:              async with ctx.typing(): @@ -95,8 +103,9 @@ class MonsterSurvey(Cog):      )      async def monster_vote(self, ctx: Context, name=None):          """ -        Casts a vote for a particular monster, or displays a list of monsters that can be voted for -        if one is not given. +        Cast a vote for a particular monster. + +        Displays a list of monsters that can be voted for if one is not specified.          """          if name is None: @@ -185,6 +194,7 @@ class MonsterSurvey(Cog):      async def monster_leaderboard(self, ctx: Context):          """          Shows the current standings. +          :param ctx:          :return:          """ @@ -214,5 +224,7 @@ class MonsterSurvey(Cog):  def setup(bot): +    """Monster survey Cog load.""" +      bot.add_cog(MonsterSurvey(bot))      log.info("MonsterSurvey cog loaded")  |