admin管理员组文章数量:1025457
if there's messages over 14 days old and some that aren't 14 days old it does not delete the messages that aren't 14 days old and it sends an error is there a way to delete the messages that are not over 14 days old and leave the ones that are over 14 days old if you can't then can you help me make it stop sending an error and make it send a message saying "You can only bulk delete messages that are under 14 days old." in the channel instead of it showing a error in the console thanks.
const { Message } = require("discord.js");
const Client = require("../structures/Client");
module.exports = {
name: `clear`,
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
const msg = message;
var amt = parseInt(args[0], 10);
if(message.member.hasPermission(['MANAGE_MESSAGES'])) {
if(!amt) {
msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
} else {
if(amt > 100) {
return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per mand` }))
} else {
if(amt == 100) {
msg.channel.bulkDelete(amt);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
} else {
msg.channel.bulkDelete(amt + 1);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
}
}
}
} else {
if(message.member.hasPermission(['ADMINISTRATOR'])) {
if(!amt) {
msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
} else {
if(amt > 100) {
return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per mand` }))
} else {
if(amt == 100) {
msg.channel.bulkDelete(amt);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
} else {
msg.channel.bulkDelete(amt + 1);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
}
}
}
} else {
msg.channel.send(client.embed({ description: `${msg.author.username}! You do not have permission to run that mand.`}));
}
}
},
timeout: 1500
}
if there's messages over 14 days old and some that aren't 14 days old it does not delete the messages that aren't 14 days old and it sends an error is there a way to delete the messages that are not over 14 days old and leave the ones that are over 14 days old if you can't then can you help me make it stop sending an error and make it send a message saying "You can only bulk delete messages that are under 14 days old." in the channel instead of it showing a error in the console thanks.
const { Message } = require("discord.js");
const Client = require("../structures/Client");
module.exports = {
name: `clear`,
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
const msg = message;
var amt = parseInt(args[0], 10);
if(message.member.hasPermission(['MANAGE_MESSAGES'])) {
if(!amt) {
msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
} else {
if(amt > 100) {
return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per mand` }))
} else {
if(amt == 100) {
msg.channel.bulkDelete(amt);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
} else {
msg.channel.bulkDelete(amt + 1);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
}
}
}
} else {
if(message.member.hasPermission(['ADMINISTRATOR'])) {
if(!amt) {
msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
} else {
if(amt > 100) {
return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per mand` }))
} else {
if(amt == 100) {
msg.channel.bulkDelete(amt);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
} else {
msg.channel.bulkDelete(amt + 1);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
}
}
}
} else {
msg.channel.send(client.embed({ description: `${msg.author.username}! You do not have permission to run that mand.`}));
}
}
},
timeout: 1500
}
Share
Improve this question
asked Oct 28, 2020 at 21:45
RareHyperIonRareHyperIon
111 silver badge4 bronze badges
1 Answer
Reset to default 4The messages that are bulk deletable in the Discord API are messages less than 14 days old. That is an API limitation, not the library limitation.
The library can filter out messages older than 14 days, like so.
message.channel.bulkDelete(number, true);
You need to set the filterOld parameter to true to automatically filter out old messages and not throw an error.
if there's messages over 14 days old and some that aren't 14 days old it does not delete the messages that aren't 14 days old and it sends an error is there a way to delete the messages that are not over 14 days old and leave the ones that are over 14 days old if you can't then can you help me make it stop sending an error and make it send a message saying "You can only bulk delete messages that are under 14 days old." in the channel instead of it showing a error in the console thanks.
const { Message } = require("discord.js");
const Client = require("../structures/Client");
module.exports = {
name: `clear`,
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
const msg = message;
var amt = parseInt(args[0], 10);
if(message.member.hasPermission(['MANAGE_MESSAGES'])) {
if(!amt) {
msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
} else {
if(amt > 100) {
return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per mand` }))
} else {
if(amt == 100) {
msg.channel.bulkDelete(amt);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
} else {
msg.channel.bulkDelete(amt + 1);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
}
}
}
} else {
if(message.member.hasPermission(['ADMINISTRATOR'])) {
if(!amt) {
msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
} else {
if(amt > 100) {
return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per mand` }))
} else {
if(amt == 100) {
msg.channel.bulkDelete(amt);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
} else {
msg.channel.bulkDelete(amt + 1);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
}
}
}
} else {
msg.channel.send(client.embed({ description: `${msg.author.username}! You do not have permission to run that mand.`}));
}
}
},
timeout: 1500
}
if there's messages over 14 days old and some that aren't 14 days old it does not delete the messages that aren't 14 days old and it sends an error is there a way to delete the messages that are not over 14 days old and leave the ones that are over 14 days old if you can't then can you help me make it stop sending an error and make it send a message saying "You can only bulk delete messages that are under 14 days old." in the channel instead of it showing a error in the console thanks.
const { Message } = require("discord.js");
const Client = require("../structures/Client");
module.exports = {
name: `clear`,
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
const msg = message;
var amt = parseInt(args[0], 10);
if(message.member.hasPermission(['MANAGE_MESSAGES'])) {
if(!amt) {
msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
} else {
if(amt > 100) {
return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per mand` }))
} else {
if(amt == 100) {
msg.channel.bulkDelete(amt);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
} else {
msg.channel.bulkDelete(amt + 1);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
}
}
}
} else {
if(message.member.hasPermission(['ADMINISTRATOR'])) {
if(!amt) {
msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
} else {
if(amt > 100) {
return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per mand` }))
} else {
if(amt == 100) {
msg.channel.bulkDelete(amt);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
} else {
msg.channel.bulkDelete(amt + 1);
msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m => { m.delete({ timeout: 3000 }); }).catch(err => { console.log(err); })
}
}
}
} else {
msg.channel.send(client.embed({ description: `${msg.author.username}! You do not have permission to run that mand.`}));
}
}
},
timeout: 1500
}
Share
Improve this question
asked Oct 28, 2020 at 21:45
RareHyperIonRareHyperIon
111 silver badge4 bronze badges
1 Answer
Reset to default 4The messages that are bulk deletable in the Discord API are messages less than 14 days old. That is an API limitation, not the library limitation.
The library can filter out messages older than 14 days, like so.
message.channel.bulkDelete(number, true);
You need to set the filterOld parameter to true to automatically filter out old messages and not throw an error.
本文标签: javascriptDiscordjsYou can only bulk delete messages that are under 14 days oldStack Overflow
版权声明:本文标题:javascript - Discord.js | You can only bulk delete messages that are under 14 days old - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745623938a2159745.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论