cloudCustomData
of a message, enabling features such as message replies and references as shown below:MESSAGE_MODIFIED
event.random
, sequence
, or time
fields of a message.chat.modifyMessage(message);
Name | Type | Description |
message | Message | Message instance |
Promise
// Listen for the `MESSAGE_MODIFIED` event// which will be delivered by the SDK after a message is modified successfullylet onMessageModified = function(event) {// event.data - An array that stores modified Message objects - [Message]};chat.on(TencentCloudChat.EVENT.MESSAGE_MODIFIED, onMessageModified);// Change the text content of `txtMessage` to `Hello Tencent`txtMessage.payload.text = "Hello Tencent";let promise = chat.modifyMessage(txtMessage);promise.then(function(imResponse) {const { message } = imResponse.data;// Message modified successfully. `message` is the latest message.}).catch(function(imError) {// Failed to modify the messageconst { code, data } = imError;if (code === 2480) {// A conflict occurred while modifying the message. `data.message` is the latest message.} else if (code === 2481) {// Audio-video group messages cannot be modified.} else if (code === 20026) {// The message does not exist.}});
Was this page helpful?