简体   繁体   中英

send message to specific channel upon ready/launch

im trying to find a way to send a message to a channel upon launch of the discord bot. I've tried using

client.on('message', (message) => {
client.on('ready', () => {
  channel = client.channels.cache.get('744630121213722696');
  channel.send('bot is up and running!');

})});

but no success, I get no error messages just no response from the bot

You can't have 2 handlers in one. Take away the client.on('message', (message) => {}

So new code would be:

client.on('ready', () => {
  channel = client.channels.cache.get('744630121213722696');
  channel.send('bot is up and running!');

});

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