简体   繁体   English

准备好/启动时向特定频道发送消息

[英]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.您不能将 2 个处理程序合二为一。 Take away the client.on('message', (message) => {}带走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!');

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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