xopbot
Version:
XOPBOT Is A Multipurpose Bot With Over 200+ Commands That Make You Love The Bot!
44 lines (43 loc) • 2.75 kB
JavaScript
const lineReplyNoMention = require('discord-reply');
const color = process.env.Color;
module.exports = {
name: 'clear',
permissions: ["MANAGE_MESSAGES"],
clientpermissions: ["MANAGE_MESSAGES", "SEND_MESSAGES", "EMBED_LINKS"],
cooldown: 4,
description: "Clear messages!",
async execute(client, message, cmd, args, Discord) {
try {
const aman = args[0];
if (!args[0]) {
const nopr = new Discord.MessageEmbed().setTimestamp().setColor(`${color}`).setAuthor(`${message.author.username}`, message.author.displayAvatarURL({ dynamic: true })).setDescription(`**\`(prefix)clear <number>\`**`)
return message.lineReplyNoMention({ embed: nopr })
}
if (isNaN(args[0])) {
const nonum = new Discord.MessageEmbed().setTimestamp().setColor(`${color}`).setAuthor(`${message.author.username}`, message.author.displayAvatarURL({ dynamic: true })).setDescription(`**\`${aman}\` Is Not A Number!**`)
return message.lineReplyNoMention({ embed: nonum })
}
if (args[0] > 100) {
const maxlen = new Discord.MessageEmbed().setTimestamp().setColor(`${color}`).setAuthor(`${message.author.username}`, message.author.displayAvatarURL({ dynamic: true })).setDescription(`**You Are Not Allowed To Delete More Than \`100\` Messages!**`)
return message.lineReplyNoMention({ embed: maxlen })
}
if (args[0] < 1) {
const minlen = new Discord.MessageEmbed().setTimestamp().setColor(`${color}`).setAuthor(`${message.author.username}`, message.author.displayAvatarURL({ dynamic: true })).setDescription(`**You Have To Delete At Least \`1\` Message!**`)
return message.lineReplyNoMention({ embed: minlen })
}
await message.channel.messages.fetch({ limit: args[0] }).then(messages => {
message.channel.bulkDelete(messages)
const success = new Discord.MessageEmbed().setTimestamp().setColor(`${color}`).setAuthor(`${message.author.username}`, message.author.displayAvatarURL({ dynamic: true })).setDescription(`**Successfully Deleted \`${messsages, size}\` Messages!**`)
message.lineReplyNoMention({ embed: success })
.then(message => {
setTimeout(() => message.delete(), 4000);
})
});
} catch (err) {
return message.lineReplyNoMention({ content: '**Cannot Delete Message Old Than 14 Days!**' })
.then(message => {
setTimeout(() => message.delete(), 6000);
})
}
}
}