From 81bba03affac1c9fcdbb47768c61d575f0697ce0 Mon Sep 17 00:00:00 2001 From: Bobloy Date: Fri, 4 May 2018 15:23:27 -0400 Subject: [PATCH] closer than ever --- hangman/__init__.py | 2 ++ hangman/hangman.py | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hangman/__init__.py b/hangman/__init__.py index 8b6ec76..2168fdf 100644 --- a/hangman/__init__.py +++ b/hangman/__init__.py @@ -1,7 +1,9 @@ from .hangman import Hangman +from redbot.core import data_manager def setup(bot): n = Hangman(bot) + data_manager.load_bundled_data(n, __file__) bot.add_cog(n) bot.add_listener(n._on_react, "on_reaction_add") diff --git a/hangman/hangman.py b/hangman/hangman.py index d502296..faa90bf 100644 --- a/hangman/hangman.py +++ b/hangman/hangman.py @@ -4,6 +4,7 @@ from random import randint import discord from discord.ext import commands from redbot.core import Config, checks +from redbot.core.data_manager import cog_data_path, load_basic_configuration class Hangman: @@ -13,6 +14,7 @@ class Hangman: def __init__(self, bot): self.bot = bot + load_basic_configuration("hangman") self.config = Config.get_conf(self, identifier=1049711010310997110) default_guild = { "theface": ':thinking:', @@ -22,7 +24,7 @@ class Hangman: self.the_data = defaultdict( lambda: {"running": False, "hangman": 0, "guesses": [], "trackmessage": False, "answer": ''}) - self.answer_path = "./data/hanganswers.txt" + self.answer_path = "/hanganswers.txt" self.winbool = defaultdict(lambda: False) self.hanglist = {} @@ -191,8 +193,9 @@ class Hangman: def _getphrase(self): """Get a new phrase for the game and returns it""" - phrasefile = open(self.answer_path, 'r') - phrases = phrasefile.readlines() + + with cog_data_path("hangman").open('r') as phrasefile: + phrases = phrasefile.readlines() outphrase = "" while outphrase == "":