My Bot isn't Deleting Archived Threads

When a Thread is closed or archived, it cannot delete the thread. It only deletes unclosed or active threads but I'd like it to delete threads regardless of if they are open, archived or closed within an hour. Any Idea whats wrong here? using Python and latest version of JS
@tasks.loop(seconds=7.5)
async def check_and_delete_threads():
try:
# Replace CHANNEL_ID with the actual ID of the channel you want to check for threads in
channel_id =
channel = bot.get_channel(channel_id)

# Replace EXCLUDED_THREAD_ID with the ID of the thread you want to exclude from deletion
excluded_thread_id =

if channel:
for thread in channel.threads:
if thread.id == excluded_thread_id:
continue

# Check if the thread is older than 2 hours
if time.time() - thread.created_at.timestamp() >= 7200 or thread.archived:
await thread.delete()
print(f"Thread {thread.name} deleted.")
# Remove thread info from the dictionary
thread_info.pop(str(thread.id), None)
@tasks.loop(seconds=7.5)
async def check_and_delete_threads():
try:
# Replace CHANNEL_ID with the actual ID of the channel you want to check for threads in
channel_id =
channel = bot.get_channel(channel_id)

# Replace EXCLUDED_THREAD_ID with the ID of the thread you want to exclude from deletion
excluded_thread_id =

if channel:
for thread in channel.threads:
if thread.id == excluded_thread_id:
continue

# Check if the thread is older than 2 hours
if time.time() - thread.created_at.timestamp() >= 7200 or thread.archived:
await thread.delete()
print(f"Thread {thread.name} deleted.")
# Remove thread info from the dictionary
thread_info.pop(str(thread.id), None)
6 Replies
d.js toolkit
d.js toolkit10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
Rxy
RxyOP10mo ago
Bot adds the thread ID to a dictionary and schedules it for deletion by remembering the ID of any thread created within a specific channel, works fine in doing that. Though once a thread is closed or archived it can't get to it to be deleted for some reason? almost as though it can't see it
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
wen
wen10mo ago
are u high ^
wen
wen10mo ago
thats most massive L i've ever seen someone take here LMAO
Want results from more Discord servers?
Add your server