简体   繁体   中英

Discord.js Invalid Form Body limit: int value should be less than or equal to 100.error when using bulkDelete()

So I got this as the command code:

    if(!args[0]){
        message.channel.send(client.cmdlines.wrongUsage);
    }else if(args[1]){
        message.channel.send(client.cmdlines.wrongUsage);
    }else{
        if(message.member.hasPermission('ADMINISTRATOR')){
            if(!isNaN(args[0])){
                message.channel.bulkDelete(args[0]+1).then(msg => {
                    message.channel.send(`Deleted ${args[0]} messages.`).then(msg => msg.delete({ timeout: 3000 })).catch(e => console.log(e));
                });
            }else{
                message.channel.send(client.cmdlines.wrongUsage);
            }
        }else{
            message.channel.send(client.cmdlines.missingPerms);
        }
    }
}

and for some reason im getting the: Invalid Form Body limit: int value should be less than or equal to 100. error. Does somebody know what possible the problem could be

It's in the error.. discord.js doesn't allow you to bulk delete more than 100 messages at a time. Run a function to determine how many times you would need to cycle through to delete all the desired messages ( Math.floor(args[0]/100 ). Then, you'll need to delete the number of messages left from the 100. ( args[0] - Math.floor(args[0])*100 )

Cycle through deleting 100 messages the first value of times, then after delete messages the second value.

Oh, and make sure to parse args[0] into an int, first

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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