|
| 1 | +module.exports = { |
| 2 | + name: 'Message Delete MOD', |
| 3 | + displayName: 'Message Delete MOD', |
| 4 | + isEvent: true, |
| 5 | + |
| 6 | + fields: ['Message that was deleted (Temp Variable Name):', 'Member who deleted the message (Temp Variable Name):'], |
| 7 | + |
| 8 | + mod(DBM) { |
| 9 | + DBM.Events = DBM.Events || {}; |
| 10 | + const { Bot, Actions } = DBM; |
| 11 | + DBM.Events.messageDeleted = async function messageDeleted(message) { |
| 12 | + if (!Bot.$evts['Message Delete MOD']) return; |
| 13 | + const server = message.guild; |
| 14 | + let executor = undefined; |
| 15 | + if (server) { |
| 16 | + const auditLogs = await message.guild.fetchAuditLogs({ |
| 17 | + limit: 1, |
| 18 | + type: 'MESSAGE_DELETE', |
| 19 | + }); |
| 20 | + |
| 21 | + const deletionAuditLogs = auditLogs.entries.first(); |
| 22 | + if (!deletionAuditLogs) { |
| 23 | + executor = undefined; |
| 24 | + } else if (deletionAuditLogs.target.id === (message.author ? message.author.id : undefined)) { |
| 25 | + executor = deletionAuditLogs.executor; |
| 26 | + } else { |
| 27 | + executor = message.author; |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + for (const event of Bot.$evts['Message Delete MOD']) { |
| 32 | + const temp = {}; |
| 33 | + if (event.temp) temp[event.temp] = message; |
| 34 | + if (event.temp2) temp[event.temp2] = executor; |
| 35 | + Actions.invokeEvent(event, server, temp); |
| 36 | + } |
| 37 | + }; |
| 38 | + |
| 39 | + const { onReady } = Bot; |
| 40 | + Bot.onReady = function messageDeletedOnReady(...params) { |
| 41 | + Bot.bot.on('messageDelete', DBM.Events.messageDeleted); |
| 42 | + onReady.apply(this, ...params); |
| 43 | + }; |
| 44 | + }, |
| 45 | +}; |
0 commit comments