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
Squid2y 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
Grif2y ago
well since it says (reading channels)i presume its at the this.interaction line
Squid
Squid2y 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
Mac2y 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 User2y ago
Message Not Public
Sign In & Join Server To View
Mac
Mac2y ago
ahh yes, correct. mb