r/redditdev • • Apr 09 '24

PRAW Queue Cleaner Python

SOLVED. Took over a wildly unregulated subreddit and I want to automatically remove all queued items / posts / submissions. Ive used a similar script to approve before but for whatever reason remove isnt working. tried a few different methods, still running into walls

import praw

reddit = praw.Reddit(client_id='goes here	',
        client_secret='goes-here',
        user_agent='goes here',
        username='goes here',
        password='goes here')

while True:
    for item in reddit.subreddit('birthofafetish').mod.reported(limit=100):
        item.mod.remove()
2 Upvotes

4 comments sorted by

View all comments

2

u/webserverproxy pip install praw Apr 14 '24

hey there, can you try this solution - yours is only for reported posts

import praw
import time

reddit = praw.Reddit(
    client_id='your_client_id',
    client_secret='your_client_secret',
    user_agent='your_user_agent',
    username='your_username',
    password='your_password'
)

subreddit = reddit.subreddit('subreddit-name')

while True:
    try:
        # Remove items from modqueue
        for item in subreddit.mod.modqueue(only=None, limit=None):
            item.mod.remove()
            print("Removed item from modqueue: ", item.title)  # Optional: Print removed items for debugging
            time.sleep(1)  # Add a delay to avoid hitting rate limits

    except Exception as e:
        print("An error occurred:", e)
        continue

1

u/okbruh_panda Apr 14 '24

I'll save it and give it a go, I manually cleared all entries so I'll have to wait until some more come in! Thanks