Created
May 21, 2024 08:35
-
-
Save shinmai/a8ad7842ef30f7c82b01f37ff233b86f to your computer and use it in GitHub Desktop.
BetterDiscord addon/plug-in to sanitise filenames when uploading
This file contains hidden or 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
/** | |
* @name Sanitise Filenames | |
* @description Hide filenames! | |
* @version 0.0.1 | |
* @author shi | |
* @authorId 142594671078539264 | |
* @website https://shinmai.wtf/ | |
* @source https://gist.github.com/shinmai/a8ad7842ef30f7c82b01f37ff233b86f/raw/SanitiseFilenames.plugin.js | |
*/ | |
/** | |
* Changelog: | |
* 0.0.1 - initial version | |
*/ | |
module.exports = meta => ({ | |
start() { | |
const sanitise = (_,args)=> { | |
const files = args[0].uploads, | |
msg = args[0].parsedMessage | |
if(msg.content.startsWith("%")) { | |
msg.content = msg.content.substring(1) | |
for(file in files) files[file].filename=files[file].classification+"."+files[file].mimeType.split('/')[1] | |
} | |
} | |
BdApi.Patcher.before('sanitiseFilenames', BdApi.Webpack.getModule(BdApi.Webpack.Filters.byProps('uploadFiles')), 'uploadFiles', sanitise) | |
}, | |
stop() { BdApi.Patcher.unpatchAll('sanitiseFilenames') } | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment