Question on user caching in bot messages

I'm testing making a bot send a message when a user joins and leaves the guild. The message contains a mention of the user. This is basically what I originally wrote:
const container = new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder()
.setContent(`<@${member.id}> has joined the server.`)
);

channel.send({
components: [container],
allowedMentions: { parse: [] },
flags: MessageFlags.IsComponentsV2
});
const container = new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder()
.setContent(`<@${member.id}> has joined the server.`)
);

channel.send({
components: [container],
allowedMentions: { parse: [] },
flags: MessageFlags.IsComponentsV2
});
However, the messages would sometimes show the mention as @unknown-user until you viewed their profile through something like Mod-View. Would changing this to use allowedMentions: { users: [member.id] } fix this or is this unavoidable? If yes to the prior, can the issue still occur when the user leaves the guild?
6 Replies
d.js toolkit
d.js toolkit6mo 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! - Marked as resolved by OP
Lyrian
Lyrian6mo ago
That's how discord protects your privacy. Checkout this user <@186330752437190658> For me it shows the name etc. But for u it's probably unknown user (except if you have indirect contact to him eg. by sharing a server)
Lyrian
Lyrian6mo ago
No description
Steve
Steve6mo ago
but this is about joinijg so it's in the server it's probably about the caching not being updated 🤷🏿‍♂️
treble/luna
treble/luna6mo ago
using allowedmentions should work since cv2 can mention users (they are included in the payload and get cached). Though i don't know if they are included by default or with allowedmentions set
bonyoze
bonyozeOP6mo ago
Got it thanks 👍

Did you find this page helpful?