Skip to content

Commit

Permalink
fix(command): Tag limit when using solve
Browse files Browse the repository at this point in the history
  • Loading branch information
Alc-Alc committed Feb 21, 2024
1 parent c06f928 commit f20c497
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/byte/plugins/forums.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ async def solved(self, ctx: Context) -> None:
Help, Suggestions, Showcase, etc. (or any other forum channel)
"""
_solved_tag = "Solved"
_tags_per_post = 5
if isinstance(ctx.channel, Thread) and ctx.channel.parent.name == "help":
if solved_tag := discord.utils.find(lambda t: t.name == _solved_tag, ctx.channel.parent.available_tags):
if len(ctx.channel.applied_tags) == _tags_per_post and solved_tag not in ctx.channel.applied_tags:
# Tags per post are limited to 5
# Remove a tag to make room for "Solved"
await ctx.channel.remove_tags(ctx.channel.applied_tags[-1])
await ctx.channel.add_tags(solved_tag, reason="Marked as solved.")
await ctx.send("Marked as solved and closed the help forum!", ephemeral=True)
await ctx.channel.edit(archived=True)
Expand Down

0 comments on commit f20c497

Please sign in to comment.