【发布时间】:2023-03-20 21:06:01
【问题描述】:
if (!args[1]) return message.channel.send('You need to specify a person!')
if (!args[2]) return message.channel.send('Please specify a time for how long the ban council will last.')
var tim = args[2]
const sweden = message.mentions.users.first()
message.react('????').then(() => message.react('????'))
const mappo = ['????', '????']
if (!args[1]) return message.channel.send('Please specify a person!')
if(message.guild){ //this will check if the command is being called from a server
const embad = new Discord.MessageEmbed()
.setTitle('Ban Council')
.addField('The Convicted:', `${sweden.tag}`)
.addField('Rules:', 'Vote on whether the convicted is guilty or not with the prompted reactions. The ban will end automatically in 5 seconds.')
message.channel.send(embad)
setTimeout(function(){
if(sweden){
const lyft = message.guild.member(sweden)
if(lyft){
if(message.reactions.cache.map(r => `${'????'} ${r.users.cache.size}`)[0] > message.reactions.cache.map(r => `${'????'} ${r.users.cache.size}`)[1]){
lyft.ban({ ression: 'Majority has exiled you from server. '}).then(() => {
message.reply(`The user ${december.tag} was banned as a result of a majority vote.`)
})
} else {
message.channel.send('The ban was cancelled.')
}
}else{
message.reply('The user is not in this server.')
}
}else{
message.reply('You need to specify a person!')
}
}, tim)
} else {
message.channel.send('Banning does not work here!')
}
它在实际有机会接受输入之前发送“Ban cancelled”。我已经尝试过收集器,但由于 max: 部分,它不起作用,我该如何解决这个问题? (也不会返回错误)
这是一个案例。 (附加到我得到的反馈)
【问题讨论】:
-
另外,顶部有一个案例,虽然它只是说案例'ban':
-
尝试使用 awaitReactions
-
@Pepe_Worm : awaitReactions 只在我没有的异步函数中工作。
-
它适用于任何函数,它只是一个承诺,如果你使用 await 那么它需要在一个异步函数中
-
@Karizma 所以你建议我重写它吗?效果很好,只是需要时间
标签: node.js discord.js