简体   繁体   English

Discord.js v12 | 从服务器删除邀请

[英]Discord.js v12 | Delete invites from server

I would my bot to delete invites created on my server with a command.我希望我的机器人使用命令删除在我的服务器上创建的邀请。 I know I can take all invites with message.guild.fetchInvites().then() , but how do I make my lambda to delete all invites?我知道我可以使用message.guild.fetchInvites().then()接受所有邀请,但是如何让我的 lambda 删除所有邀请? Thank you in advance and excuse me If it is a dumb question!提前谢谢你,如果这是一个愚蠢的问题,请原谅!

You started off well, but here is how to loop through them all and delete them one by one:你开始得很好,但这里是如何遍历它们并一一删除它们:

message.guild.invites.fetch().then(invites => {
  invites.each(i => i.delete())
})

Warning: If there are a lot of invites, you may get ratelimited.警告:如果有很多邀请,您可能会受到速率限制。 You can add a "sleep" function to fix this您可以添加“睡眠” function 来解决此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM