Make FAQ check which channel it's called in to return the appropriate FAQ

pull/21/head
Stijn De Clercq 2020-12-25 18:40:26 +01:00
parent cb4e67be69
commit 81ef990e1f
2 changed files with 17 additions and 0 deletions

View File

@ -1,3 +1,4 @@
from data import constants
from decorators import help from decorators import help
import discord import discord
from discord.ext import commands from discord.ext import commands
@ -20,6 +21,9 @@ class Faq(commands.Cog):
""" """
Command group that controls the FAQ commands. Command group that controls the FAQ commands.
When this command is invoked, it sends a list of valid categories. When this command is invoked, it sends a list of valid categories.
After invoking in a subject's channel (without passing a category),
it sends the FAQ for that subject instead.
:param ctx: Discord Context :param ctx: Discord Context
:param args: args passed :param args: args passed
""" """
@ -28,6 +32,10 @@ class Faq(commands.Cog):
if len(args) != 0 and any("@" not in arg for arg in args): if len(args) != 0 and any("@" not in arg for arg in args):
return await self.faqCategory(ctx, args) return await self.faqCategory(ctx, args)
# Check if the command was used in a subject's channel
if ctx.channel.id in constants.faq_channels:
return await self.faqCategory(ctx, (constants.faq_channels[ctx.channel.id],))
# List of all categories with the first letter capitalized # List of all categories with the first letter capitalized
resp = [stringFormatters.titleCase(cat[0]) for cat in faq.getCategories()] resp = [stringFormatters.titleCase(cat[0]) for cat in faq.getCategories()]

View File

@ -46,6 +46,15 @@ holidayAPIKey = "af4e1ebe-465d-4b93-a828-b95df18e6424"
prefixes = ["big d", "didier"] prefixes = ["big d", "didier"]
faq_channels = {
727876753523081216: "ad2",
727876779481497600: "comnet",
727876797458284584: "funcprog",
727876819264733244: "statprob",
727876836587208714: "sysprog",
676713433567199232: "didier"
}
class Live(Enum): class Live(Enum):
CallOfCode = "626699611192688641" CallOfCode = "626699611192688641"