【发布时间】:2017-07-08 21:52:03
【问题描述】:
所以我正在开发一个使用 discord.js 的 Discord Bot,discord.js 是 Discord API 的 node.js 包装器。基本上代码是这样工作的:
/*
A ping pong bot, whenever you send "ping", it replies "pong".
*/
// import the discord.js module
const Discord = require('discord.js');
// create an instance of a Discord Client, and call it bot
const bot = new Discord.Client();
// the token of your bot - https://discordapp.com/developers/applications/me
const token = 'your bot token here';
// create an event listener for messages
bot.on('message', message => {
// if the message is "ping",
if (message.content === 'ping') {
// send "pong" to the same channel.
message.channel.sendMessage('pong');
}
});
bot.login(token);
但我的问题是,我怎样才能使用户只能使用冷却时间为 3 秒的“ping”命令。为此,您需要用户 ID,如果您想知道,那将是 message.author.id。提前致谢。
【问题讨论】:
标签: javascript node.js discord