discord.js 랜덤 이미지 질문

조회수 1016회
// Send hikari's image
client.on('message', message => {
    if (message.content.startsWith ("hikari")) {
        const hikari = [
            'https://example/giphy.gif',
            'https://example/giphy2.gif',
            'https://example/giphy3.gif',
            ]


            message.channel.send({
                file: hikari[Math.floor(Math.random() * hikari.length)]
            });

    }
});

이런다음 hikari를 치면

(node:12432) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\로컬주소\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:12432) 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: 1)
(node:12432) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

라는 오류가 뜨면서 불러오지를 못합니다.

message.channel.send({
                file: hikari[Math.floor(Math.random() * hikari.length)]
            });

에서 문제가 있는것같은데 고치기에는 능력이 부족하네요 ㅠㅠ

  • (•́ ✖ •̀)
    알 수 없는 사용자
  • 오류메시지 자체는 "내용이 없는 메시지를 보낼수는 없듬"입니다. 뭔가 텍스트메시지 보내는 부분이 있을텐데 거기에 아무말이나 넣어서 다시 해보시겠어요? 엽토군 2020.6.11 16:07

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)