Get user who clicked button
I would like to get the nickname of the user who pressed the button, only that when I type there, for example, interaction.member.user.username, it gives me the user who typed the slash command
11 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.await confirmation.update({ embeds: [potwierdzenie], components: [] });
const myDB = getDb();
const db = myDB.collection(
ThxList
);
const doc = {
user: user.username + "#" + user.discriminator,
userId: user.id,
from: interaction.user.username,
fromId: interaction.user.id,
acceptedBy: ???,
};
const result = await db.insertOne(doc);
console.log(
A document was inserted with the _id: ${result.insertedId}
);buttoninteraction.member.nickname or .displayName
What is
interaction
? The button interaction?
And what is confirmation
They both seem to be interactions, looks like confirmation is the buttoninteraction from what you saidconst confirmation = await response.awaitMessageComponent({ time: null });
I was right, why is the time null btw
async execute(interaction) {......
is that infinity
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
confirmation.member.nickname
or confirmation.member.displayName
to get the username if the nickname is null. From ur code, you're not tryna get the nickname, that's the usernameI fix that
thanks
I mean, technically but you can just not pass it, which I don't recommend cuz then if the person doesn't click you'd have the collector going on forever which can affect memory and stuff
If more than one collector is created and stuff of course
ok
I will keep this in mind