#Make bot send message from a specific user in a specific channel

5 messages · Page 1 of 1 (latest)

bleak jasper
#

I'm trying to make a bot send a message to a specific channel, the message sent would be something I say in another channel, I don't get any errors, just nothing happens whenever I send a message.

const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });

client.once(Events.ClientReady, c => {
    console.log(`Ready! Logged in as ${c.user.tag}`);
});
let mustaMsg = "";
client.on("messageCreate", (message) => {
    const channel = client.channels.cache.get("1193008116246249545");
    if (message.author.username === "Musta" && (message.channel.id != "1193008116246249545")) {
        mustaMsg = message.content;
        channel.send(mustaMsg);
    }
})
client.login(token);
obtuse needleBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
bleak jasper
smoky birch
#

Your current code is checking the wrong property for the wrong username