Discord error 40058: Cannot send a message in a forum channel
Last verified against Discord Developer Docs - Opcodes and status codes
Cannot send a message in a forum channelWhat error 40058 means
You posted to POST /channels/{channel.id}/messages with the ID of a forum channel. Forum channels (type 15) and media channels (type 16) do not hold messages directly. Every message lives inside a post, and each post is a thread.
To post into a forum, create a thread with POST /channels/{channel.id}/threads and include a message object in the body; that message becomes the post's opening message. To reply to an existing post, send to the thread's own channel ID, not the forum's.
This confuses bots that store a "log channel" or "announcement channel" by ID and later find an admin converted it, or selected a forum, in a setup menu that allowed any channel type. Webhooks have their own forum rules, covered on 220001.
What it looks like
{
"message": "Cannot send a message in a forum channel",
"code": 40058
}Why it happens
- Bot configured to post into a channel that is a forum or media channel
- Setup command channel picker did not restrict channel types
- Message intended for an existing post sent to the parent forum ID
- Admin changed the channel setup after the bot stored the ID
How to fix Discord error 40058
- 1Fetch the channel and check its type before sending
- 2For a new post, call POST /channels/{forum.id}/threads with name and message fields
- 3For replies, send to the thread ID of the existing post
- 4Restrict channel selectors in your setup command to text channel types
How to stop it recurring
Validate channel type when a channel is configured, not when the first message fails, and use channel_types on channel options in slash commands. If forums need to be supported, add an explicit create-post path. Required forum tags are a separate rule, see 40067.
Official reference: Discord Developer Docs - Opcodes and status codes. See all Discord error codes or the Discord limits and quotas.
Related codes
- 40067: A tag is required to create a forum postA tag is required to create a forum post in this channel
- 220001: Forum webhooks need thread_name or thread_idWebhooks posted to forum channels must have a thread_name or thread_id
- 50008: Cannot send messages in a non-text channelCannot send messages in a non-text channel
- 50024: Cannot execute action on this channel typeCannot execute action on this channel type
Error 40058 - quick answers
What does Discord error 40058 mean?
You posted to POST /channels/{channel.id}/messages with the ID of a forum channel. Forum channels (type 15) and media channels (type 16) do not hold messages directly. Every message lives inside a post, and each post is a thread. To post into a forum, create a thread with POST /channels/{channel.id}/threads and include a message object in the body; that message becomes the post's opening message.
How do I fix Discord error 40058?
1. Fetch the channel and check its type before sending 2. For a new post, call POST /channels/{forum.id}/threads with name and message fields 3. For replies, send to the thread ID of the existing post 4. Restrict channel selectors in your setup command to text channel types
Should I retry after error 40058?
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.