Skip to content

fix: give the bot access to the ticket channels it creates - #38

Merged
Musiker15 merged 1 commit into
MSK-Scripts:mainfrom
Uncharted-Roleplay:fix/bot-channel-access
Oct 23, 2026
Merged

Musiker15 merged 1 commit into
MSK-Scripts:mainfrom
Uncharted-Roleplay:fix/bot-channel-access

Conversation

@shane615

Copy link
Copy Markdown
Contributor

Description

New ticket channels deny ViewChannel to @everyone and allow the creator and the staff roles. The @everyone deny applies to the bot as well, and nothing allows it back in. A bot with Administrator doesn't notice, but with the permissions the startup check and the invite URL ask for (Manage Channels, Manage Roles, View Channel, Send Messages, Manage Messages, Embed Links, Attach Files, Read Message History), every new ticket fails right after the channel is created:

[Topic] Could not set topic: Missing Access
[Interactions] Unhandled error: DiscordAPIError[50001]: Missing Access
    at createTicketChannel (src/utils/ticketActions.js)

The user gets "an internal error has occurred", and the half-created channel stays behind as an open ticket.

The fix adds a member overwrite for the bot itself (View Channel, Send Messages, Read Message History, Attach Files, Embed Links) to the channel's initial overwrites. Later moves use lockPermissions: false, so the overwrite stays.

Related Issue

None; found while testing #32–#34 live with a bot that has no Administrator.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

How Was This Tested?

  • Node.js 24.20.0, npm test: all pass, plus tests/ticket-channel-access.test.js (fails without the fix).
  • Live: reproduced on our test server with the invite-URL permissions; after the fix, tickets open normally and the full open / claim / lock / close flow works.

Checklist

  • Code follows the project's conventions
  • No new dependencies
  • No new user-facing strings
  • No schema change
  • Works without MSK_API_KEY
  • Verified on a test server
  • CHANGELOG.md entry under [Unreleased]
  • Conventional Commits

https://claude.ai/code/session_01HZPZxD3edzJNFFsiWsHYY1

@Musiker15

Copy link
Copy Markdown
Member

Thanks, good find. I checked it against main: no move resets the overwrites (everything uses lockPermissions: false), so the bot's own overwrite stays in place. Tests pass, and the new test fails without the fix.

#32 is merged now, so this branch conflicts with main in CHANGELOG.md. I wanted to resolve that for you, but your fork belongs to an organization and GitHub doesn't let maintainers push to those. Could you rebase onto main? Just keep your entry at the end of the ### Fixed list in [Unreleased]. I'll merge it right after.

The overwrites deny ViewChannel to @everyone and allow the creator and
staff roles, but never the bot. A bot without Administrator (the
permissions the startup check and invite URL ask for) locked itself out
of every new ticket: the opening message failed with Missing Access and
the player got 'an internal error has occurred'. Found in the live test.

Claude-Session: https://claude.ai/code/session_01HZPZxD3edzJNFFsiWsHYY1
@shane615
shane615 force-pushed the fix/bot-channel-access branch from 903c67a to eba6eab Compare October 23, 2026 21:08
@shane615

Copy link
Copy Markdown
Contributor Author

Rebased onto main; the entry is at the end of ### Fixed in [Unreleased]. Tests pass.

@Musiker15
Musiker15 merged commit e7f1a8c into MSK-Scripts:main Oct 23, 2026
5 checks passed
shane615 added a commit to Uncharted-Roleplay/ucrp-ticketbot that referenced this pull request Oct 23, 2026
openTicket now looks the member up for getOpenRefusal, so the MSK-Scripts#38 test's
fake guild needs members.fetch; and since MSK-Scripts#38 the channel overwrites read
client.user.id, so the race test's fake client needs a bot user. Test
fixtures only.

Claude-Session: https://claude.ai/code/session_01HZPZxD3edzJNFFsiWsHYY1
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.

2 participants