aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/halloween/spookyrating.py
diff options
context:
space:
mode:
authorGravatar Objectivitix <[email protected]>2021-05-16 15:50:07 -0400
committerGravatar GitHub <[email protected]>2021-05-16 15:50:07 -0400
commit07b5f296bed099d4cde849cfeba3320e3f4aa808 (patch)
tree87b8efa0a3d11d38eb0f77c75e4a42d5033584b9 /bot/exts/halloween/spookyrating.py
parentdelete trailing whitespace after docstring (diff)
parentMerge pull request #738 from python-discord/vcokltfre/feat/bookmark-reply (diff)
Merge branch 'main' into main
Diffstat (limited to 'bot/exts/halloween/spookyrating.py')
-rw-r--r--bot/exts/halloween/spookyrating.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/bot/exts/halloween/spookyrating.py b/bot/exts/halloween/spookyrating.py
index 6f069f8c..105d2164 100644
--- a/bot/exts/halloween/spookyrating.py
+++ b/bot/exts/halloween/spookyrating.py
@@ -3,24 +3,24 @@ import json
import logging
import random
from pathlib import Path
+from typing import Dict
import discord
from discord.ext import commands
+from bot.bot import Bot
from bot.constants import Colours
log = logging.getLogger(__name__)
-with Path("bot/resources/halloween/spooky_rating.json").open(encoding="utf8") as file:
- SPOOKY_DATA = json.load(file)
- SPOOKY_DATA = sorted((int(key), value) for key, value in SPOOKY_DATA.items())
+data: Dict[str, Dict[str, str]] = json.loads(Path("bot/resources/halloween/spooky_rating.json").read_text("utf8"))
+SPOOKY_DATA = sorted((int(key), value) for key, value in data.items())
class SpookyRating(commands.Cog):
"""A cog for calculating one's spooky rating."""
- def __init__(self, bot: commands.Bot):
- self.bot = bot
+ def __init__(self):
self.local_random = random.Random()
@commands.command()
@@ -46,21 +46,21 @@ class SpookyRating(commands.Cog):
_, data = SPOOKY_DATA[index]
embed = discord.Embed(
- title=data['title'],
- description=f'{who} scored {spooky_percent}%!',
+ title=data["title"],
+ description=f"{who} scored {spooky_percent}%!",
color=Colours.orange
)
embed.add_field(
- name='A whisper from Satan',
- value=data['text']
+ name="A whisper from Satan",
+ value=data["text"]
)
embed.set_thumbnail(
- url=data['image']
+ url=data["image"]
)
await ctx.send(embed=embed)
-def setup(bot: commands.Bot) -> None:
- """Spooky Rating Cog load."""
- bot.add_cog(SpookyRating(bot))
+def setup(bot: Bot) -> None:
+ """Load the Spooky Rating Cog."""
+ bot.add_cog(SpookyRating())