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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745623939a4636690.html
评论列表(0条)