Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
Sending Bots Name Not Users Discord

So here is my code

const Discord = require('discord.js');

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [4611] });

let targetChannel = '906686653874176090' //target channel

client.once('ready', () => {
    console.log('Ready! - Made By Woodington');
});  

client.on('messageCreate', gotMessage);

function gotMessage(msg) {
    if (msg.channel.id !== targetChannel) { 
        client.channels.fetch(targetChannel)  
        .then(channel => channel.send(msg.content + `${client.user.tag}`)) 
        .catch(console.error);
    }
}

What it does is forward messages to another channel, with the users Discord tag at the bottom. However, it sends the bots Discord name and not the original senders. Any ideas?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are using the client variable which is your own bot. You need to make use of the msg parameter you received within the event. That's the reason why your bot sends its own tag, because client.user.tag equals YourBot#0000.

To send the author's tag, replace client.user.tag with the following:

msg.author.tag

This will return Author's Username#0000

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!