【发布时间】:2019-05-24 19:28:50
【问题描述】:
我在 JS 中有一段代码:
var commands = require('commands.json');
module.exports = class CatCommand extends commando.Command {
constructor(client) {
super(client, {
name: 'cat',
group: 'fun',
aliases: commands[this.group][this.name].aliases || [utils.translate(this.name)],
memberName: name,
description: commands[this.group][this.name].description || 'No description',
examples: commands[this.group][this.name].usages || ['No examples'],
throttling: {
usages: 2,
duration: 5
}
});
}
async run(message) {}
}
我需要使用变量name 和group 作为commands' 键。最好的方法是什么?
【问题讨论】:
-
无法引用“建设中”对象字面量的字段。如果您需要使用这些值,请将它们设为单独声明的变量的值。
-
好的,我试试。谢谢!
标签: javascript node.js discord.js commando