RPDJF / Goofyn

Goofyn is a fun, friendly Discord bot inspired by "Murder Drones." It chats like a real user with playful, emoji-filled messages!
https://goofyn.ruinformatique.ch
MIT License
3 stars 0 forks source link

[bug] Welcome command crashing if no guild document #7

Closed RPDJF closed 3 months ago

RPDJF commented 3 months ago

Using the welcome command before registering any other data on the server will cause the command to crash. However, if data is registered first, for example by using the language command, the welcome command can then be used successfully. The issue may stem from problematic code within the welcome command:

const welcomeDoc = (await db.getData("guilds", interaction.guildId)).welcome || { enabled: false, channel_id: null, message: null, thumbnail_url: null };

The code attempts to access the welcome property of the document without verifying if the document is null. To resolve this, we should check for the existence of the document before proceeding.

Action items: