storycraft/node-kakao

TypeError: logId.eq is not a function (channel.chatListStore.get())

kaan03 opened this issue · 5 comments

image

const id = new Long('2569351501097908224');
console.log(channel.chatListStore.get(id));

eval을 통해 chat의 logId를 구한 다음 해당 logId 대화를 가져오기 위해 위와 같이 소스를 작성하니 다음과 같은 오류가 발생합니다.

(node:12884) UnhandledPromiseRejectionWarning: TypeError: logId.eq is not a function
    at C:\loco\node_modules\node-kakao\src\talk\chat\store.ts:69:54
    at Array.findIndex (<anonymous>)
    at TalkMemoryChatListStore.findIndex (C:\loco\node_modules\node-kakao\src\talk\chat\store.ts:69:27)
    at TalkMemoryChatListStore.get (C:\loco\node_modules\node-kakao\src\talk\chat\store.ts:87:20)
    at eval (eval at <anonymous> (C:\loco\index.ts:825:35), <anonymous>:1:23)
    at TalkOpenChannelList.<anonymous> (C:\loco\index.ts:825:35)
    at TalkOpenChannelList.emit (C:\loco\node_modules\eventemitter3\index.js:182:35)
    at C:\loco\node_modules\node-kakao\src\event\event-context.ts:24:52
    at Array.forEach (<anonymous>)
    at EventContext.emit (C:\loco\node_modules\node-kakao\src\event\event-context.ts:24:23)
(node:12884) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

소스의 어느 부분을 수정해야 하나요?

chatListStore.get 메서드는 logId 키를 갖는 객체를 인자로 받습니다.

channel.chatListStore.get({ logId: id });

코드를 사용해보세요.

#536 (comment)

chatListStore.get 메서드는 logId 키를 갖는 객체를 인자로 받습니다.

channel.chatListStore.get({ logId: id });

코드를 사용해보세요.

계속 시도해봤는데 안되서 답변 남기는점 죄송합니다.

if(msg == '/info' && data.chat.type === KnownChatType.REPLY) {
      const reply = data.attachment<ReplyAttachment>(); 
      const id = reply.src_logId
      channel.chatListStore.get({logId : id});
}

위와 같은 코드를 사용할 시

'{ logId: Long; }' 형식의 인수는 'Long' 형식의 매개 변수에 할당될 수 없습니다.
  개체 리터럴은 알려진 속성만 지정할 수 있으며 'Long' 형식에 'logId'이(가) 없습니다.

(Argument of type '{ LogId: Long; }' is not assingable to parameter of type 'Long'. )

라는 에러가 발생합니다.

chatListStore.get 메서드는 logId 키를 갖는 객체를 인자로 받습니다.

channel.chatListStore.get({ logId: id });

코드를 사용해보세요.

계속 시도해봤는데 안되서 답변 남기는점 죄송합니다.

if(msg == '/info' && data.chat.type === KnownChatType.REPLY) {
      const reply = data.attachment<ReplyAttachment>(); 
      const id = reply.src_logId
      channel.chatListStore.get({logId : id});
}

위와 같은 코드를 사용할 시

'{ logId: Long; }' 형식의 인수는 'Long' 형식의 매개 변수에 할당될 수 없습니다.
  개체 리터럴은 알려진 속성만 지정할 수 있으며 'Long' 형식에 'logId'이(가) 없습니다.

(Argument of type '{ LogId: Long; }' is not assingable to parameter of type 'Long'. )

라는 에러가 발생합니다.

재확인 결과 channel.chatListStore.get 메서드에 logId 인자를 그대로 주는 것이 맞습니다.

const chat = await channel.chatListStore.get(id);

윗 글은 수정하겠습니다.

image

const id = new Long('2569351501097908224');
console.log(channel.chatListStore.get(id));

eval을 통해 chat의 logId를 구한 다음 해당 logId 대화를 가져오기 위해 위와 같이 소스를 작성하니 다음과 같은 오류가 발생합니다.

(node:12884) UnhandledPromiseRejectionWarning: TypeError: logId.eq is not a function
    at C:\loco\node_modules\node-kakao\src\talk\chat\store.ts:69:54
    at Array.findIndex (<anonymous>)
    at TalkMemoryChatListStore.findIndex (C:\loco\node_modules\node-kakao\src\talk\chat\store.ts:69:27)
    at TalkMemoryChatListStore.get (C:\loco\node_modules\node-kakao\src\talk\chat\store.ts:87:20)
    at eval (eval at <anonymous> (C:\loco\index.ts:825:35), <anonymous>:1:23)
    at TalkOpenChannelList.<anonymous> (C:\loco\index.ts:825:35)
    at TalkOpenChannelList.emit (C:\loco\node_modules\eventemitter3\index.js:182:35)
    at C:\loco\node_modules\node-kakao\src\event\event-context.ts:24:52
    at Array.forEach (<anonymous>)
    at EventContext.emit (C:\loco\node_modules\node-kakao\src\event\event-context.ts:24:23)
(node:12884) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

소스의 어느 부분을 수정해야 하나요?

주어진 소스에서는 에러가 발생하지 않습니다.

주어진 소스에서는 에러가 발생하지 않습니다.

감사합니다. 해결되었습니다 :)