Rei-x / discord-speech-recognition

Speech to text extension for discord.js
https://npmjs.com/package/discord-speech-recognition
MIT License
56 stars 22 forks source link

DiscordAPIError: Cannot send an empty message #32

Closed cjlora closed 2 years ago

cjlora commented 2 years ago

Hi there, I was trying out the simpleBot example and the bot crashes when it doesn't recognize a familiar word. I see that it throws something on traceback but it still stops the whole bot from functioning. I would really like to understand the code more and possibly put a try catch method so it prevents it from crashing. Thanks!

Rei-x commented 2 years ago

Okay, that was my bad. I updated simpleBot example and now it should work without crashing. Let me know if it helps you!

cjlora commented 2 years ago

It seemed to not crash anymore, however it started to repeat the message multiple times

image

It also had this on the traceback which I patched by increasing the limit, however it still repeats the message multiple times

image

Rei-x commented 2 years ago

are you using the latest version of discord-speech-recognition? Can you show me te repository with the code?

edit: try to run npm install discord-speech-recognition

Rei-x commented 2 years ago

okay, simpleBot was using outdated version of discord-speech-recognition, it should work now

cjlora commented 2 years ago

Yeah my bad, I didn't update it on my end. Apparently it outputs the message only once now, but it still seems to crash when it picks up inaudible sounds.

Here's the link to the repository: https://github.com/cjlora/tyrant-bot

Rei-x commented 2 years ago

you need to check if message is empty (because sometimes bot doesn't recognize speech properly) -> https://github.com/Rei-x/discord-speech-recognition/blob/main/examples/simpleBot/index.js#L27

client.on("speech", (msg) => {
  if (!msg.content) return; // <- add this
  [some code]
});
cjlora commented 2 years ago

Okay, I'll try it out. Thanks dude!

Rei-x commented 2 years ago

no problem, if it works please close this issue and don't hesitate to ask if you have any more questions, have fun coding

cjlora commented 2 years ago

I'm having a weird interaction when a certain person joins the channel however I don't know how to troubleshoot it. Here's the traceback.

image

Rei-x commented 2 years ago

is this person using web version of discord?

cjlora commented 2 years ago

Yes the person is using a web version of discord.

Rei-x commented 2 years ago

unfortunately, I don't think that I can do anything with it, it's because of how @discordjs/voice handles voice connections, there is an open issue for this: https://github.com/discordjs/discord.js/issues/7647

and there is also open pull request, i think it should be fixed relatively quickly: https://github.com/discordjs/discord.js/pull/8277

cjlora commented 2 years ago

Oh thank you dude. Anyways I'll close the issue now. Thanks for your time.