discord js clear message from id
//Updated to d.js v12 & fixed some bugs |
// Input: [!clear @user <amount>] & [!clear <amount>] !Command name and prefix depend on your code!
const user = message.mentions.users.first();
let amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2])
amount = Math.floor(amount + 1);
if (!amount) return message.reply('You need to specify an amount.');
if (!amount && !user) return message.reply('You need to specify a user and an amount.');
messages.channel.messages.fetch({
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);
} else {
messages = amount;
}
message.channel.bulkDelete(messages).catch(error => console.log(error.stack));
});
Also in JavaScript:
- chart.js npm install
- how to remove last index of array in javascript
- increase node heap size
- react map array limit
- how to get timestamp in javascript of a date object
- check data type in js
- Error: node_modules/@angular/fire/database/interfaces.d.ts:2:10
- FAILURE: Build failed with an exception react native android
- js change button text
- javascript loop an array check if a number is even
- Removing duplicates in an Array of Objects
- javascript convert to array
- return an array of strings from an array of objects js
- looping in javascript
- how to make a factorial function in javascript
- visual studio appsettings development json not nested appsettings.json
- capitalise first letter js
- js localstorage boolean
- javascript getdate
- vowel
- javascript localStorage clear items
- curren route vue
- javascript loadImage
- parse local json file