better platformindicators settings (#243)

This commit is contained in:
megumin 2022-11-21 19:12:46 +00:00 committed by GitHub
parent 0f7c80fd4d
commit 31ec1ec1b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -98,6 +98,7 @@ export default definePlugin({
{ {
// Server member list decorators // Server member list decorators
find: "this.renderPremium()", find: "this.renderPremium()",
predicate: () => ["both", "list"].includes(Settings.plugins.PlatformIndicators.displayMode),
replacement: { replacement: {
match: /this.renderPremium\(\)[^\]]*?\]/, match: /this.renderPremium\(\)[^\]]*?\]/,
replace: "$&.concat(Vencord.Plugins.plugins.PlatformIndicators.renderPlatformIndicators(this.props))" replace: "$&.concat(Vencord.Plugins.plugins.PlatformIndicators.renderPlatformIndicators(this.props))"
@ -106,6 +107,7 @@ export default definePlugin({
{ {
// Dm list decorators // Dm list decorators
find: "PrivateChannel.renderAvatar", find: "PrivateChannel.renderAvatar",
predicate: () => ["both", "list"].includes(Settings.plugins.PlatformIndicators.displayMode),
replacement: { replacement: {
match: /(subText:(.{1,3})\..+?decorators:)(.+?:null)/, match: /(subText:(.{1,3})\..+?decorators:)(.+?:null)/,
replace: "$1[$3].concat(Vencord.Plugins.plugins.PlatformIndicators.renderPlatformIndicators($2.props))" replace: "$1[$3].concat(Vencord.Plugins.plugins.PlatformIndicators.renderPlatformIndicators($2.props))"
@ -114,7 +116,7 @@ export default definePlugin({
{ {
// User badges // User badges
find: "Messages.PROFILE_USER_BADGES", find: "Messages.PROFILE_USER_BADGES",
predicate: () => Settings.plugins.PlatformIndicators.showAsBadges, predicate: () => ["both", "badges"].includes(Settings.plugins.PlatformIndicators.displayMode),
replacement: { replacement: {
match: /(Messages\.PROFILE_USER_BADGES,role:"group",children:)(.+?\.key\)\}\)\))/, match: /(Messages\.PROFILE_USER_BADGES,role:"group",children:)(.+?\.key\)\}\)\))/,
replace: "$1[Vencord.Plugins.plugins.PlatformIndicators.renderPlatformIndicators(e)].concat($2)" replace: "$1[Vencord.Plugins.plugins.PlatformIndicators.renderPlatformIndicators(e)].concat($2)"
@ -129,11 +131,25 @@ export default definePlugin({
), ),
options: { options: {
showAsBadges: { displayMode: {
description: "Show platform icons in user badges", type: OptionType.SELECT,
type: OptionType.BOOLEAN, description: "Where to display the platform indicators",
default: true,
restartNeeded: true, restartNeeded: true,
options: [
{
label: "Member List & Badges",
value: "both",
default: true
},
{
label: "Member List Only",
value: "list"
},
{
label: "Badges Only",
value: "badges"
} }
]
},
} }
}); });