Question:
I am making a Discord bot in discord.js and I want to get the content of a pinned message.I know I can use
interaction.channel.messages.fetchPinned().then(pinnedMessages => /* do stuf */ );
to fetch the messages. But if you try to print out the value of pinnedMessages.content
it will return undefined
.The type of
pinnedMessages
is an object, but I do not know how I can get the contents of it.So, how do I do this?
Answer:
fetchPinned
returns a collection of messages. There are a couple of methods you can use, depending on your needs.To get the content of the first pinned message, you can use:
If you have better answer, please add a comment about this, thank you!