diff options
| author | 2020-08-09 14:06:35 -0700 | |
|---|---|---|
| committer | 2020-08-09 14:06:35 -0700 | |
| commit | 6f51cf18febdfdf8d8949e3a3a91d707ed2d9dc2 (patch) | |
| tree | c7d17861fd1b80448e15e6a02134f9502f5bf64f /bot/exts | |
| parent | Merge pull request #424 from python-discord/statuscats (diff) | |
Edited "topic" command for fetching python channel topics.
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/easter/conversationstarters.py | 25 | 
1 files changed, 24 insertions, 1 deletions
| diff --git a/bot/exts/easter/conversationstarters.py b/bot/exts/easter/conversationstarters.py index a5f40445..0c773119 100644 --- a/bot/exts/easter/conversationstarters.py +++ b/bot/exts/easter/conversationstarters.py @@ -2,6 +2,7 @@ import json  import logging  import random  from pathlib import Path +from discord import Embed  from discord.ext import commands @@ -10,6 +11,10 @@ log = logging.getLogger(__name__)  with open(Path("bot/resources/easter/starter.json"), "r", encoding="utf8") as f:      starters = json.load(f) +with open(Path("bot/resources/easter/py_topics.json"), "r", encoding="utf8") as f: +    # First ID is #python-general and the rest are top to bottom categories of Topical Chat/Help. +    py_topics = json.load(f) +  class ConvoStarters(commands.Cog):      """Easter conversation topics.""" @@ -19,7 +24,25 @@ class ConvoStarters(commands.Cog):      @commands.command()      async def topic(self, ctx: commands.Context) -> None: -        """Responds with a random topic to start a conversation.""" +        """Responds with a random topic to start a conversation, changing depending on channel."""    + +        # Fetching topics. +        channel_topics = py_topic[str(ctx.channel.id)] +         +        if channel_topics: +            return await ctx.send(random.choice(channel_topics['python-channels'])) + +        else: +            # If the channel ID doesn't have any topics. +            embed = Embed( +                description=( +                    "No topics found. You can suggest new ideas for topics " +                    "[here](https://github.com/python-discord/seasonalbot/issues/426)!" +                )) +             +            return await ctx.send(embed=embed) + +        # If the channel isn't Python.          await ctx.send(random.choice(starters['starters'])) | 
