aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/halloween/monsterbio.py
diff options
context:
space:
mode:
authorGravatar Janine vN <[email protected]>2021-09-04 23:31:14 -0400
committerGravatar Janine vN <[email protected]>2021-09-04 23:31:14 -0400
commit3377e46dc890626a29b05e134799b6219598107b (patch)
treebdb4a2c6efbe113ec0e355a9eff5070cc8ec52aa /bot/exts/halloween/monsterbio.py
parentMove Easter to Holidays Folder (diff)
Move Halloween to Holidays folder
Moves all the hallowen features to the holidays folder. Also updates the paths to reflect the folder moves.
Diffstat (limited to 'bot/exts/halloween/monsterbio.py')
-rw-r--r--bot/exts/halloween/monsterbio.py54
1 files changed, 0 insertions, 54 deletions
diff --git a/bot/exts/halloween/monsterbio.py b/bot/exts/halloween/monsterbio.py
deleted file mode 100644
index 69e898cb..00000000
--- a/bot/exts/halloween/monsterbio.py
+++ /dev/null
@@ -1,54 +0,0 @@
-import json
-import logging
-import random
-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__)
-
-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 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"]))
- return "".join(seeded_random.choice(TEXT_OPTIONS["monster_type"][i]) for i in range(n_candidate_strings))
-
- @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.author.id) # Seed a local Random instance rather than the system one
-
- name = self.generate_name(seeded_random)
- species = self.generate_name(seeded_random)
- biography_text = seeded_random.choice(TEXT_OPTIONS["biography_text"])
- words = {"monster_name": name, "monster_species": species}
- for key, value in biography_text.items():
- if key == "text":
- continue
-
- options = seeded_random.sample(TEXT_OPTIONS[key], value)
- words[key] = " ".join(options)
-
- embed = discord.Embed(
- title=f"{name}'s Biography",
- color=seeded_random.choice([Colours.orange, Colours.purple]),
- description=biography_text["text"].format_map(words),
- )
-
- await ctx.send(embed=embed)
-
-
-def setup(bot: Bot) -> None:
- """Load the Monster Bio Cog."""
- bot.add_cog(MonsterBio())