修复Discord自我机器人

时间:2020-03-27 21:10:33

标签: javascript node.js

我真的在尝试解决此错误。我该如何解决?

C:\Users\yeet\node_modules\discord.js\src\client\Client.js:41
    } catch {
            ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\yeet\node_modules\discord.js\src\index.js:8:11)

机器人的源代码

const discord = require("discord.js")
const fs = require("fs");
const clc = require("cli-color");
const ConsoleTitle = require("node-bash-title");

const bot = new discord.Client({disableEveryone: true})

ConsoleTitle("TypicSelfBot version b1.0.0")

bot.on("ready", async () => {
    console.log(clc.red("Your current name is: ${bot.user.username}"))
    setTimeout( () => {
        console.log(clc.green("Ready to use"))
        console.log(clc.green("Prefix is -"))
        console.log(clc.green("Commands: -embed; More coming soon"))
    }, 200)
})
bot.on("message", async message => {
    if(message.content === "-embed")
    {
        let embed = new discord.RichEmbed()
        .setDescription("Made by TypicScripter on Roblox, Discord: Typic#0001 or TypicScripter#0001")
        .setFooter("This is a embed message - adding arguments soon")
    }
})

bot.login("") // Put your Discord token here. This wont log your token.

我想制造这个机器人,但是没人知道如何修复它。

1 个答案:

答案 0 :(得分:0)

关于我目前正在使用的一种机器人,我一直遇到同样的问题。对于当前的discord.js版本,这似乎是一个问题,因为用一个完整的旧版本替换 node_modules 文件夹似乎可以解决问题。

尝试用此文件夹替换 node_modules 文件夹。这为我解决了问题

https://drive.google.com/file/d/1Us8qO-_jUkRRx6oUpEasvsflRAMdko6R/view?usp=sharing