diff options
| author | 2019-03-19 14:52:43 -0400 | |
|---|---|---|
| committer | 2019-03-19 14:52:43 -0400 | |
| commit | bfd9f9b4d5f9de92fbb462f1194bc5dbaf65052f (patch) | |
| tree | 5313ac761762ba2f1f4f606e82ab5bed801abf37 /bot/seasons | |
| parent | Add missed error listener decorator (diff) | |
| parent | Merge pull request #144 from MadisonMcdonald/encoding-fix (diff) | |
Merge branch 'master' into dpy-cog-changes
Diffstat (limited to 'bot/seasons')
| -rw-r--r-- | bot/seasons/evergreen/snakes/utils.py | 2 | ||||
| -rw-r--r-- | bot/seasons/valentines/pickuplines.py | 44 |
2 files changed, 45 insertions, 1 deletions
diff --git a/bot/seasons/evergreen/snakes/utils.py b/bot/seasons/evergreen/snakes/utils.py index 605c7ef3..ec280223 100644 --- a/bot/seasons/evergreen/snakes/utils.py +++ b/bot/seasons/evergreen/snakes/utils.py @@ -117,7 +117,7 @@ ANGLE_RANGE = math.pi * 2 def get_resource(file: str) -> List[dict]: - with (SNAKE_RESOURCES / f"{file}.json").open() as snakefile: + with (SNAKE_RESOURCES / f"{file}.json").open(encoding="utf-8") as snakefile: return json.load(snakefile) diff --git a/bot/seasons/valentines/pickuplines.py b/bot/seasons/valentines/pickuplines.py new file mode 100644 index 00000000..4462478f --- /dev/null +++ b/bot/seasons/valentines/pickuplines.py @@ -0,0 +1,44 @@ +import logging +import random +from json import load +from pathlib import Path + +import discord +from discord.ext import commands + +from bot.constants import Colours + +log = logging.getLogger(__name__) + +with open(Path('bot', 'resources', 'valentines', 'pickup_lines.json'), 'r', encoding="utf8") as f: + pickup_lines = load(f) + + +class PickupLine: + """ + A cog that gives random cheesy pickup lines. + """ + + def __init__(self, bot): + self.bot = bot + + @commands.command() + async def pickupline(self, ctx): + """ + Gives you a random pickup line. Note that most of them are very cheesy! + """ + random_line = random.choice(pickup_lines['lines']) + embed = discord.Embed( + title=':cheese: Your pickup line :cheese:', + description=random_line['line'], + color=Colours.pink + ) + embed.set_thumbnail( + url=random_line.get('image', pickup_lines['placeholder']) + ) + await ctx.send(embed=embed) + + +def setup(bot): + bot.add_cog(PickupLine(bot)) + log.info('Pickup line cog loaded') |