diff options
Diffstat (limited to 'bot/exts/halloween/monsterbio.py')
-rw-r--r-- | bot/exts/halloween/monsterbio.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/bot/exts/halloween/monsterbio.py b/bot/exts/halloween/monsterbio.py index 016a66d1..69e898cb 100644 --- a/bot/exts/halloween/monsterbio.py +++ b/bot/exts/halloween/monsterbio.py @@ -6,20 +6,19 @@ from pathlib import Path import discord from discord.ext import commands +from bot.bot import Bot from bot.constants import Colours log = logging.getLogger(__name__) -with open(Path("bot/resources/halloween/monster.json"), "r", encoding="utf8") as f: - TEXT_OPTIONS = json.load(f) # Data for a mad-lib style generation of text +TEXT_OPTIONS = json.loads( + Path("bot/resources/halloween/monster.json").read_text("utf8") +) # Data for a mad-lib style generation of text class MonsterBio(commands.Cog): """A cog that generates a spooky monster biography.""" - def __init__(self, bot: commands.Bot): - self.bot = bot - def generate_name(self, seeded_random: random.Random) -> str: """Generates a name (for either monster species or monster name).""" n_candidate_strings = seeded_random.randint(2, len(TEXT_OPTIONS["monster_type"])) @@ -28,7 +27,7 @@ class MonsterBio(commands.Cog): @commands.command(brief="Sends your monster bio!") async def monsterbio(self, ctx: commands.Context) -> None: """Sends a description of a monster.""" - seeded_random = random.Random(ctx.message.author.id) # Seed a local Random instance rather than the system one + seeded_random = random.Random(ctx.author.id) # Seed a local Random instance rather than the system one name = self.generate_name(seeded_random) species = self.generate_name(seeded_random) @@ -39,7 +38,7 @@ class MonsterBio(commands.Cog): continue options = seeded_random.sample(TEXT_OPTIONS[key], value) - words[key] = ' '.join(options) + words[key] = " ".join(options) embed = discord.Embed( title=f"{name}'s Biography", @@ -50,6 +49,6 @@ class MonsterBio(commands.Cog): await ctx.send(embed=embed) -def setup(bot: commands.Bot) -> None: - """Monster bio Cog load.""" - bot.add_cog(MonsterBio(bot)) +def setup(bot: Bot) -> None: + """Load the Monster Bio Cog.""" + bot.add_cog(MonsterBio()) |