Skip to content

Mr Folio gets a Get release pings button - #252

Merged
McCal-Codes merged 1 commit into
mainfrom
bot-release-pings
Oct 2, 2026
Merged

McCal-Codes merged 1 commit into
mainfrom
bot-release-pings

Conversation

@McCal-Codes

Copy link
Copy Markdown
Owner

What this changes

A "Get release pings" button for Mr Folio. Nothing in the server says how to get the Folio updates role, which is what @-mentions people when a release is posted. The button gives the role when pressed and takes it back when pressed again, and the answer is private to the person who pressed.

  • tools/folio-bot/pings.mjs: the button (one row, one button, custom id folio-release-pings) and the toggle. It reads the person's roles from the interaction itself, so there is no second lookup.
  • worker.js: handles message-component interactions (type 3). A button this bot did not make is acknowledged and ignored.
  • wrangler.toml: ROLE_UPDATES = "1553093586705449062".
  • It only works in the Folio Community server (the same GUILD_ID check /redeem uses).

How I checked it

  • node --test in tools/folio-bot: 50 pass (44 before, 5 in pings.test.mjs, 1 in worker.test.mjs): the button's shape, give and take back, a 403 that says what to fix, another server or a missing setting changing nothing, Discord failing, and a signed press answered privately.
  • Not deployed and not tried in Discord. The button is not on any message yet; I attach it to the pinned welcome post after the bot is deployed.

Before it can work

  • Folio updates sits above Mr Folio in Server Settings › Roles, and Discord only lets a bot hand out roles below its own, so the first press would get a 403 and the message above. Drag Folio updates below Mr Folio (or Mr Folio above it).
  • Deploy from tools/folio-bot (~/dev/folio-site/node_modules/.bin/wrangler deploy).

Cheap way out: revert; no other command reads these files.

  • No app change, so no CHANGELOG line (REL-7 skipped)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b63a277f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tools/folio-bot/worker.js
if (interaction.type === MESSAGE_COMPONENT) {
// A button press. Only the release-pings button exists; anything else is acknowledged and ignored.
if (interaction.data?.custom_id !== PINGS_BUTTON) return json({ type: PONG })
const said = await togglePings(env, interaction, discord(env)).catch((error) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Defer slow component role updates

When Discord's role API takes more than three seconds due to transient latency, this branch sends no initial response until togglePings completes. Discord requires the initial interaction response within three seconds, so the user can see “interaction failed” even though the role change later succeeds; retrying may then reverse the successful change. Unlike the application-command path below, component interactions need the same timeout/defer-and-edit handling. See Discord's interaction response deadline.

Useful? React with 👍 / 👎.

@McCal-Codes
McCal-Codes merged commit 2c2841f into main Oct 2, 2026
3 checks passed
@McCal-Codes
McCal-Codes deleted the bot-release-pings branch October 2, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant