[英]discord.js unlimited purge command
Is there a way to make this better?有没有办法让它变得更好? I'm trying to make unlimited purge command... But it seems like message.channel.messages.cache only gets message the time you used it and I don't really know how to make it better.
我正在尝试制作无限制的清除命令...但似乎 message.channel.messages.cache 仅在您使用它时才收到消息,我真的不知道如何使它变得更好。 The bot will just lag for a long time... and cycle wont break because of that.
机器人只会滞后很长时间......并且循环不会因此而中断。
for (let i = 1; i <= amount/100; i++) {
let messagecount = message.channel.messages.cache.size
if(messagecount<=5){
console.log("break")
break}
message.channel.bulkDelete(100)
}
}
According to the Discord API docs , you can't delete messages older than 2 weeks through the Discord API, and neither can you with more than 100 messages. According to the Discord API docs , you can't delete messages older than 2 weeks through the Discord API, and neither can you with more than 100 messages. This is not a limitation you should/would want to break, and you may encounter the risk of being ratelimited .
这不是您应该/想要打破的限制,您可能会遇到被 ratelimited 的风险。 Of course, you could loop this, as you tried, but the ratelimit is still here.
当然,你可以循环这个,就像你尝试的那样,但速率限制仍然在这里。 If I were you and wanted to delete the messages this bad, I would either call the command multiple times, or loop the
bulkDelete
with a cooldown (2000ms would be enough, I guess?).如果我是你并且想删除这么糟糕的消息,我会多次调用该命令,或者
bulkDelete
使用冷却时间(我猜 2000 毫秒就足够了?)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.