28
28
from discord .ext import commands
29
29
30
30
import core
31
- from constants import Channels
31
+ from constants import Channels , ForumTags
32
32
from core .context import Context
33
33
34
34
35
35
if TYPE_CHECKING :
36
36
from discord .ext .commands ._types import Check # type: ignore # why does this need a stub?
37
37
38
38
39
- FORUM_BLURB = f"""
39
+ _FORUM_BLURB = f"""
40
40
Welcome to the help forum!
41
41
Please provide as much information as possible about your problem, and then wait for someone to help you.
42
42
43
- A good question should include:
43
+ Please include:
44
44
- your problem
45
45
- your code
46
46
- your traceback (if applicable)
47
47
- what you've tried so far
48
+ {{remarks}}
48
49
49
50
Once your issue has been solved type `{ core .CONFIG ['prefix' ]} solved` to close the thread.
50
51
""" .strip ()
51
52
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
+
52
61
53
62
class NotThreadOwner (commands .CheckFailure ):
54
63
pass
@@ -103,7 +112,26 @@ async def forum_post_created(self, thread: discord.Thread) -> None:
103
112
104
113
await channel .send (f"{ thread .owner } ({ thread .owner_id } ) created thread '{ thread .name } ' ({ thread .id } )." )
105
114
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 )
107
135
108
136
@can_close_thread ()
109
137
@is_forum_thread ()
@@ -124,12 +152,12 @@ async def solved(self, ctx: core.GuildContext) -> None:
124
152
except discord .HTTPException :
125
153
pass
126
154
127
- tag = ctx .channel .parent .get_tag (1006769269201195059 )
155
+ tag = ctx .channel .parent .get_tag (ForumTags . RESOLVED )
128
156
if not tag :
129
157
return
130
158
131
159
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 ):
133
161
tags .append (tag )
134
162
135
163
await ctx .channel .edit (
0 commit comments