MessageDelete.js (733B)
1 'use strict'; 2 3 const Action = require('./Action'); 4 const { Events } = require('../../util/Constants'); 5 6 class MessageDeleteAction extends Action { 7 handle(data) { 8 const client = this.client; 9 const channel = this.getChannel(data); 10 let message; 11 if (channel) { 12 message = this.getMessage(data, channel); 13 if (message) { 14 channel.messages.cache.delete(message.id); 15 message.deleted = true; 16 /** 17 * Emitted whenever a message is deleted. 18 * @event Client#messageDelete 19 * @param {Message} message The deleted message 20 */ 21 client.emit(Events.MESSAGE_DELETE, message); 22 } 23 } 24 25 return { message }; 26 } 27 } 28 29 module.exports = MessageDeleteAction;