在javascript中更改discord bot的前缀
我正在制作机器人,并希望有一个前缀来调用机器人 . 当你没有组时,它可以改变 . 但是如何更改前缀“!”当我使用群组?
我的主要代码
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;
2 years ago
我知道这有点晚了,但是
用那个替换第二和第三行 . 您可以将:D更改为您想要的任何前缀 .