message_delete
message_delete removes a message for everyone. Authors can delete their own messages, and moderators can delete anyone’s.
Request
Section titled “Request”{ "cmd": "message_delete", "channel": "general", "id": "7d0e4c1a-5b8f-4b0e-8f55-2d3c9a61e7b4"}| Field | Type | Required | Description |
|---|---|---|---|
channel |
string | One of channel or thread_id |
Channel name. |
thread_id |
string | One of channel or thread_id |
Thread ID. If you also send channel, it must be the thread’s parent. |
id |
string | Yes | ID of the message to delete. |
Deleting a message also deletes its poll, if it has one, and the stored files of its attachments.
Response
Section titled “Response”The server sends this event to you and to every other connection that can view the channel:
{ "cmd": "message_delete", "channel": "general", "id": "7d0e4c1a-5b8f-4b0e-8f55-2d3c9a61e7b4"}- A thread deletion has
thread_id, andchannelis the thread’s parent. - Only your copy carries your request’s
listener. Users severed from you don’t receive the event.
The deletion is recorded in the audit log with the author and the deleted text.
Permissions
Section titled “Permissions”You must be able to view the channel. Then:
- For your own message, your roles need
delete_ownin the channel. - For someone else’s message, your roles need
delete.
A user in a timeout can’t delete messages.
Errors
Section titled “Errors”val |
When |
|---|---|
Channel not found |
The channel doesn’t exist, or you sent neither channel nor thread_id. |
Thread not found |
No thread has this ID. |
Thread does not belong to this channel |
channel is not the thread’s parent. |
You do not have permission to view this thread |
You can’t view the thread’s parent channel. |
Messages must be sent inside a thread in forum channels |
channel is a forum and you sent no thread_id. |
This channel does not support chat |
channel is a separator. |
Access denied to this channel |
You can’t view the channel. |
Message not found |
No message with this ID is in the channel or thread. |
You do not have permission to delete your own messages in this channel |
Your roles lack delete_own. |
You do not have permission to delete messages in this channel |
The message is someone else’s and your roles lack delete. |
Unable to delete message poll |
The message was deleted, but its poll could not be. No message_delete event is sent, so reload the channel. |
A validation message is returned when id is missing or empty. A user in a timeout gets a rate_limit frame; see the protocol model.
