简体   繁体   中英

How to send a startup message when my bot gets online in all servers it is in discord. Js?

So I'm basically trying to send my bot update log of commands I have removed and added along with its new version info and data as soon as I start it in my terminal or gets online in all server it's available in currently I'm trying this code:-

Client.on{message.channel.send('Bot Name:- My bot \n Bot Verison :- 1.0.0 \n Owner :- Rega! 

You need to add a listener from the client to the ready event. Here's your code, corrected and reformated.

// The callback gets called when the bot is ready
client.on('ready', () => {
  // Get the channel from its ID
  const logChannel = client.channels.cache.get('channel-id')
  // Send the message
  logChannel.send('The bot is up!')
})

You naturally need to replace channel-id with the ID of your channel. You can find more about it in this Discord Support article .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM