Last active
September 19, 2024 07:31
-
-
Save shinmai/4d07a79f4f9ede6659efd470b7662bec to your computer and use it in GitHub Desktop.
BetterDiscord addon/plug-in to try and keep from accidentally pinging people
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 Sush Up! | |
* @description STOP PINGING YOUR FRIENDS! | |
* @version 0.0.2 | |
* @author shi | |
* @authorId 142594671078539264 | |
* @website https://shinmai.wtf/ | |
* @source https://gist.github.com/shinmai/4d07a79f4f9ede6659efd470b7662bec/raw/SushUp.plugin.js | |
*/ | |
/** | |
* Changelog: | |
* 0.0.1 - initial version | |
* 0.0.2 - automagically disable reply pings and supress typing notices | |
* - changed name to reflect the purpose more (no version number change) | |
*/ | |
module.exports = meta => ({ | |
start() { | |
const getChannel = BdApi.Webpack.getStore("ChannelStore").getChannel, | |
targets = [], //add serverIDs or userIDs as strings to only run on certain chats | |
targetsWhitelist = false, // set to true to NOT run on chats matching targets | |
hushUpBby = (_,args,oFn)=> { | |
let channelId = args[0].channelId | |
if(!args[0].channelId) | |
[ channelId ] = args | |
const channel = getChannel(channelId), | |
target = channel.recipients?.at(0) || channel.guild_id, | |
msg = (args.length>1)?args[1]:args[0].parsedMessage | |
if( ( targetsWhitelist?!targets.includes(target):targets.includes(target) || targets.length==0 ) && !msg.content.startsWith("@silent ") ) { | |
if(!msg.content.startsWith(".")) | |
msg.content = '@silent ' + msg.content | |
else | |
msg.content = msg.content.substring(1) | |
} | |
return oFn(...args) | |
}, | |
sushYouSillyGoose = (_,args,oFn) => { | |
const [ channelId ] = args, | |
channel = getChannel(channelId), | |
target = channel.recipients?.at(0) || channel.guild_id | |
if( targetsWhitelist?!targets.includes(target):targets.includes(target) || targets.length==0 ) return | |
return oFn(...args) | |
}, | |
pingsShouldBeOptIn = (_,args) => { | |
const props = args[0], | |
target = props.channel.recipients?.at(0) || props.channel.guild_id | |
if( targetsWhitelist?!targets.includes(target):targets.includes(target) || targets.length==0 ) props.shouldMention = false | |
} | |
BdApi.Patcher.instead('sushUp', BdApi.Webpack.getModule(BdApi.Webpack.Filters.byProps('sendMessage')), 'sendMessage', hushUpBby) | |
BdApi.Patcher.instead('sushUp', BdApi.Webpack.getModule(BdApi.Webpack.Filters.byProps('uploadFiles')), 'uploadFiles', hushUpBby) | |
BdApi.Patcher.instead('sushUp', BdApi.Webpack.getModule(BdApi.Webpack.Filters.byProps('startTyping')), 'startTyping', sushYouSillyGoose) | |
BdApi.Patcher.before('sushUp', BdApi.Webpack.getModule(BdApi.Webpack.Filters.byProps('createPendingReply')), 'createPendingReply', pingsShouldBeOptIn) | |
}, | |
stop() { BdApi.Patcher.unpatchAll('sushUp') } | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment