Getting user from a message link

Hello, if I send my bot a message (msg_A) containing a link to a separate message (msg_B), how can I get the name/user who originally posted msg_B?
3 Replies
d.js docs
d.js docs2y ago
• 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.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
probablyraging
Regex not really necessary, just split the message at each forward slash, leaving you with an array of everything else, the very last entry in that array will be the message ID
const str = 'https://discord.com/channels/222078108977594368/1006924447829205163/1006931711008976986'
const split = str.split('/')
const index = split.length - 1

console.log(split[index]) // 1006931711008976986
const str = 'https://discord.com/channels/222078108977594368/1006924447829205163/1006931711008976986'
const split = str.split('/')
const index = split.length - 1

console.log(split[index]) // 1006931711008976986