Skip to content

Add close command for threads/posts #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions intbot/core/bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,40 @@ async def wiki(ctx):
suppress_embeds=True,
)

@bot.command()
async def close(ctx):
channel = ctx.channel
parent = channel.parent
author = ctx.message.author

# Check if it's a public or private post (thread)
if channel.type in (discord.ChannelType.public_thread, discord.ChannelType.private_thread):

# Check if the post (thread) was sent in a forum,
# so we can add a tag
if parent.type == discord.ChannelType.forum:

# Get tag from forum
tag = None
for _tag in parent.available_tags:
if _tag.name.lower() == "done":
tag = _tag
break

if tag is not None:
await channel.add_tags(tag)

# Remove command message
await ctx.message.delete()

# We need to archive after adding tags in case it was a forum.
# Otherwise we only archive the thread
await channel.edit(archived=True)

# Send notification to the thread
await channel.send(f"# This was marked as done by {author.mention}")



@bot.command()
async def version(ctx):
Expand Down