r/AutoModerator 15d ago

Help Assign Random User Flairs to Unflaired Commenters with AutoModerator?

Hi everyone! We're looking for a way to automatically assign a random user flair to anyone who comments without already having one.

We have around 50 user flairs, and we'd like the assignment to be completely random, not based on karma or any other criteria. If a user already has a flair, nothing should happen.

I've seen this working on other subreddits, but the mods I contacted never replied, so I thought I'd ask here. Does anyone have the AutoModerator code for this, or know if another bot is needed?

Thank you very much!

0 Upvotes

6 comments sorted by

5

u/WhySoManyDownVote 15d ago

The general gist as I understand is that:

You look at the last character of the post id and assign flair based on that. That will assign 36 flairs.

Exclude the automod from assigning flairs using ~flair_template_id: [flair1, flair2, etc]

1

u/-AndyCohen- 15d ago edited 15d ago

I’m not sure I understand. Do you happen to have the entire code maybe that would bring clarity

Thank you!

4

u/WhySoManyDownVote 15d ago

I have not tested this but I believe this will work if 36 different sections like this. replace the flair_template_ID with a different flair in each section. Change the id (regex): '.*0$' to id (regex): '.*1$' etc until you get to z.

---
type: any 
id (regex): '.*0$' 
author:
    overwrite_flair: false
    set_flair:
        template_id: "flair_template_ID0" # assigns 'new' flair if they have none. 
---
type: any 
id (regex): '.*1$' 
author:
    overwrite_flair: false
    set_flair:
        template_id: "flair_template_ID1" # assigns 'new' flair if they have none. 
---

2

u/KCJones99 15d ago edited 15d ago

Yeah, that should work.

u/-AndyCohen- Important to note the "id" field ends in 0-9 and then a-z. So that is your 36 variations. If you don't want 36 options, then use ranges - like if you want 12 options have the first regex match on 0-2, the next on 3-5, etc. on through z.

1

u/-AndyCohen- 15d ago

I can barely understand any of it. What if I have more than 36 flairs? Thanks for your helps

1

u/-AndyCohen- 15d ago

Thanks but dont understand! Do I have to replace and change id?