-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Message delete event MOD Added a variable for the member who deleted the message * Update message_delete_EVT.js Add support for DMs --------- Co-authored-by: OneAndOnlyFinbar <[email protected]>
- Loading branch information
1 parent
53eeb77
commit 179b70b
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module.exports = { | ||
name: 'Message Delete MOD', | ||
displayName: 'Message Delete MOD', | ||
isEvent: true, | ||
|
||
fields: ['Message that was deleted (Temp Variable Name):', 'Member who deleted the message (Temp Variable Name):'], | ||
|
||
mod(DBM) { | ||
DBM.Events = DBM.Events || {}; | ||
const { Bot, Actions } = DBM; | ||
DBM.Events.messageDeleted = async function messageDeleted(message) { | ||
if (!Bot.$evts['Message Delete MOD']) return; | ||
const server = message.guild; | ||
let executor = undefined; | ||
if (server) { | ||
const auditLogs = await message.guild.fetchAuditLogs({ | ||
limit: 1, | ||
type: 'MESSAGE_DELETE', | ||
}); | ||
|
||
const deletionAuditLogs = auditLogs.entries.first(); | ||
if (!deletionAuditLogs) { | ||
executor = undefined; | ||
} else if (deletionAuditLogs.target.id === (message.author ? message.author.id : undefined)) { | ||
executor = deletionAuditLogs.executor; | ||
} else { | ||
executor = message.author; | ||
} | ||
} | ||
|
||
for (const event of Bot.$evts['Message Delete MOD']) { | ||
const temp = {}; | ||
if (event.temp) temp[event.temp] = message; | ||
if (event.temp2) temp[event.temp2] = executor; | ||
Actions.invokeEvent(event, server, temp); | ||
} | ||
}; | ||
|
||
const { onReady } = Bot; | ||
Bot.onReady = function messageDeletedOnReady(...params) { | ||
Bot.bot.on('messageDelete', DBM.Events.messageDeleted); | ||
onReady.apply(this, ...params); | ||
}; | ||
}, | ||
}; |