Answer the question
In order to leave comments, you need to log in
How to display attachments: []?
MessageContext {
id: 0,
conversationMessageId: 0,
peerId: 0,
peerType: 'chat',
senderId: 0,
senderType: 'user',
createdAt: 0,
updatedAt: undefined,
pinnedAt: undefined,
text: undefined,
forwards: MessageForwardsCollection(1) [
MessageContext {
id: 0,
conversationMessageId: 0,
peerId: 0,
peerType: 'chat',
senderId: 0,
senderType: 'user',
createdAt: 0,
updatedAt: undefined,
pinnedAt: undefined,
text: undefined,
forwards: MessageForwardsCollection(1) [
MessageContext {
id: 0,
conversationMessageId: 0,
peerId: 0,
peerType: 'chat',
senderId: 0,
senderType: 'user',
createdAt: 0,
updatedAt: undefined,
pinnedAt: undefined,
text: undefined,
forwards: MessageForwardsCollection(0) [],
attachments: [
AudioMessageAttachment <audio_message0_0_0000> {
id: 0,
ownerId: 0,
accessKey: '000000',
duration: 0,
oggUrl: 'https://psv4.userapi.com/c0//u0/audiomsg/d4/0.ogg',
mp3Url: 'https://psv4.userapi.com/c0//u0/audiomsg/d4/0.mp3',
url: 'https://psv4.userapi.com/c0//u0/audiomsg/d4/0.mp3',
locale: undefined,
transcript: undefined,
isTranscriptDone: false
}
],
isOutbox: false,
type: 'message',
subTypes: [
'message_new'
],
state: {}
}
],
attachments: [],
isOutbox: false,
type: 'message',
subTypes: [
'message_new'
],
state: {}
}
],
attachments: [],
isOutbox: true,
type: 'message',
subTypes: [
'message_new'
],
state: {}
}
мне нужно вывести только вот это:
attachments: [
AudioMessageAttachment <audio_message0_0_0000> {
id: 0,
ownerId: 0,
accessKey: '000000',
duration: 0,
oggUrl: 'https://psv4.userapi.com/c0//u0/audiomsg/d4/0.ogg',
mp3Url: 'https://psv4.userapi.com/c0//u0/audiomsg/d4/0.mp3',
url: 'https://psv4.userapi.com/c0//u0/audiomsg/d4/0.mp3',
locale: undefined,
transcript: undefined,
isTranscriptDone: false
}
],
isOutbox: false,
type: 'message',
subTypes: [
'message_new'
],
state: {}
}
]
Answer the question
In order to leave comments, you need to log in
look at how your command looks like, that is, for example, cmd.on(/^test/i, message => {}), just look at what you have written instead of message and then to get any information from the message we do: message.attachments or for example message.text is the text of the message
const attachment = message.attachments
const example = attachment.filter(x => x.text == message.text)[0] //без фильтра почему то не мог получить параметры..
const data = {
id: 0,
conversationMessageId: 0,
peerId: 0,
peerType: 'chat',
senderId: 0,
senderType: 'user',
createdAt: 0,
updatedAt: undefined,
pinnedAt: undefined,
text: undefined,
forwards: [
{
id: 0,
conversationMessageId: 0,
peerId: 0,
peerType: 'chat',
senderId: 0,
senderType: 'user',
createdAt: 0,
updatedAt: undefined,
pinnedAt: undefined,
text: undefined,
forwards: [
{
id: 0,
conversationMessageId: 0,
peerId: 0,
peerType: 'chat',
senderId: 0,
senderType: 'user',
createdAt: 0,
updatedAt: undefined,
pinnedAt: undefined,
text: undefined,
forwards: [],
attachments: [
{
id: 0,
ownerId: 0,
accessKey: '000000',
duration: 0,
oggUrl: 'https://psv4.userapi.com/c0//u0/audiomsg/d4/0.ogg',
mp3Url: 'https://psv4.userapi.com/c0//u0/audiomsg/d4/0.mp3',
url: 'https://psv4.userapi.com/c0//u0/audiomsg/d4/0.mp3',
locale: undefined,
transcript: undefined,
isTranscriptDone: false
}
],
isOutbox: false,
type: 'message',
subTypes: [
'message_new'
],
state: {}
}
],
attachments: [],
isOutbox: false,
type: 'message',
subTypes: [
'message_new'
],
state: {}
}
],
attachments: [],
isOutbox: true,
type: 'message',
subTypes: [
'message_new'
],
state: {}
};
console.log(data.forwards[0].forwards[0].attachments)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question