Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Discord.js上创建事件_Javascript_Node.js_Discord_Discord.js - Fatal编程技术网

Javascript 如何在Discord.js上创建事件

Javascript 如何在Discord.js上创建事件,javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,我试着去做,但没有成功。当新频道在Discord中打开时,您将在打开新频道的频道上写入消息 client.on("channelCreate", channel => { const newchannel = client.channels.find('id', channel) newchannel.send("New Channel!'") }); 如何解决此问题?channelCreate事件返回GuidChannel,因此无需手动搜

我试着去做,但没有成功。当新频道在Discord中打开时,您将在打开新频道的频道上写入消息

client.on("channelCreate", channel => {
  const newchannel = client.channels.find('id', channel)
  newchannel.send("New Channel!'")
});
如何解决此问题?

channelCreate事件返回GuidChannel,因此无需手动搜索

client.onchannelCreate,频道=>{ channel.sendChannel已创建!.catcherror=>{ console.error`无法将消息发送到${channel.name}。|${error}` }; }; 此外,您使用的find函数也是错误的。以下是您应该如何使用它:

client.channels.findchannel=>channel.id==ChannelID.sendholl World!; 或者,您可以使用:

client.channels.getChannelID.sendholl World!;