尝试让漫游器向所有成员添加角色,然后在说一些文本后将其删除

时间:2019-10-23 03:00:39

标签: javascript node.js discord.js

我正在使用discord.js
因此,我想创建一个向所有人赋予“冻结”角色的机器人,然后在10秒钟后将其删除。 我不断收到一个addrole和removerole错误,并开始让我感到沮丧。

这是我们的代码

if(command === "stop"){
if(!message.member.roles.some(r=>["Owner"].includes(r.name)) )
    return message.reply("Sorry, you don't have permissions to use this!");

let role = message.guild.roles.find(r => r.name == 'Frozen')

if (!role) return message.channel.send(`**${message.author.username}**, role not found`)

client.setMaxListeners(Infinity)
message.guild.members.filter(m => !m.user.bot).forEach(member => member.addRole(role))
message.channel.send(`**ZA WARUDO**`)

setTimeout(function(){ 
    message.channel.send(`**Step**`)
}, 3 * 1000);

setTimeout(function(){ 
    message.channel.send(`**Step**`)
}, 6 * 1000);

setTimeout(function(){ 
    message.channel.send(`**Step**`)
}, 9 * 1000);

setTimeout(function(){ 
    message.guild.members.filter(m => !m.user.bot).forEach(member => member.removeRole(role))
    message.channel.send(`**Time Shall now continue**`)
}, 10 * 1000);

}

所以我需要帮助

这是我得到的重复多次的错误代码

(node:23652) UnhandledPromiseRejectionWarning: Error: Adding the role timed out.
    at timeout.client.setTimeout (D:\Documents\Monika_Bot\node_modules\discord.js\src\client\rest\RESTMethods.js:514:16)
    at Timeout.setTimeout [as _onTimeout] (D:\Documents\Monika_Bot\node_modules\discord.js\src\client\Client.js:433:7)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:23652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 60)
(node:23652) UnhandledPromiseRejectionWarning: Error: Removing the role timed out.
    at timeout.client.setTimeout (D:\Documents\Monika_Bot\node_modules\discord.js\src\client\rest\RESTMethods.js:540:16)
    at Timeout.setTimeout [as _onTimeout] (D:\Documents\Monika_Bot\node_modules\discord.js\src\client\Client.js:433:7)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:23652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 61)

0 个答案:

没有答案