Skip to content

Instantly share code, notes, and snippets.

@shinmai
Last active July 9, 2024 21:41
Show Gist options
  • Save shinmai/4d07a79f4f9ede6659efd470b7662bec to your computer and use it in GitHub Desktop.
Save shinmai/4d07a79f4f9ede6659efd470b7662bec to your computer and use it in GitHub Desktop.
BetterDiscord addon/plug-in to try and keep from accidentally pinging people
/**
* @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('beMoreSneaky', BdApi.Webpack.getModule(BdApi.Webpack.Filters.byProps('sendMessage')), 'sendMessage', hushUpBby)
BdApi.Patcher.instead('beMoreSneaky', BdApi.Webpack.getModule(BdApi.Webpack.Filters.byProps('uploadFiles')), 'uploadFiles', hushUpBby)
BdApi.Patcher.instead('beMoreSneaky', BdApi.Webpack.getModule(BdApi.Webpack.Filters.byProps('startTyping')), 'startTyping', sushYouSillyGoose)
BdApi.Patcher.before('beMoreSneaky', BdApi.Webpack.getModule(BdApi.Webpack.Filters.byProps('createPendingReply')), 'createPendingReply', pingsShouldBeOptIn)
},
stop() { BdApi.Patcher.unpatchAll('beMoreSneaky') }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment