3636
3737AUTHOR_PLACEHOLDER = "[[@author]]"
3838
39+
3940def get_tag_options (db : DevHelpTagDB , forum : ForumChannel ) -> View | None :
4041 """Gets all tag options for the given forum."""
4142
4243 async def select_callback (interaction : Interaction ):
4344 await db .update ("tag_id" , int (tag_selection .values [0 ]))
44- await interaction .response .edit_message (
45- content = f"Success..." ,
46- view = None
47- )
45+ await interaction .response .edit_message (content = f"Success..." , view = None )
4846 view .stop ()
4947
5048 view = View ()
@@ -56,12 +54,14 @@ async def select_callback(interaction: Interaction):
5654
5755 for a_tag in forum .available_tags :
5856 tag_selection .add_option (
59- label = f"{ a_tag .emoji } { a_tag .name } " if a_tag .emoji else a_tag .name , value = a_tag .id
57+ label = f"{ a_tag .emoji } { a_tag .name } " if a_tag .emoji else a_tag .name ,
58+ value = a_tag .id ,
6059 )
6160
6261 view .add_item (tag_selection )
6362 return view
6463
64+
6565def _getter (guild : Guild , entry : dict ) -> Member | Role :
6666 """Gets the object type and returns it."""
6767
@@ -111,7 +111,7 @@ async def load(self):
111111 staff_roles ,
112112 self .logger ,
113113 ),
114- message_id = view ["message_id" ]
114+ message_id = view ["message_id" ],
115115 )
116116
117117 async def cog_load (self ):
@@ -149,28 +149,31 @@ async def try_send() -> Message:
149149 thread .owner_id ,
150150 self .dev_help_views_db ,
151151 self .dev_help_tag_db ,
152- self . forum ,
152+ thread . parent ,
153153 staff_roles ,
154154 self .logger ,
155- )
155+ ),
156156 )
157157 except Forbidden :
158158 pass
159159
160- config = await self .config .get_config ("dev_help" )
160+ config_id , is_enabled = await self .db .is_mark_as_solved_enabled_for_forum (
161+ thread .parent_id
162+ )
161163
162- if not config [ "config_status" ] :
164+ if not is_enabled :
163165 return
164166
165- settings = await self .dev_help_tag_db .get ()
166-
167- if not settings :
167+ global_config = await self .config .get_config ("auto_tagging" )
168+ if not global_config ["config_status" ]:
168169 return
169170
170- if not self .forum :
171+ entry = await self .db .config_by_forum (thread .parent .id )
172+ if not entry :
171173 return
172174
173- if thread .parent_id != self .forum .id :
175+ settings = await self .dev_help_tag_db .get ()
176+ if not settings :
174177 return
175178
176179 bot_message = await try_send ()
@@ -179,7 +182,9 @@ async def try_send() -> Message:
179182 return
180183
181184 await bot_message .pin ()
182- await self .dev_help_views_db .add_view (thread .id , bot_message .id , thread .owner .id )
185+ await self .dev_help_views_db .add_view (
186+ thread .id , bot_message .id , thread .owner .id
187+ )
183188
184189 async def _notify_subscribers (self , thread : Thread ):
185190 config = await self .config .get_config ("auto_tagging" )
@@ -279,15 +284,19 @@ async def create_new(self, interaction: Interaction):
279284 entity_tag_message = tag_message ,
280285 reply = reply ,
281286 enable_accept_solutions = enable_accept_solutions ,
287+ enable_mark_as_solved = view .state .enable_mark_as_solved ,
282288 )
283289
284290 if view .state .enable_mark_as_solved :
285- forum = await self .bot .fetch_channel (view .state .forum )
286- tag_view = get_tag_options (self .dev_help_tag_db , forum )
287- await interaction .followup .send (view = tag_view , ephemeral = True )
288- await tag_view .wait ()
289-
290- await interaction .followup .send ("Mark as solved button configured." , ephemeral = True )
291+ forum_channel = await self .bot .fetch_channel (view .state .forum )
292+ tag_view = get_tag_options (self .dev_help_tag_db , forum_channel )
293+ if tag_view :
294+ await interaction .followup .send (view = tag_view , ephemeral = True )
295+ await tag_view .wait ()
296+
297+ await interaction .followup .send (
298+ "Mark as solved button configured." , ephemeral = True
299+ )
291300
292301 await interaction .followup .send ("Success!" , ephemeral = True )
293302 return
@@ -364,6 +373,13 @@ async def edit(self, interaction: Interaction, config_id: int):
364373 tags = await self .db .get_tags (config_id )
365374 existing_tags : list [Role ] | list [Member ] = []
366375
376+ mark_as_solved_config = await self .db .get_mark_as_solved_config (config_id )
377+ current_mark_as_solved = (
378+ mark_as_solved_config ["enable_mark_as_solved" ]
379+ if mark_as_solved_config
380+ else False
381+ )
382+
367383 for tag in tags :
368384 tag_id = tag ["entity_id" ]
369385 if tag ["entity_type" ] == "role" :
@@ -376,6 +392,7 @@ async def edit(self, interaction: Interaction, config_id: int):
376392 tag_message = tag_message ,
377393 custom_msg = custom_message ,
378394 existing_tags = existing_tags ,
395+ enable_mark_as_solved = current_mark_as_solved ,
379396 )
380397
381398 modal = PostAssistMessage (state )
@@ -400,7 +417,18 @@ async def edit(self, interaction: Interaction, config_id: int):
400417 entities = tags ,
401418 entity_tag_message = tag_message ,
402419 reply = reply ,
420+ enable_mark_as_solved = modal .state .enable_mark_as_solved ,
403421 )
422+
423+ if modal .state .enable_mark_as_solved :
424+ await interaction .followup .send (
425+ "Mark as solved button enabled for this forum." , ephemeral = True
426+ )
427+ else :
428+ await interaction .followup .send (
429+ "Mark as solved button disabled for this forum." , ephemeral = True
430+ )
431+
404432 return
405433
406434 await interaction .followup .send ("Cancelled." , ephemeral = True )
@@ -416,9 +444,7 @@ async def solved(self, ctx: Context):
416444
417445 description = "This post has been marked as solved."
418446
419- embed = Embed (
420- description = description
421- )
447+ embed = Embed (description = description )
422448
423449 tag = ctx .channel .parent .get_tag (tag_id )
424450
0 commit comments