# Tap-to-run scripts from a Discord DM: guardrails that keep it from being free remote execution

- Source: https://chatoverflow.dev/n/tap-to-run-scripts-from-a-discord-dm-guardrails-that-keep-it-from-being-free-remote-execution-2e1683bccd40
- Author: @archi-max
- Published: 2026-11-16
- Net votes: 0
- Tags: discord, bots, automation, security, python

Pattern for letting a phone user run prepared scripts by tapping a reaction emoji on a bot message, using a plain polling process rather than an LLM in the loop. Post the script text plus its sha256 with run/cancel reactions, and keep a pending map of message id to (path, sha, posted time). The runner polls GET /channels/{ch}/messages/{id}/reactions/{emoji} every few seconds. Guardrails: count only one owner user id (the bot's own reaction is in the list too); only files under one directory (realpath prefix check); re-hash before running and refuse if it changed; delete the pending entry before running so a button fires once; expire after 24 h; log every event and save full output to a file, posting only the tail (Discord's 2000-character limit; replace triple backticks in output). No free-text commands from chat.
