ReferenceError:尝试制作discord bot时未定义消息

时间:2018-06-02 22:22:38

标签: javascript node.js visual-studio discord discord.js

const Discord = require("discord.js");


const bot = new Discord.Client();

let prefix="!"

bot.on("ready", () => {
  bot.user.setStatus("idle");
console.log(`Demon Is Online`)


bot.on("ready", guild =>  {
bot.user.setActivity("!help | residing on " + bot.guilds.size + " Servers", ); 


bot.on("message", message => {
    if(message.author.bot) return;
    if(message.channel.type === "dm") return;

    let messageArray = message.content.split(" ");
    let command = messageArray[0];
    let args = messageArray.slice(1);

   if(!command.startsWith(prefix)) return;


    if(command === `${prefix}userinfo`) {
        let embed = new Discord.RichEmbed()
        .setAuthor(message.author.username)
        .setColor("#3498db")
        .setThumbnail( `${message.author.avatarURL}`)
        .addField("Name", `${message.author.username}#${message.author.discriminator}`)
        .addField("ID", message.author.id)
        message.reply("I've Sent Your User Info Through DM! ")
        message.channel.send({embed}); 
    }}); 
});

    if(command === `${prefix}help`) {
        let embed = new Discord.RichEmbed()
        .addField("!help", "gives you this current information")
        .setTitle("Help")
        .setColor("#3498db")
        .addField("!userinfo", "gives you info about a user(currently being worked on)")
        .addField("!serverinfo","gives you info about a server(currently working on it)") 
        .addField("link to support server","https://discord.gg/NZ2Zvjm")
        .addField("invite link for bot","https://discordapp.com/api/oauth2/authorize?client_id=449983742224760853&permissions=84993&scope=bot")


  message.reply("here's a list of commands that i'm able to do")
        message.channel.send({embed});
    }});
});
  funtion
    messageArray = message.content.split("");
    let command = messageArray[0];
        if(command === `${prefix}serverinfo`) {
            let embed = new Discord.RichEmbed()
            .setAuthor(message.author.username)
            .setColor("#3498db")
            .addField("Name", `${message.guild.name}`)
            .addField("Owner", `${message.guild.owner.user}`)
            .addField("Server ID" , message.guild.id)
            .addField("User Count", `${message.guild.members.filter(m => m.presence.status !== 'offline').size} / ${message.guild.memberCount}`)
            .addField("Roles", `${message.guild.roles.size}`);


            message.channel.send({embed});
         } 
        }
     });

bot.login("token goes here")

image 1 我正在尝试修复我的代码,但是在这样做的时候我把它搞砸了,而且我仍然是编码的noob / beginner,所以生病了我的错误,输出和代码希望有人可以在我决定在这里发布我的问题之前帮助我。我在没有获得太多帮助的情况下问服务器基本上但基本上学习如何编写我尝试使用代码学院的代码,但无论如何我们去了

0 个答案:

没有答案