简体   繁体   中英

How to make discord.js bot repeat message given to it in another channel?

I'm using discord.js and am trying to make a bot so that everytime this specific person says something from another server that the bot is in, I want the bot to repeat this message in a specific channel.

client.on('message', message => {
  if (message.author === ("244921929495085057")){
    client.channels.get("655598459268759593").send(message.content);
  }
})

I can't figure out how to do this. Thank you!

I'm assuming you are using the latest version of discord.js which is v12 at the time of writing this.

According to the discord.js docs

You need to add .cache after client.channels to access the channels list.

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