diff options
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/exts/halloween/halloween_facts.py | 1 | ||||
| -rw-r--r-- | bot/exts/halloween/monstersurvey.py | 16 | ||||
| -rw-r--r-- | bot/exts/pride/drag_queen_name.py | 4 | 
3 files changed, 10 insertions, 11 deletions
| diff --git a/bot/exts/halloween/halloween_facts.py b/bot/exts/halloween/halloween_facts.py index 139e0810..3a89b5aa 100644 --- a/bot/exts/halloween/halloween_facts.py +++ b/bot/exts/halloween/halloween_facts.py @@ -33,7 +33,6 @@ class HalloweenFacts(commands.Cog):          with Path("bot/resources/halloween/halloween_facts.json").open("r", encoding="utf8") as file:              self.halloween_facts = json.load(file)          self.facts = list(enumerate(self.halloween_facts)) -        random.shuffle(self.facts)      def random_fact(self) -> Tuple[int, str]:          """Return a random fact from the loaded facts.""" diff --git a/bot/exts/halloween/monstersurvey.py b/bot/exts/halloween/monstersurvey.py index 42a316e6..231454ea 100644 --- a/bot/exts/halloween/monstersurvey.py +++ b/bot/exts/halloween/monstersurvey.py @@ -1,6 +1,6 @@  import json  import logging -import os +import pathlib  from discord import Embed  from discord.ext import commands @@ -25,24 +25,24 @@ class MonsterSurvey(Cog):      def __init__(self):          """Initializes values for the bot to use within the voting commands.""" -        self.registry_location = os.path.join(os.getcwd(), "bot", "resources", "halloween", "monstersurvey.json") -        with open(self.registry_location, "r", encoding="utf8") as jason: -            self.voter_registry = json.load(jason) +        self.registry_path = pathlib.Path("bot", "resources", "halloween", "monstersurvey.json") +        with self.registry_path.open(encoding="utf8") as data: +            self.voter_registry = json.load(data)      def json_write(self) -> None:          """Write voting results to a local JSON file."""          log.info("Saved Monster Survey Results") -        with open(self.registry_location, "w", encoding="utf8") as jason: -            json.dump(self.voter_registry, jason, indent=2) +        with self.registry_path.open("w", encoding="utf8") as data: +            json.dump(self.voter_registry, data, indent=2)      def cast_vote(self, id: int, monster: str) -> None:          """ -        Cast a user"s vote for the specified monster. +        Cast a user's vote for the specified monster.          If the user has already voted, their existing vote is removed.          """          vr = self.voter_registry -        for m in vr.keys(): +        for m in vr:              if id not in vr[m]["votes"] and m == monster:                  vr[m]["votes"].append(id)              else: diff --git a/bot/exts/pride/drag_queen_name.py b/bot/exts/pride/drag_queen_name.py index 9839f089..d9424001 100644 --- a/bot/exts/pride/drag_queen_name.py +++ b/bot/exts/pride/drag_queen_name.py @@ -19,7 +19,7 @@ class DragNames(commands.Cog):      @staticmethod      def load_names() -> list:          """Loads a list of drag queen names.""" -        with open(Path("bot/resources/pride/drag_queen_names.json"), "r", encoding="utf8") as f: +        with Path("bot/resources/pride/drag_queen_names.json").open(encoding="utf8") as f:              return json.load(f)      @commands.command(name="dragname", aliases=["dragqueenname", "queenme"]) @@ -29,5 +29,5 @@ class DragNames(commands.Cog):  def setup(bot: Bot) -> None: -    """Load the Drag Queen Cog.""" +    """Load the Drag Names Cog."""      bot.add_cog(DragNames()) | 
