Musta
Musta
DIAdiscord.js - Imagine an app
Created by Musta on 1/6/2024 in #djs-questions
Make bot send message from a specific user in a specific channel
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);
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);
6 replies