discord.js SyntaxError:无效或意外的令牌

时间:2019-11-17 12:42:08

标签: discord.js

我知道之前曾有人问过这个问题,但是我找不到解决方案,或者为什么 我的机器人正在这样做,我对此没有任何解决方案。 如果您能帮助我,我将非常感激。

SyntaxError:无效或意外的令牌

[一些Wikipedia随机垃圾,因为我无法发布[请添加一些详细信息]

IP地址以人类可读的符号编写和显示,例如IPv4中的172.16.254.1,以及IPv6中的2001:db8:0:1234:0:567:8:1。通过在地址上添加有效位数后缀(例如192.168.1.15/24)来在CIDR表示法中指定地址的路由前缀的大小,该地址等于历史上使用的子网掩码255.255.255.0。

IP地址空间由Internet号码分配机构(IANA)以及五个在其指定地区负责分配给本地Internet注册表(例如Internet服务提供商)的区域性Internet注册表(RIR)进行全局管理用户。 IANA将IPv4地址以大约1680万个地址的块的形式分配给RIR,但自2011年以来在IANA级别上已经用尽。只有一个RIR仍然可以提供非洲的本地分配。[6]

网络管理员为连接到网络的每个设备分配IP地址。此类分配可以基于静态(固定或永久)或动态进行,具体取决于网络惯例和软件功能。

const Discord = require("discord.js");
const bot = new Discord.Client();
const prefix = "/";
var fs = require("fs");
var lineReader = require("line-reader");
var async = require("async");
const firstline = require("firstline");
const generated = new Set();
bot.on("ready", () => {
  console.log(`Logged in as ${bot.user.tag}!`);
});

bot.on("message", message => {
  if (message.channel.id === "INSERT_CHANNEL_ID") { //channel id here
    if (message.author.bot) return;
    var command = message.content
      .toLowerCase()
      .slice(prefix.length)
      .split(" ")[0];

    if (command === "test") {
      message.channel.send("Test done, bot's working");
    }

    if (command === "gen") {
      if (generated.has(message.author.id)) {
        message.channel.send(
          "Wait 15 minute before generating another account!. - " +
            message.author
        );
      } else {
        let messageArray = message.content.split(" ");
        let args = messageArray.slice(1);
        if (!args[0])
          return message.reply("Please, specify the service you want!");
        var fs = require("fs");
        const filePath = __dirname + "/" + args[0] + ".txt";

        fs.readFile(filePath, function(err, data) {
          if (!err) {
            data = data.toString();
            var position = data.toString().indexOf("\n");
            var firstLine = data.split("\n")[0];
            message.author.send(firstLine);
            if (position != -1) {
              data = data.substr(position + 1);
              fs.writeFile(filePath, data, function(err) {
                const embed = {
                  title: "Account Generated!",
                  description: "Check your dm for the account's information!",
                  color: 8519796,
                  timestamp: "2019-04-04T14:16:26.398Z",
                  footer: {
                    icon_url:
                      "https://cdn.discordapp.com/avatars/530778425540083723/7a05e4dd16825d47b6cdfb02b92d26a5.png",
                    text: "Buy discord accounts from Mental#1424"
                  },
                  thumbnail: {
                    url:
                      "http://www.compartosanita.it/wp-content/uploads/2019/02/right.png"
                  },
                  author: {
                    name: "Account Generator",
                    url: "https://discordapp.com",
                    icon_url: bot.displayAvatarURL
                  },
                  fields: []
                };
                message.channel.send({ embed });
                generated.add(message.author.id);
                setTimeout(() => {
                  // Removes the user from the set after a minute
                  generated.delete(message.author.id);
                }, 150000);
                if (err) {
                  console.log(err);
                }
              });
            } else {
              message.channel.send(
                "Sorry, there isn't any account avaible for that service!"
              );
            }
          } else {
            message.channel.send(
              "Sorry, that service doesen't exists on our database"
            );
          }
        });
      }
    }

    if (command === "help") {
      const embed = {
        title: "Anarchy Account Generator",
        description: "Informations",
        color: 8519796,
        timestamp: "2019-04-04T14:16:26.398Z",
        footer: {
          icon_url:
            "https://cdn.discordapp.com/avatars/530778425540083723/7a05e4dd16825d47b6cdfb02b92d26a5.png",
          text: "Buy discord accounts from Mental#1424"
        },
        thumbnail: {
          url:
            "http://www.compartosanita.it/wp-content/uploads/2019/02/right.png"
        },
        author: {
          name: "Account Generator",
          url: "https://discordapp.com",
          icon_url: bot.displayAvatarURL
        },
        fields: [
          {
            name: "Bot made by",
            value: "Mental#1424"
          }
        ]
      };
      message.channel.send({ embed });
    }
    if (command === "restock") {
      let messageArray = message.content.split(" ");
      let args = messageArray.slice(1);
      if (!message.member.hasPermission("ADMINISTRATOR"))
        return message.reply("Sorry, you can't do it, you are not an admin!");
      if (!args[0])
        return message.reply(
          "Please, specify the service you want to restock!"
        );
      message.channel.send(
        "@everyone " +
          "**" +
          args[0] +
          "**" +
          " has been restocked by " +
          "<@" +
          message.author.id +
          ">"
      );
    }
  }
});

bot.login("NoTokenForU");

1 个答案:

答案 0 :(得分:0)

IP地址与您的机器人令牌无关,错误消息表示您的Bot令牌不正确。

请确保您正确地复制了令牌,如果您还没有令牌,请访问Discord Developer Portal