【发布时间】:2019-04-29 09:50:47
【问题描述】:
总的来说,我对编码还很陌生,但我对事物的掌握得很好。我正在为 Discord 编写一个机器人,我需要的主要命令是从 5 开始倒计时。例如,有人说 !startqueue 它将从 5 开始计数,一旦达到零就会停止。如果不必发送单独的消息,我将能够在其他地方找到答案。我不知道这是否有意义,所以如果需要,请要求澄清。
这是控制 !roll 功能的代码。它会从 1 到 6 滚动一个随机数(这只是为了说明如何编写代码以查找有效的不和谐命令)。
const commando = require('discord.js-commando');
class DiceRollCommand extends commando.Command {
constructor(client) {
super(client, {
name: 'roll',
group: 'random',
memberName: 'roll',
description: 'Rolls a die' ,
});
}
async run(message, args) {
var roll = Math.floor(Math.random() * 6) + 1;
message.reply("You Rolled a " + roll);
}
}
module.exports = DiceRollCommand;
下面是我为 !queue 命令设置的基本代码
const commando = require('discord.js-commando');
class QueueCommand extends commando.Commando {
constructor(client) {
super(client, {
name: 'Queue Start',
group: 'random',
memberName: 'startQueue',
description: 'Starts the queue' ,
});
}
}
这只是我所拥有的其余代码,您可以看到我也看到的所有代码。
const commando = require('discord.js-commando') ;
const bot = new commando.CommandoClient();
bot.registry.registerGroup('random', 'Random') ;
bot.registry.registerDefaults();
bot.registry.registerCommandsIn(__dirname + "/commands") ;
bot.login('no token');
【问题讨论】:
标签: javascript discord