我正在制作机器人,并希望有一个前缀来调用机器人 . 当你没有组时,它可以改变 . 但是如何更改前缀“!”当我使用群组?
我的主要代码
const commando = require('discord.js-commando');
const bot = new commando.Client();
const prefix = ":D";
bot.registry.registerGroup('random', 'Random');
bot.registry.registerCommandsIn(__dirname + "/commands");
bot.login('Botcode'
);
我的组
const commando = require('discord.js-commando');
class DiceRollCommand extends commando.Command {
constructor(client) {
super(client, {
name: 'roll',
group: 'random',
memberName: 'roll',
description: 'Roll a die'
});
}
async run(message, args){
var roll = Math.floor(Math.random() * 6) + 1;
message.reply("You rolled a " + roll);
}
}
module.exports = DiceRollCommand;
4 回答
您将不得不在node_module目录中编辑'client.js' . \ node_modules \ discord.js,突击队的\ src \ client.js
这是第28行:
希望这有帮助!
你不必使用
const bot = new commando.Client({ commandPrefix: prefix });
你可以像这样使用一行:bot.commandPrefix = "YOUR PREFIX"
我不是专家所以不要试图证明我的代码有问题!我知道这有点晚了,但是
用那个替换第二和第三行 . 您可以将:D更改为您想要的任何前缀 .