【发布时间】:2020-10-06 18:42:35
【问题描述】:
我希望能够获得用户的响应。问题是我不知道如何确保我得到特定用户的响应而不是其他人的响应。我怎么能做到这一点? 例如询问最小和最大数字,然后从它们之间获取一个随机数。
这是我尝试过的:
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '-';
client.on('message', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === random) {
message.channel.send('Please enter your starting number')
channel.fetchMessages({ limit: 1 }).then(messages => {
let min = messages.first();
})
message.channel.send('Please enter your limit')
channel.fetchMessages({ limit: 1 }).then(messages => {
let max = messages.first();
})
getRndInteger(min,max)
function getRndInteger(min, max) {
console.log(Math.floor(Math.random() * (max - min + 1) ) + min);
}
}
});
我希望它等到激活它的用户说出一个数字(它也可能有超时)。
【问题讨论】:
标签: node.js discord discord.js