Why does guild not exist on interaction at one point?

Here is my declaration I'm using to get a channel using an interaction, when I run this code and pass in the ModalInteraction type of interaciton, when I pass in Command interaction it returns: TypeError: Cannot read properties of undefined (reading 'channels'). What gives?
6 Replies
Squid
Squid3y ago
Depending on which line the error is being thrown on, either this.interaction.guild is undefined, or botConfig is undefined The latter is more likely, depending on what this is defined as But all Interaction instances have a .guild property so it cannot be undefined (even if it can be null)
Grif
GrifOP3y ago
well since it says (reading channels)i presume its at the this.interaction line
Squid
Squid3y ago
It means that whatever comes before .channels is undefined, but you have two spots where something.channels exists If you log this.interaction.guild at the top within the try block, what does it return?
Mac
Mac3y ago
It could if the channel is a DM Make sure no one is running ur suggestion channel in DM's or it could always be that this is undefined
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Mac
Mac3y ago
ahh yes, correct. mb
Want results from more Discord servers?
Add your server