moonstar-x / discord-tts-bot

A Text-to-Speech bot for Discord.
https://docs.moonstar-x.dev/discord-tts-bot
MIT License
98 stars 84 forks source link

Crash when sending images/stickers in TTS channel #68

Closed Natame closed 2 years ago

Natame commented 2 years ago

:bug: Describe the Bug

Using stickers or sending an image in TTS channel will crash the bot

:scroll: Log

/www/wwwroot/discordbot/NetaTTS/node_modules/google-tts-api/dist/assertInputTypes.js:5
        throw new TypeError('text should be a string');
              ^

TypeError: text should be a string
    at Object.assertInputTypes [as default] (/www/wwwroot/discordbot/NetaTTS/node_modules/google-tts-api/dist/assertInputTypes.js:5:15)
    at Object.getAllAudioUrls (/www/wwwroot/discordbot/NetaTTS/node_modules/google-tts-api/dist/getAudioUrl.js:61:31)
    at /www/wwwroot/discordbot/NetaTTS/src/classes/tts/providers/GoogleProvider.js:12:32
    at new Promise (<anonymous>)
    at GoogleProvider.createPayload (/www/wwwroot/discordbot/NetaTTS/src/classes/tts/providers/GoogleProvider.js:10:12)
    at TTSPlayer.say (/www/wwwroot/discordbot/NetaTTS/src/classes/tts/TTSPlayer.js:63:36)
    at TTSChannelHandler.handleSay (/www/wwwroot/discordbot/NetaTTS/src/classes/tts/TTSChannelHandler.js:55:24)
    at TTSChannelHandler.handleMessage (/www/wwwroot/discordbot/NetaTTS/src/classes/tts/TTSChannelHandler.js:26:17)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Node.js v17.4.0
moonstar-x commented 2 years ago

Hey there, can you post a screenshot of a message example that crashes the bot?

Is it like when you send a message with no text and just an image/sticker?

Natame commented 2 years ago

Yes, sending an image with no text crashes the bot

Got it fixed by adding:

if (textToSay === "")
      return;

in /src/classes/tts/TTSChannelHandler.js for now

moonstar-x commented 2 years ago

Fixed in #69.