Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context.reply APIError: Code №10 - Internal server error #559

Open
AntonMaksimau opened this issue Nov 15, 2023 · 2 comments
Open

context.reply APIError: Code №10 - Internal server error #559

AntonMaksimau opened this issue Nov 15, 2023 · 2 comments

Comments

@AntonMaksimau
Copy link

AntonMaksimau commented Nov 15, 2023

Я хочу сделать так, чтобы при команде от учатсника чата, бот присылал сообщение
а) Если сама команда соддержит "replyMessage", то на это сообщение (как context.reply только не на команду, а на сообщение приклепленное в команде)
б) Если команда не соддержит "replyMessage", то просто присылало ответ.
Вот код, который постоянно возвращает ошибку APIError: Code №10 - Internal server error

command.hear(/^(Бот зацени|Бот оцени)$/i, async (context) => {
    const peerType = context.peerType;
    const senderType = context.senderType;
    if(peerType == "chat" && senderType == "user"){
        const phrases = ["...", "...", "...", "...", "...", "...", "...", "..."];
        const randomPhrase = phrases[Math.floor(Math.random() * phrases.length)]; 
       if(context.hasReplyMessage){
            context.loadMessagePayload();
            const replyMessage = context.replyMessage;
            const messageId = replyMessage.conversationMessageId;
            const peerId = replyMessage.peerId;
            await context.send({                
                message: randomPhrase,
                peer_id: peerId,
                reply_to: messageId,
                random_id: 0,
            });
        } else {
            context.send(randomPhrase);
        }
    }
});
@negezor
Copy link
Owner

negezor commented Nov 29, 2023

Это внутренняя ошибка ВКонтакте, рекомендую написать в техподдержку. А так же не рекомендую переопределять peer_id в context.send() , так как по умолчанию он уже будет отвечать в текущем диалоге, как и указание random_id не требуется.

@mulfyx
Copy link

mulfyx commented Dec 19, 2023

context.loadMessagePayload(); асинхронный, к слову

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants