disalbe purge
This commit is contained in:
parent
0881809db7
commit
7c5f6ec97f
2 changed files with 8 additions and 30 deletions
|
@ -1,22 +1,15 @@
|
||||||
exports.run = (client, message, args) => {
|
exports.run = (client, message, args) => {
|
||||||
|
const user = message.mentions.users.first();
|
||||||
const StaffRole = message.guild.roles.find("name", "Staff");
|
|
||||||
if (!StaffRole)
|
|
||||||
return console.log("The Staff role does not exist");
|
|
||||||
|
|
||||||
if (!message.member.roles.has(StaffRole.id))
|
|
||||||
return message.reply("Sick you thought");
|
|
||||||
|
|
||||||
if (!message.GuildMember.hasPermission())
|
|
||||||
return message.reply(" ");
|
|
||||||
|
|
||||||
const amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2])
|
const amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2])
|
||||||
if (!amount) return message.reply('Must specify an amount to delete!');
|
if (!amount) return message.reply('Must specify an amount to delete!');
|
||||||
|
if (!amount && !user) return message.reply('Must specify a user and amount, or just an amount, of messages to purge!');
|
||||||
message.channel.fetchMessages({
|
message.channel.fetchMessages({
|
||||||
limit: 100,
|
limit: 100,
|
||||||
}).then((messages) => {
|
}).then((messages) => {
|
||||||
messages = messages.filter(m => m.author.id).array().slice(0, amount);
|
if (user) {
|
||||||
|
const filterBy = user ? user.id : Client.user.id;
|
||||||
message.channel.bulkDelete(messages).catch(error => console.log(error.stack));
|
messages = messages.filter(m => m.author.id === filterBy).array().slice(0, amount);
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
message.channel.bulkDelete(messages).catch(error => console.log(error.stack));
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,15 +0,0 @@
|
||||||
exports.run = (client, message, args) => {
|
|
||||||
const user = message.mentions.users.first();
|
|
||||||
const amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2])
|
|
||||||
if (!amount) return message.reply('Must specify an amount to delete!');
|
|
||||||
if (!amount && !user) return message.reply('Must specify a user and amount, or just an amount, of messages to purge!');
|
|
||||||
message.channel.fetchMessages({
|
|
||||||
limit: 100,
|
|
||||||
}).then((messages) => {
|
|
||||||
if (user) {
|
|
||||||
const filterBy = user ? user.id : Client.user.id;
|
|
||||||
messages = messages.filter(m => m.author.id === filterBy).array().slice(0, amount);
|
|
||||||
}
|
|
||||||
message.channel.bulkDelete(messages).catch(error => console.log(error.stack));
|
|
||||||
});
|
|
||||||
};
|
|
Loading…
Reference in a new issue