Discord.js sending a message to a specific channel

后端 未结 4 1874
予麋鹿
予麋鹿 2020-12-20 19:27

I\'m failing to achieve something very simple. I can\'t send a message to a specific channel. I\'ve browsed trough the documentation and similar threads on stack overflow. <

4条回答
  •  眼角桃花
    2020-12-20 19:44

    Here's how I send a message to a specific channel every time a message is deleted. This is helpful if you'd like to send the message without a channel ID.

    client.on("messageDelete", (messageDelete) => {
      const channel = messageDelete.guild.channels.find(ch => ch.name === 'channel name here');
      channel.send(`The message : "${messageDelete.content}" by ${messageDelete.author} was deleted. Their ID is ${messageDelete.author.id}`);
    }); 
    

    Make sure to define it if you're not using messageDelete.

提交回复
热议问题