所以我收到一条奇怪的错误消息,如下所示:
SyntaxError: Unexpected identifier
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 /home/remix867/bot_commando/node_modules/require-all/index.js:52:46
所以它以前工作过,但我已经安装了所有依赖项。Javascript 代码如下所示:
const { Command } = require('discord.js-commando');
const { oneLine } = require('common-tags');
const { RichEmbed } = require('discord.js');
const config = require('../../config.json');
var quotes = config.quotes;
module.exports = class EchoCommand extends Command {
constructor(client) {
super(client, {
name: 'quote',
group: 'quote',
memberName: 'quote',
description: 'Echoes a random Quote.',
details: oneLine`,
I'll say out a quote`,
examples: ['quote']
});
}
const avatarURL = message.author.avatar ? message.author.avatarURL: 'https://discordapp.com/assets/0e291f67c9274a1abdddeb3fd919cbaa.png';
const embed = new Discord.RichEmbed()
.setAuthor(`${message.author.tag}`, `${avatarURL}`);
.setColor(0x0000FF);
.setDescription(quotes[Math.floor(Math.random() * quotes.length)]);
.setTimestamp();
await message.channel.send({
embed
});
};
Config.json 只是一个简单的 json,其中存储了所有随机报价。
问题应该在我定义头像 URL 的第 20 行,但如果我删除这一行,它会在另一行显示其他内容,并出现完全相同的错误。
提前致谢 :)