TypeError: Cannot read properties of undefined (reading 'channels')
I am trying to automate the welcome messages through the use of a bot and have a functioning listener for the guildMemberAdd event but when trying to get the id of the channel I want to send the message to I get this error. My code is the following
I have at this point quintuple checked that this is the correct channel and correct id for the channel. Does this have something to do with the nature of the client object being passed in. Any help appreciated.
5 Replies
client isn't a parameter for guildMemberAdd
Also this is a discord.js issue, not sapphire related
But nevertheless, the argument should be member (as it's the GuildMember passed through)
And just like in a Command class, you can use
As
container
is also part of the Listener classAhh ok that makes more sense that it takes the guild member rather than the client. I struggled to find info on the docs I am not super experience reading docs in general but do you have alink to the documentation for the listener class. When using the search function on the site I only see the namespace Listener.
And as for discord.js documentation, the event shows the parameter being "member"
Also if you do
Listener<typeof Events.GuildMemberAdd>
(Events is imported from sapphire, it's our constant for all the event names, you can also use it for the event: Events.GuildMemberAdd
) then TS will scream at you for providing the wrong types to the run method.