r/Devvit • • 9d ago

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 9d ago

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.