S
S
scriptnet hello2020-05-10 19:23:18
In contact with
scriptnet hello, 2020-05-10 19:23:18

How to delete a message in a Vk conversation using vk.api?

response to this code
cmd.on(/^(?:test)$/i, async (message, bot) => {
console.log(message)
})
MessageContext {
id: 0,
conversationMessageId: 132192,
peerId: 2000000001 ,
peerType: 'chat',
senderId: 502634070,
senderType: 'user',
createdAt: 1589127297,
text: 'test',
forwards: MessageForwardsCollection(0) [],
attachments: [],
isOutbox: false,
type: 'message' ,
subTypes: [
'new_message'
],
state: {}
}
How I tried to make the bot delete the message
cmd.on(/^(?:test)$/i, async (message, bot) =>{
vk.api.messages.delete({
message_ids: message.conversationMessageId,
delete_for_all: 1
})
message.send(`message deleted`)
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
THEMOD, 2020-05-11
@scriptnet

Get the message id via messages.getByConversationMessageId and then delete it using messages.delete when getting a response from the first request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question