How to make a filter?
Error: TypeError: Cannot read properties of undefined (reading 'id')
How do I get the author Id? I tried researching...
12 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!you seem to already be aware that
<Interaction>.user
exists
consider using the property that exists rather than one that doesn't
though you should probably also rename your filter's param so that you don't attempt to compare the same interaction's user with itself@duck I tried message.author.id but it failed even though I defined it...
interaction.author ain't a thing
I also tried message.author.id but it didn't work....
Maybe save the id of the author in a variable before setting a filter
dont use {} then ig
it's because you're checking for a boolean but not returning anything
@Andrew okay I will try that
did they completely remove message.autor.id in v14?
no they didn't, and there's no good reason to do so. I'm just telling you to handle it yourself
because interaction.author isn't a thing
@Andrew Yes Ik just make an empty attempt because the message.author.id didn't work
(this is in a command handler)
Anyways, I'll try an handle it but thank you
to fully elaborate, just naming the variable
message
won't suddenly make its value a Message
object
given your error and initial code, I'm assuming this is slash command handler (or in general an application command handler) rather than a text command handler, in which case this uses the interactionCreate
event
and therefore the object you're working with is an Interaction
object
as previously mentioned <Interaction>.user
exists, which is a property you already seem aware of being the user who invoked the interactionOh I am using a splash command
Oh Guys, I wasn't able to figure out the filter but I was able to find an alternative
I just defined the author by
interaction.user.id
right when the author requests the buttons and compare it when the button is clickedwhy would author be an id