moonstar-x / discord-tts-bot

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

Crash when parsing custom server emojis #67

Closed moonstar-x closed 2 years ago

moonstar-x commented 2 years ago

:bug: Describe the Bug

Using any say command with an emoji from another server (nitro feature) will crash the bot.

:scroll: Log

/home/runner/discord-tts-bot-1/src/utils/mentions.js:18
  return message.replace(CUSTOM_EMOJI_PATTERN, (_, id) => emojis.get(id).name);
                                                                        ^

TypeError: Cannot read property 'name' of undefined
    at /home/runner/discord-tts-bot-1/src/utils/mentions.js<:18:800772399988736070>73
    at String.replace (<anonymous>)
    at cleanEmojis (/home/runner/discord-tts-bot-1/src/utils/mentions.js<:18:800772399988736070>18)
    at cleanMessage (/home/runner/discord-tts-bot-1/src/utils/mentions.js:27:11)
    at TTSChannelHandler.handleSay (/home/runner/discord-tts-bot-1/src/classes/tts/TTSChannelHandler.js:39:23)
    at TTSChannelHandler.handleMessage (/home/runner/discord-tts-bot-1/src/classes/tts/TTSChannelHandler.js:26:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discord-tts-bot@4.0.5 start: `node ./src/app.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the discord-tts-bot@4.0.5 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-01-29T19_24_43_985Z-debug.log
exit status 1
moonstar-x commented 2 years ago

Fixed in #69.