aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/halloween
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-05-25 10:34:52 +0100
committerGravatar GitHub <[email protected]>2020-05-25 10:34:52 +0100
commitbb30d2904b4a3273d4b10dc9548c542d65f0c379 (patch)
treee6bf89e968dd39a153227aa8ca060496d2c3cbec /bot/exts/halloween
parentMerge pull request #401 from fuzzmz/minesweeper-disabled-dm-handling (diff)
parentRemove accidental extra word from docstring (diff)
Merge pull request #413 from jodth07/encoding_bug_fix
Encoding bug fix
Diffstat (limited to 'bot/exts/halloween')
-rw-r--r--bot/exts/halloween/candy_collection.py4
-rw-r--r--bot/exts/halloween/hacktoberstats.py4
-rw-r--r--bot/exts/halloween/halloween_facts.py2
-rw-r--r--bot/exts/halloween/halloweenify.py2
-rw-r--r--bot/exts/halloween/monstersurvey.py4
-rw-r--r--bot/exts/halloween/spookyrating.py2
6 files changed, 9 insertions, 9 deletions
diff --git a/bot/exts/halloween/candy_collection.py b/bot/exts/halloween/candy_collection.py
index 90c29eb2..2c7d2f23 100644
--- a/bot/exts/halloween/candy_collection.py
+++ b/bot/exts/halloween/candy_collection.py
@@ -27,7 +27,7 @@ class CandyCollection(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
- with open(json_location) as candy:
+ with open(json_location, encoding="utf8") as candy:
self.candy_json = json.load(candy)
self.msg_reacted = self.candy_json['msg_reacted']
self.get_candyinfo = dict()
@@ -178,7 +178,7 @@ class CandyCollection(commands.Cog):
def save_to_json(self) -> None:
"""Save JSON to a local file."""
- with open(json_location, 'w') as outfile:
+ with open(json_location, 'w', encoding="utf8") as outfile:
json.dump(self.candy_json, outfile)
@in_month(Month.OCTOBER)
diff --git a/bot/exts/halloween/hacktoberstats.py b/bot/exts/halloween/hacktoberstats.py
index e01ee50c..db5e37f2 100644
--- a/bot/exts/halloween/hacktoberstats.py
+++ b/bot/exts/halloween/hacktoberstats.py
@@ -123,7 +123,7 @@ class HacktoberStats(commands.Cog):
"""
if self.link_json.exists():
logging.info(f"Loading linked GitHub accounts from '{self.link_json}'")
- with open(self.link_json, 'r') as file:
+ with open(self.link_json, 'r', encoding="utf8") as file:
linked_accounts = json.load(file)
logging.info(f"Loaded {len(linked_accounts)} linked GitHub accounts from '{self.link_json}'")
@@ -145,7 +145,7 @@ class HacktoberStats(commands.Cog):
}
"""
logging.info(f"Saving linked_accounts to '{self.link_json}'")
- with open(self.link_json, 'w') as file:
+ with open(self.link_json, 'w', encoding="utf8") as file:
json.dump(self.linked_accounts, file, default=str)
logging.info(f"linked_accounts saved to '{self.link_json}'")
diff --git a/bot/exts/halloween/halloween_facts.py b/bot/exts/halloween/halloween_facts.py
index 44a66ab2..7eb6d56f 100644
--- a/bot/exts/halloween/halloween_facts.py
+++ b/bot/exts/halloween/halloween_facts.py
@@ -29,7 +29,7 @@ class HalloweenFacts(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
- with open(Path("bot/resources/halloween/halloween_facts.json"), "r") as file:
+ with open(Path("bot/resources/halloween/halloween_facts.json"), "r", encoding="utf8") as file:
self.halloween_facts = json.load(file)
self.facts = list(enumerate(self.halloween_facts))
random.shuffle(self.facts)
diff --git a/bot/exts/halloween/halloweenify.py b/bot/exts/halloween/halloweenify.py
index a19066cf..596c6682 100644
--- a/bot/exts/halloween/halloweenify.py
+++ b/bot/exts/halloween/halloweenify.py
@@ -22,7 +22,7 @@ class Halloweenify(commands.Cog):
async def halloweenify(self, ctx: commands.Context) -> None:
"""Change your nickname into a much spookier one!"""
async with ctx.typing():
- with open(Path("bot/resources/halloween/halloweenify.json"), "r") as f:
+ with open(Path("bot/resources/halloween/halloweenify.json"), "r", encoding="utf8") as f:
data = load(f)
# Choose a random character from our list we loaded above and set apart the nickname and image url.
diff --git a/bot/exts/halloween/monstersurvey.py b/bot/exts/halloween/monstersurvey.py
index 27da79b6..7b1a1e84 100644
--- a/bot/exts/halloween/monstersurvey.py
+++ b/bot/exts/halloween/monstersurvey.py
@@ -27,13 +27,13 @@ class MonsterSurvey(Cog):
"""Initializes values for the bot to use within the voting commands."""
self.bot = bot
self.registry_location = os.path.join(os.getcwd(), 'bot', 'resources', 'halloween', 'monstersurvey.json')
- with open(self.registry_location, 'r') as jason:
+ with open(self.registry_location, 'r', encoding="utf8") as jason:
self.voter_registry = json.load(jason)
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') as jason:
+ with open(self.registry_location, 'w', encoding="utf8") as jason:
json.dump(self.voter_registry, jason, indent=2)
def cast_vote(self, id: int, monster: str) -> None:
diff --git a/bot/exts/halloween/spookyrating.py b/bot/exts/halloween/spookyrating.py
index 1a48194e..6f069f8c 100644
--- a/bot/exts/halloween/spookyrating.py
+++ b/bot/exts/halloween/spookyrating.py
@@ -11,7 +11,7 @@ from bot.constants import Colours
log = logging.getLogger(__name__)
-with Path("bot/resources/halloween/spooky_rating.json").open() as file:
+with Path("bot/resources/halloween/spooky_rating.json").open(encoding="utf8") as file:
SPOOKY_DATA = json.load(file)
SPOOKY_DATA = sorted((int(key), value) for key, value in SPOOKY_DATA.items())