Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

260
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda