diff options
| author | 2020-11-21 10:53:03 -0800 | |
|---|---|---|
| committer | 2020-11-21 10:53:03 -0800 | |
| commit | 23cf970b63fc4654d031b91e2f99247162e790fc (patch) | |
| tree | 4575c60a0fa49ec576346f49bf8755aafe0737a6 /bot/exts/evergreen | |
| parent | feature/add wonder twins command (diff) | |
move constants to init, change [-1] to .endswith()
Diffstat (limited to 'bot/exts/evergreen')
| -rw-r--r-- | bot/exts/evergreen/wonder_twins.py | 18 | 
1 files changed, 9 insertions, 9 deletions
| diff --git a/bot/exts/evergreen/wonder_twins.py b/bot/exts/evergreen/wonder_twins.py index 475ddcb7..fdaf4556 100644 --- a/bot/exts/evergreen/wonder_twins.py +++ b/bot/exts/evergreen/wonder_twins.py @@ -4,10 +4,6 @@ from pathlib import Path  import yaml  from discord.ext.commands import Bot, Cog, Context, command -with open(Path.cwd() / "bot" / "resources" / "evergreen" / "wonder_twins.yaml", "r", encoding="utf-8") as f: -    info = yaml.load(f, Loader=yaml.FullLoader) -    WATER_TYPES, OBJECTS, ADJECTIVES = info["water_types"], info["objects"], info["adjectives"] -  class WonderTwins(Cog):      """Cog for a Wonder Twins inspired command.""" @@ -15,10 +11,14 @@ class WonderTwins(Cog):      def __init__(self, bot: Bot):          self.bot = bot +        with open(Path.cwd() / "bot" / "resources" / "evergreen" / "wonder_twins.yaml", "r", encoding="utf-8") as f: +            info = yaml.load(f, Loader=yaml.FullLoader) +            self.water_types, self.objects, self.adjectives = info["water_types"], info["objects"], info["adjectives"] +      @staticmethod      def append_onto(phrase: str, insert_word: str) -> str:          """Appends one word onto the end of another phrase, used to format the use of 'an' or 'a'.""" -        if insert_word[-1] == "s": +        if insert_word.endswith("s"):              phrase = phrase.split()              del phrase[0]              phrase = " ".join(phrase) @@ -28,9 +28,9 @@ class WonderTwins(Cog):      def format_phrase(self) -> str:          """Creates a transformation phrase from available words.""" -        adjective = random.choice((None, random.choice(ADJECTIVES))) -        object_name = random.choice(OBJECTS) -        water_type = random.choice(WATER_TYPES) +        adjective = random.choice((None, random.choice(self.adjectives))) +        object_name = random.choice(self.objects) +        water_type = random.choice(self.water_types)          words = [object_name, water_type]          if adjective: @@ -41,7 +41,7 @@ class WonderTwins(Cog):      @command(name="formof", aliases=["wondertwins", "wondertwin", "fo"])      async def form_of(self, ctx: Context) -> None:          """Command to send a Wonder Twins inspired phrase to the user invoking the command.""" -        await ctx.send(f"Form of {self.format_phrase()}") +        await ctx.send(f"Form of {self.format_phrase()}!")  def setup(bot: Bot) -> None: | 
