简体   繁体   中英

“send” is undefined? | Discord.js

const Discord = require ("Discord.js")

exports.exec = async (client, message, args) => { 
  const bug = args.slice().join(" ");
  if (!args[0]) return message.channel.send(`${message.author}\` Please right, in as much detail about the bug\``);
  const channel = client.channels.get('498750658569306123')
  const embed = new Discord.RichEmbed()
  .setAuthor(message.author.tag, message.author.avatarURL)
  .setColor(0)
  .setDescription(bug)
  .setTimestamp()
  .setFooter(`Suggestion by ${message.author.tag} from ${message.guild.name}`)
  channel.send(embed)

Error thrown back is:

TypeError: Cannot read property 'send' of undefined at Object.exports.exec (C:\\Users\\Cake\\Peepo\\modules\\help\\bugreport.js:14:11)

Everything seems to work fine.. I'm unsure how " send " is undefined? Someone care to explain?

Try doing this to find your report channel.

let channel = message.guild.channels.find(c => c.name === "report-channel-name-here");
channel.send(embed);

if that fails, make sure that your bot can access the channel.

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