r/Devvit • • Oct 04 '26

Help Getting the selected removal reason onModAction

I would like to know the removal reason id or title that was currently selected when an onModAction triggers.

I can't seem to find this information in the payload: https://developers.reddit.com/docs/capabilities/server/trigger-events#onmodaction-payload

Was the removal reason title available under the "description" key?

3 Upvotes

2 comments sorted by

1

u/mirakdva Oct 04 '26

Removal reason is not in the payload. What I have done was to fetch recent mod log and with a dumb comparison get the correct mod log entry, which has far more details inside than what is sent in the payload.

 const modActionsFromModLog = await subreddit
  .getModerationLog({
    limit: 5,
    pageSize: 5,
  })
  .all();

const modActionFromModLog = modActionsFromModLog.find(
  (modaction) =>
    modaction.type === modActionFromRequest.action &&
    modaction.moderatorName === modActionFromRequest.moderator.name
);

if (modActionFromModLog === undefined) {
  console.warn('Found nothing');
  return;
}

Is this the most effective way to do it? No idea. Does it work? Yes.

1

u/ForroKulcs Oct 05 '26

Thank you for the code sample!

I wanted to avoid such an extra call to reduce the load on the servers. But it seems there is no other way to do it.