SzoDavid / WordChain

A word chain game discord bot. Project to learn Node.js
MIT License
2 stars 2 forks source link

Status command crashes if database is empty #38

Open SzoDavid opened 2 years ago

SzoDavid commented 2 years ago

If the database is empty running /status throws an error:

Uncaught CombinedPropertyError Error: Received one or more errors
    at handle (/path/WordChain/node_modules/@sapphire/shapeshift/dist/index.js:463:70)
    at parse (/path/WordChain/node_modules/@sapphire/shapeshift/dist/index.js:142:88)
    at addFields (/path/WordChain/node_modules/@discordjs/builders/dist/messages/embed/Embed.cjs:17:42)
    at execute (/path/WordChain/commands/status.js:34:25)
SzoDavid commented 2 years ago

Maybe the issue is with parsing the channels used by the bot in the current server. Check what happens if there are channels registered in one server, but there are none in an other one.

If this is the issue, in this case display an embed saying for example "There are channels using this bot already, make it <++num> by running /set_channel"

kovagoadi commented 2 years ago

Maybe the issue is with parsing the channels used by the bot in the current server. Check what happens if there are channels registered in one server, but there are none in an other one.

From what I've seen it isn't related to that. It happens because the value of statusEmbed for the current channels is set to an empty string (it is set in game/status.js here, then the foreach doesn't happen, because the query doen't return anything, thus the function returns an empty string for channels), which I think causes this error to occur.