Been a while since I coded with DJS. How do I listen for the (not as new but still newer) replies...

I am not sure how to listen to replies like the attached image. This works to run commands and I'd like to be able to do the same thing. Also, how do you get the space between the prefix and the command name to work? Is the prefix literally (in the case of this screenshot) .t(space) with (space) being replaced with a literal space?
13 Replies
progamersischu
arguments take the content of the message an split at every space then you got an array. Take the 2nd value [1] and this is your 1st argument. the first argument is "prefixCommand". If you just want the first value [0] to be the first argument then simply slice out the first value of your array and done
Erin
ErinOP3y ago
Alright, so they are using args slice 0 for .t(space) makes sense. Any ideas on how to listen to replies like that? For some of my commands I need to get the user ID of the user replied to... so I ran and logged a message in my test server to myself and this is what I need to grab (this user ID)
repliedUser: User {
id: '455926927371534346',
bot: false,
system: false,
flags: [UserFlags],
username: 'DudeThatsErin',
discriminator: '5567',
avatar: '0dc9b11fed88783e427f08a8041d7349',
banner: undefined,
accentColor: undefined
}
repliedUser: User {
id: '455926927371534346',
bot: false,
system: false,
flags: [UserFlags],
username: 'DudeThatsErin',
discriminator: '5567',
avatar: '0dc9b11fed88783e427f08a8041d7349',
banner: undefined,
accentColor: undefined
}
I just don't know how.
progamersischu
object....... user.id done so your logged user.id
Erin
ErinOP3y ago
I don't understand what you mean by object. What object?
progamersischu
If you request something of the api then you get an object back.
Erin
ErinOP3y ago
Okay, that still doesn't tell me how I get that information. I have tried message.user.id and message.mentions.users.first() former says message.user is incorrect and latter says undefined
progamersischu
how does your event looks like?
progamersischu
yeah so currently you log the user trie user.id or user.user.id idk
Erin
ErinOP3y ago
Did not work.
console.log('My ID should match this: 455926927371534346', message.user.user.id)
^

TypeError: Cannot read properties of undefined (reading 'user')
console.log('My ID should match this: 455926927371534346', message.user.user.id)
^

TypeError: Cannot read properties of undefined (reading 'user')
progamersischu
interesting if you log the error then try: error.stack
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Erin
ErinOP3y ago
I got it. I used message.mentions.repliedUser.id to get that user ID and user's info.
Want results from more Discord servers?
Add your server