Discord API · error code

Discord error 50021: Cannot execute action on a system message

Permanent - do not retryHTTP 400Validation and request shape

Last verified against Discord Developer Docs - Opcodes and status codes

What Discord returns
Cannot execute action on a system message

What error 50021 means

The message you targeted is a system message, one generated by Discord rather than sent by a user, bot or webhook: member join notices, boost announcements, pin notifications, thread-created markers, channel follow adds and similar (message types other than 0 DEFAULT and 19 REPLY, with some exceptions). Certain actions are not allowed on them, notably pinning and replying with a message reference in some cases.

Bots see this when they blindly act on every incoming MESSAGE_CREATE. A welcome bot that reacts to the "X joined the server" system message is fine (reactions are allowed), but one that tries to pin it or reference it in certain ways is not. Auto-pin and auto-thread features should check the message type first. Note that system messages can be deleted with Manage Messages; it is mainly pinning that is refused.

What it looks like

{
  "message": "Cannot execute action on a system message",
  "code": 50021
}

Why it happens

  • Pinning a join, boost, or pin-notification system message
  • Auto-thread or auto-pin logic not filtering by message.type
  • Acting on the CHANNEL_PINNED_MESSAGE notice (type 6) that your own pin just generated, causing a loop

How to fix Discord error 50021

  1. 1Check message.type and skip anything other than 0 (DEFAULT) and 19 (REPLY) for pin/thread automation
  2. 2If you intended to remove the system message, delete it instead (DELETE /channels/{id}/messages/{id} with Manage Messages)
  3. 3Consider disabling the system message sources in Server Settings > Overview (join and boost messages) if they are noise for your bot
  4. 4Add a guard so the bot ignores the type-6 notice it triggers by pinning

How to stop it recurring

Make message type a first-class filter in your event pipeline: most bot features should only ever look at type 0 and 19. Document the exceptions (for example reacting to join messages) explicitly rather than handling all types by default.

System messages are the platform talking to the channel, and the API mostly treats them as read-only furniture. Filtering by message.type at the top of the event pipeline is cheaper than special-casing each feature; the message-type list lives with the message limits on the Discord limits page, and pinning real messages still requires the pairing rules in 50019.

Official reference: Discord Developer Docs - Opcodes and status codes. See all Discord error codes or the Discord limits and quotas.

Related codes

Error 50021 - quick answers

What does Discord error 50021 mean?

The message you targeted is a system message, one generated by Discord rather than sent by a user, bot or webhook: member join notices, boost announcements, pin notifications, thread-created markers, channel follow adds and similar (message types other than 0 DEFAULT and 19 REPLY, with some exceptions). Certain actions are not allowed on them, notably pinning and replying with a message reference in some cases.

How do I fix Discord error 50021?

1. Check message.type and skip anything other than 0 (DEFAULT) and 19 (REPLY) for pin/thread automation 2. If you intended to remove the system message, delete it instead (DELETE /channels/{id}/messages/{id} with Manage Messages) 3. Consider disabling the system message sources in Server Settings > Overview (join and boost messages) if they are noise for your bot 4. Add a guard so the bot ignores the type-6 notice it triggers by pinning

Should I retry after error 50021?

No. Retrying the same request produces the same error; the condition has to be fixed first. Treat it as a permanent failure for that message and surface it, rather than looping.

Stop debugging Discord by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.