Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Discord.js批量删除命令_Javascript_Discord_Bots_Discord.js - Fatal编程技术网

Javascript Discord.js批量删除命令

Javascript Discord.js批量删除命令,javascript,discord,bots,discord.js,Javascript,Discord,Bots,Discord.js,我正在尝试向我的bot添加批量删除命令,但当我键入要删除的邮件数时,出现以下错误: TypeError [MESSAGE_BULK_DELETE_TYPE]: The messages must be an Array, Collection, or number. 代码如下: 否则,如果isVallidCommnadmessage,请删除{ 如果!message.member.hasPermission'KICK_MEMBERS'返回message.channel.send您无法删除邮件:/

我正在尝试向我的bot添加批量删除命令,但当我键入要删除的邮件数时,出现以下错误:

TypeError [MESSAGE_BULK_DELETE_TYPE]: The messages must be an Array, Collection, or number.
代码如下:

否则,如果isVallidCommnadmessage,请删除{ 如果!message.member.hasPermission'KICK_MEMBERS'返回message.channel.send您无法删除邮件:/; if!args[0]返回消息。回复您要删除多少消息限制99; ifparseIntargs[0]>99条返回消息。回复您不能一次删除超过99条消息!!; message.channel.bulkDeleteparseIntargs[0]+1。然后message=>{ message.channel.send`Cleared${args[0]}messages!`。然后message=>message.delete{timeout:300}; 消息,反应
const deleteCount = parseInt(args[0], 10);

if (!deleteCount || deleteCount < 1 || deleteCount > 100) return;

message.channel.bulkDelete(deleteCount + 1).catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
要使用parseInt,必须添加小数点,因此10->parseIntargs[0],10;。 我上面的代码片段运行良好