Javascript Discord.js无法读取属性';发送';未定义的和其他一些小问题

Javascript Discord.js无法读取属性';发送';未定义的和其他一些小问题,javascript,node.js,discord.js,Javascript,Node.js,Discord.js,我现在使用它作为命令处理程序。 我已经试了好几个小时让它工作,但就是不工作。我现在唯一的错误是 “无法读取未定义的'send'属性”,但我觉得在修复它之后,它还会有其他错误 代码应将消息、已删除消息、已编辑消息的副本发送到频道。前一段时间还可以用,但现在坏了 我对此代码有问题: // import library const { JDClient, Discord } = require('./src/'); const { prefix, token, logsChannel } = requ

我现在使用它作为命令处理程序。 我已经试了好几个小时让它工作,但就是不工作。我现在唯一的错误是 “无法读取未定义的'send'属性”,但我觉得在修复它之后,它还会有其他错误 代码应将消息、已删除消息、已编辑消息的副本发送到频道。前一段时间还可以用,但现在坏了 我对此代码有问题:

// import library
const { JDClient, Discord } = require('./src/');
const { prefix, token, logsChannel } = require('./config.json');
client = new Discord.Client();
// define minimum bot options
const options = {
  token: 'TOKEN',
  trigger: '?'
};


// build bot commands
const commands = {
  help: {
    run: (message, pars, arr)=>{
      message.reply('**Available commands:** \n' + Object.keys(bot.commands).join(', '))
    }
  }
};


// create bot instance
var bot = new JDClient(options, commands);

// Messages log
bot.discord.on('message', message => {
  // Function
  function isEmpty(collection) {
      for(var arg in collection) {
          if(collection.hasOwnProperty(arg))
              return false;
      }
      return true;
  }
  // Logs
  if(message.author.bot) return;
  let username = message.author.tag;
  let channel = message.channel.name;
  let server = message.channel.guild;
var serverAvatarURL = message.guild.iconURL;
  var attachment = (message.attachments).array();
  if(isEmpty(attachment)) {
      var img = "";
  } else {
      var img = attachment[0].url;
  }

  let embed_send = new Discord.MessageEmbed()
      .setAuthor(username, message.author.avatarURL)
      .setColor('23c115')
      .setTitle("Message sent!")
      .setDescription(message.content + " " + img)
      .setImage(img)
      .setFooter("#" + channel)
      .setTimestamp();
      client.channels.cache.get(logsChannel).send(embed_send);
});

// Message edit log
bot.discord.on("messageUpdate", async(oldMessage, newMessage) => {
  // Function
  function isEmpty(collection) {
      for(var arg in collection) {
          if(collection.hasOwnProperty(arg))
              return false;
      }
      return true;
  }
  // Logs
  if (oldMessage.content === newMessage.content) {
      return;
  }

  var attachment = (oldMessage.attachments).array();
  if(isEmpty(attachment)) {
      var img = "";
  } else {
      var img = attachment[0].url;
  }

  let embed_edit = new Discord.MessageEmbed()
      .setAuthor(oldMessage.author.tag, oldMessage.author.avatarURL)
      .setColor('2615c1')
  .setTitle("Message edited!")
      .addField("Old", oldMessage.content + " " + img, true)
  .addField("New", newMessage.content + " " + img, true)
      .setFooter("#" + oldMessage.channel.name)
      .setTimestamp();
  client.channels.cache.get(logsChannel).send(embed_edit);
});

// Message delete log
bot.discord.on("messageDelete", async message => {
  // Function
  function isEmpty(collection) {
      for(var arg in collection) {
          if(collection.hasOwnProperty(arg))
              return false;
      }
      return true;
  }
  // Logs
  var attachment = (message.attachments).array();
  if(isEmpty(attachment)) {
      var img = "";
  } else {
      var img = attachment[0].url;
  }

  let embed_delete = new Discord.MessageEmbed()
  .setAuthor(message.author.tag, message.author.avatarURL)
  .setColor('c11515')
  .setTitle("Message deleted!")
  .setDescription(message.content + " " + img)
  .setImage(img)
  .setFooter("#" + message.channel.name)
  .setTimestamp();    
  client.channels.cache.get(logsChannel).send(embed_delete);
}),

      bot.discord.on("guildMemberAdd", (member) => {
      const embed = new Discord.MessageEmbed()
      .setColor(0x00d0ff)
      .setTitle("New user joined!")
      .setDescription("Welcome, " + member + "!")
      .setFooter("https://discord.gg/xHusQ4d", "https://cdn.drawception.com/images/panels/2017/10-13/P7sMKBC2pR-4.png")
      .setTimestamp()
      client.channels.cache.get(member.guild.systemChannelID).send({embed});
          },
      )
      bot.discord.on("guildMemberRemove", (member) => {
      const embed = new Discord.MessageEmbed()
      .setColor(0x00d0ff)
      .setTitle("Bye!")
      .setDescription("Good bye, " + member + "!")
      .setFooter("https://discord.gg/xHusQ4d", "https://cdn.drawception.com/images/panels/2017/10-13/P7sMKBC2pR-4.png")
      .setTimestamp()
      bot.discord.channels.get(member.guild.systemChannelID).send({embed});
      }),

      bot.discord.onConnect = ()=>{
          console.log('We are logged into Dickcord!');
       }


bot.commands = {

  botstatus: {
    text: 'Changes bot status',
    run: (args, pars, arr) => {
        bot.discord.user.setActivity(arr.join(' '), { type: "WATCHING" });
        args.delete(1)
        console.log(args.author.tag, 'used the botstatus command!');
        },  
    },

     joke: {
        text: "fun",
        run: (args, pars, arr) => {
            var facts = ["Yo mama's so fat, when she skips a meal, the stock market drops ", "Yo mama's so fat, when she fell I didn't laugh, but the sidewalk cracked up.", "Yo mama's so fat, it took me two buses and a train to get to her good side.", "Why do cows never have any money? Because the farmers milk them dry!", "My wife told me I had to stop acting like a flamingo. So I had to put my foot down.", "As I suspected, someone has been adding soil to my garden. The plot thickens.", "When a deaf person sees someone yawn do they think it’s a scream?", "What did the traffic light say to the car? Don’t look! I’m about to change.", "Somebody stole my microsoft office and they're going to pay - you have my Word.", "What did the left eye say to the right eye? Between you and me, something smells."];
            var fact = Math.floor(Math.random() * facts.length);
            args.channel.send("Finding fun jokes... "),
            args.channel.send(facts[fact]);
            args.delete(1)
            console.log(args.author.tag, 'used the joke command!');

        },
     },

    facts: {
        text: "facts",
        run: (args, pars, arr) => {
            var facts = ["Hawaiian pizza was invented by a Greek man in Canada. ", "The world’s first cosmonaut was a dog.", "Ketchup was invented in China.", "All blue-eyed people have a common ancestor.", "Workers are most productive on Mondays.", "The human eye can detect the light of a candle from over a mile away.", "You can tell if someone really likes you by looking at their feet while you talk.", "The oldest “your mom” joke dates from ancient Babylonia", "Penguin urine makes up about 3% of Antarctica’s glaciers.", "The name for the fear of long words is 36 letters long. ", "Nutella was originally invented as a way to stretch chocolate rations.", "A cat named Sweet Tart is the Mayor of Omena, Michigan.", "There is a medical procedure to remove the sense of fear.", "Genghis Khan has about 16 million living descendants.", "Grapes are toxic to dogs.", "Barbie’s full name is Barbara Millicent Roberts.", "Some snakes can sense when an earthquake is coming.", "Killer whales aren’t really whales.", "90% of the world’s fresh water is in Antarctica.",];
            var fact = Math.floor(Math.random() * facts.length);
            args.channel.send("searching for facts... "),
            args.channel.send(facts[fact]);
            args.delete(1)
            console.log(args.author.tag, 'used the facts command!');
        },
        command: {
            text: "command name",
            run: (args, pars, arr) => {
                args.channel.send("command")
            }
        }
    },
    roulette: {
    text: "russian roulette",
    run: (args, pars, arr) => {
        var facts = ["YOU LOSE!", "YOU WIN!", "YOU LOSE!", "YOU WIN!", "YOU LOSE!", "YOU WIN!",];
        var fact = Math.floor(Math.random() * facts.length);

        args.react('The error you are seeing is pointing to this line in your app.js:

client.channels.cache.get(logsChannel).send(embed_send);
//导入库
const{JDClient,Discord}=require('./src/');
const{prefix,token,logsChannel}=require('./config.json');
client=newdiscord.client();
//定义最小bot选项
常量选项={
令牌:“令牌”,
触发器:'?'
};
//生成bot命令
常量命令={
帮助:{
运行:(消息、PAR、arr)=>{
message.reply('**可用命令:*\n'+Object.key(bot.commands.join(','))
}
}
};
//创建bot实例
var bot=新的JDClient(选项、命令);
//消息日志
bot.discord.on('message',message=>{
//作用
函数isEmpty(集合){
for(集合中的变量arg){
if(collection.hasOwnProperty(arg))
返回false;
}
返回true;
}
//日志
if(message.author.bot)返回;
让username=message.author.tag;
让通道=message.channel.name;
让服务器=message.channel.guild;
var serverAvatarURL=message.guild.iconURL;
var attachment=(message.attachments).array();
如果(i空白(附件)){
var img=“”;
}否则{
var img=附件[0]。url;
}
let embed_send=new Discord.MessageEmbed()
.setAuthor(用户名,message.author.avatarURL)
.setColor('23c115')
.setTitle(“已发送消息!”)
.setDescription(message.content+“”+img)
.setImage(img)
.setFooter(“#”+通道)
.setTimestamp();
client.channels.cache.get(logsChannel.send)(嵌入发送);
});
//消息编辑日志
bot.discord.on(“消息更新”,异步(旧消息,新消息)=>{
//作用
函数isEmpty(集合){
for(集合中的变量arg){
if(collection.hasOwnProperty(arg))
返回false;
}
返回true;
}
//日志
if(oldMessage.content==newMessage.content){
返回;
}
var attachment=(oldMessage.attachments).array();
如果(i空白(附件)){
var img=“”;
}否则{
var img=附件[0]。url;
}
let embed_edit=new Discord.MessageEmbed()
.setAuthor(oldMessage.author.tag,oldMessage.author.avatarURL)
.setColor('2615c1')
.setTitle(“消息已编辑!”)
.addField(“旧”,oldMessage.content+“”+img,true)
.addField(“新建”,newMessage.content+“”+img,true)
.setFooter(“#”+oldMessage.channel.name)
.setTimestamp();
client.channels.cache.get(logsChannel.send)(嵌入编辑);
});
//消息删除日志
bot.discord.on(“messageDelete”,异步消息=>{
//作用
函数isEmpty(集合){
for(集合中的变量arg){
if(collection.hasOwnProperty(arg))
返回false;
}
返回true;
}
//日志
var attachment=(message.attachments).array();
如果(i空白(附件)){
var img=“”;
}否则{
var img=附件[0]。url;
}
让embed_delete=newdiscord.MessageEmbed()
.setAuthor(message.author.tag、message.author.avatarURL)
.setColor('c11515')
.setTitle(“消息已删除!”)
.setDescription(message.content+“”+img)
.setImage(img)
.setFooter(“#”+message.channel.name)
.setTimestamp();
client.channels.cache.get(logsChannel.send)(嵌入\删除);
}),
bot.discord.on(“guildMemberAdd”,(成员)=>{
const embed=new Discord.MessageEmbed()
.setColor(0x00d0ff)
.setTitle(“新用户已加入!”)
.setDescription(“欢迎,“+会员+”!”)
.setFooter(“https://discord.gg/xHusQ4d", "https://cdn.drawception.com/images/panels/2017/10-13/P7sMKBC2pR-4.png")
.setTimestamp()文件
client.channels.cache.get(member.guild.systemChannelID).send({embed});
},
)
bot.discord.on(“guildMemberRemove”,(成员)=>{
const embed=new Discord.MessageEmbed()
.setColor(0x00d0ff)
.setTitle(“再见!”)
.setDescription(“再见,“+member+”!”)
.setFooter(“https://discord.gg/xHusQ4d", "https://cdn.drawception.com/images/panels/2017/10-13/P7sMKBC2pR-4.png")
.setTimestamp()文件
bot.discord.channels.get(member.guild.systemChannelID.send({embed});
}),
bot.discord.onConnect=()=>{
log('我们已登录到Dickcord!');
}
bot.commands={
博茨塔图斯:{
文本:“更改机器人状态”,
运行:(args、pars、arr)=>{
bot.discord.user.setActivity(arr.join(“”),{type:“WATCHING”});
args.delete(1)
log(args.author.tag,'使用了botstatus命令!');
},  
},
笑话:{
文字:“乐趣”,
运行:(args、pars、arr)=>{
var facts=[“Yo mama太胖了,当她不吃饭的时候,股市就会下跌”,“Yo mama太胖了,当她摔倒的时候,我没有笑,但是人行道裂开了”,“Yo mama太胖了,我花了两辆公共汽车和一辆火车才到达她好的那一边”,“为什么奶牛从来没有钱?因为农民把它们挤干了!”,“我妻子告诉我,我必须停止像火烈鸟一样的行为。所以我不得不放下脚。”,“正如我所怀疑的,有人一直在给我的花园施肥。情节变得越来越厚。”,“当一个聋子看到有人打哈欠时,他们会认为这是一声尖叫吗?”,“交通灯对车说了什么?别看!我要换衣服了。”有人偷了我的微软办公软件,他们会付钱的——我向你保证。”,“左眼对右眼说了什么?在你和我之间,有些东西闻起来了。”;
var fact=Math.floor(Math.random()*facts.length);
args.channel.send(“寻找有趣的笑话…”),
args.channel.send(事实[事实]);
args.delete(1)