recognize user

I want to make a command that reads all the arguments given to a user with a keyboard and looks for which of those messages are IDs of existing people, and if it finds them, it returns all the ones it found in the form of a mention. I have this code:
(async () => {
const args = d.message.content.split(" ").slice(1);
const validIds = [];

for (const id of args) {
try {
await client.users.fetch(id);
validIds.push(id);
} catch {
}
}

if (validIds.length > 0) {
return validIds.join("\\n");
}
})()
(async () => {
const args = d.message.content.split(" ").slice(1);
const validIds = [];

for (const id of args) {
try {
await client.users.fetch(id);
validIds.push(id);
} catch {
}
}

if (validIds.length > 0) {
return validIds.join("\\n");
}
})()
but it doesn't work
5 Replies
d.js toolkit
d.js toolkit4mo ago
- 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!
YordiGamex
YordiGamexOP4mo ago
It does not send an error to the console but it does not return anything either.
treble/luna
treble/luna4mo ago
first of all why dont you use slash commands, they have built in validation second, does that function run at all
d.js docs
d.js docs4mo ago
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops. - Once you do, log relevant values and if-conditions - More sophisticated debugging methods are breakpoints and runtime inspections: learn more
YordiGamex
YordiGamexOP4mo ago
I don't like using slash command and for that command I don't find it necessary
Want results from more Discord servers?
Add your server