Skip to content

Commit b4eef45

Browse files
authored
Add specific blurbs depending on what the help post tagged for (#35)
* Add specific blurbs depending on what the help post tagged for * bamboozled by constants formatting
1 parent dda6b94 commit b4eef45

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

constants/constants.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
from ._meta import CONSTANTS
2424

2525

26-
__all__ = (
27-
"Roles",
28-
"Colours",
29-
"Channels",
30-
)
26+
__all__ = ("Roles", "Colours", "Channels", "ForumTags")
3127

3228

3329
class Roles(CONSTANTS):
@@ -61,3 +57,12 @@ class Colours(CONSTANTS):
6157
PYTHONISTA_BG: int = 0x18344D
6258
PYTHON_YELLOW: int = 0xFFDE57
6359
PYTHON_BLUE: int = 0x4584B6
60+
61+
62+
class ForumTags(CONSTANTS):
63+
PYTHON = 1006716837041557574
64+
TWITCHIO = 1006716863469867060
65+
WAVELINK = 1006716892020473917
66+
DISCORDPY = 1006716972802789457
67+
OTHER = 1006717008613740596
68+
RESOLVED = 1006769269201195059

modules/help.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,36 @@
2828
from discord.ext import commands
2929

3030
import core
31-
from constants import Channels
31+
from constants import Channels, ForumTags
3232
from core.context import Context
3333

3434

3535
if TYPE_CHECKING:
3636
from discord.ext.commands._types import Check # type: ignore # why does this need a stub?
3737

3838

39-
FORUM_BLURB = f"""
39+
_FORUM_BLURB = f"""
4040
Welcome to the help forum!
4141
Please provide as much information as possible about your problem, and then wait for someone to help you.
4242
43-
A good question should include:
43+
Please include:
4444
- your problem
4545
- your code
4646
- your traceback (if applicable)
4747
- what you've tried so far
48+
{{remarks}}
4849
4950
Once your issue has been solved type `{core.CONFIG['prefix']}solved` to close the thread.
5051
""".strip()
5152

53+
# fmt: off
54+
FORUM_BLURB_GENERIC = _FORUM_BLURB.format(remarks="")
55+
FORUM_BLURB_PYTHON = _FORUM_BLURB.format(remarks="- your Python version")
56+
FORUM_BLURB_TWITCHIO = _FORUM_BLURB.format(remarks="- your TwitchIO version")
57+
FORUM_BLURB_WAVELINK = _FORUM_BLURB.format(remarks="- your Wavelink version\n- your Discord.py version")
58+
FORUM_BLURB_DPY = _FORUM_BLURB.format(remarks="- your Discord.py version")
59+
# fmt: on
60+
5261

5362
class NotThreadOwner(commands.CheckFailure):
5463
pass
@@ -103,7 +112,26 @@ async def forum_post_created(self, thread: discord.Thread) -> None:
103112

104113
await channel.send(f"{thread.owner} ({thread.owner_id}) created thread '{thread.name}' ({thread.id}).")
105114

106-
await thread.send(FORUM_BLURB)
115+
tags = {s.id for s in thread.applied_tags}
116+
# we'll check for individual libs before the generic python tag
117+
# wavelink and twitchio are first, before genericizing down to dpy and finally python
118+
119+
if ForumTags.TWITCHIO in tags:
120+
blurb = FORUM_BLURB_TWITCHIO
121+
122+
elif ForumTags.WAVELINK in tags:
123+
blurb = FORUM_BLURB_WAVELINK
124+
125+
elif ForumTags.DISCORDPY in tags:
126+
blurb = FORUM_BLURB_DPY
127+
128+
elif ForumTags.PYTHON in tags:
129+
blurb = FORUM_BLURB_PYTHON
130+
131+
else:
132+
blurb = FORUM_BLURB_GENERIC
133+
134+
await thread.send(blurb)
107135

108136
@can_close_thread()
109137
@is_forum_thread()
@@ -124,12 +152,12 @@ async def solved(self, ctx: core.GuildContext) -> None:
124152
except discord.HTTPException:
125153
pass
126154

127-
tag = ctx.channel.parent.get_tag(1006769269201195059)
155+
tag = ctx.channel.parent.get_tag(ForumTags.RESOLVED)
128156
if not tag:
129157
return
130158

131159
tags = ctx.channel.applied_tags
132-
if not any(tag_.id == 1006769269201195059 for tag_ in tags):
160+
if not any(tag_.id == ForumTags.RESOLVED for tag_ in tags):
133161
tags.append(tag)
134162

135163
await ctx.channel.edit(

0 commit comments

Comments
 (0)