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 toolkitβ€’6mo 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β€’6mo ago
just send a message in the ready event which should be run everytime pm2 restarts the process
π™‘π™‰π˜Ύπ™‰π™
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β€’6mo ago
ye
π™‘π™‰π˜Ύπ™‰π™
okay let me try
d.js docs
d.js docsβ€’6mo 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
π™‘π™‰π˜Ύπ™‰π™
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β€’6mo ago
now you just have to define the channel object with this in the event
π™‘π™‰π˜Ύπ™‰π™
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β€’6mo ago
yes, you should change it to the id of the channel you want to send a message to
π™‘π™‰π˜Ύπ™‰π™
oh i means i need to change the channel id and channel name? okay let me try it
chewie
chewieβ€’6mo ago
you just need to use one of the two ways not both either channel id OR channel name
π™‘π™‰π˜Ύπ™‰π™
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β€’6mo ago
if the id is correct, then yes
π™‘π™‰π˜Ύπ™‰π™
Okay thank you it worked perfectly πŸ‘
Want results from more Discord servers?
Add your server