Discord.js showing "message.author.tag | message.content"

Viewed 1503

So I am making a bot that when it gets dmed it logs to a channel, the problem is, the message coming to the channel is showing "message.author.tag | message.content" instead of the user dming and what they said. I'm sure this is an easy fix but I can't find it in the docs.

client.on('message', message => {
    if (message.channel.type === "dm" && message.author.id !== client.user.id) {
    client.channels.cache.get('789752010572169216').send(`message.author.tag | message.content`);
}})
1 Answers

When you use backticks for a string you're making a template literal. The way to interpolate, or insert values in template literals is to wrap them in ${}.

So you can change the message to something like this:

`${message.author.tag} | ${message.content}`
Related