How can i automate message?

So, i am currently using pm2 to automatically run my bot and i want my bot to send message every time pm2 start my bot. If you need any further context, i will explain it. Thank you :woah:
15 Replies
d.js toolkit
d.js toolkit4w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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
chewie 🌈
chewie 🌈4w ago
just send a message in the ready event which should be run everytime pm2 restarts the process
iblamevncnt
iblamevncnt4w ago
execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`);
},
execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`);
},
so i just add send a message here? (sorry, im a beginner)
chewie 🌈
chewie 🌈4w ago
ye
iblamevncnt
iblamevncnt4w ago
okay let me try
d.js docs
d.js docs4w ago
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
- Caches in discord.js are Collections which extend the native Map structure. - learn more
iblamevncnt
iblamevncnt4w ago
execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`);
channel.send('Bot is ready!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
},
execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`);
channel.send('Bot is ready!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
},
chewie 🌈
chewie 🌈4w ago
now you just have to define the channel object with this in the event
iblamevncnt
iblamevncnt4w ago
okay let me try
const channel = client.channels.cache.get("222086648706498562");
const channel = client.channels.cache.get("222086648706498562");
what are these numbers suppose to mean? should i change it?
chewie 🌈
chewie 🌈4w ago
yes, you should change it to the id of the channel you want to send a message to
iblamevncnt
iblamevncnt4w ago
oh i means i need to change the channel id and channel name? okay let me try it
chewie 🌈
chewie 🌈4w ago
you just need to use one of the two ways not both either channel id OR channel name
iblamevncnt
iblamevncnt4w ago
oh okay
module.exports = {
name: Events.ClientReady,
once: true,
execute(client) {
const channel = client.channels.cache.get("1250036747732127848");
console.log(`Ready! Logged in as ${client.user.tag}`);
channel.send('Bot is ready!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
},
};
module.exports = {
name: Events.ClientReady,
once: true,
execute(client) {
const channel = client.channels.cache.get("1250036747732127848");
console.log(`Ready! Logged in as ${client.user.tag}`);
channel.send('Bot is ready!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
},
};
is this good?
chewie 🌈
chewie 🌈4w ago
if the id is correct, then yes
iblamevncnt
iblamevncnt4w ago
Okay thank you it worked perfectly 👍