2023-11-09 03:42:35 +00:00
|
|
|
/*
|
|
|
|
* Vencord, a Discord client mod
|
|
|
|
* Copyright (c) 2023 Vendicated, ant0n, FieryFlames and contributors
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { definePluginSettings } from "@api/Settings";
|
|
|
|
import { Devs } from "@utils/constants";
|
|
|
|
import definePlugin, { OptionType } from "@utils/types";
|
2024-02-23 12:06:03 +00:00
|
|
|
import { UserStore } from "@webpack/common";
|
2023-11-09 03:42:35 +00:00
|
|
|
|
|
|
|
export const settings = definePluginSettings({
|
|
|
|
superReactByDefault: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
description: "Reaction picker will default to Super Reactions",
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
unlimitedSuperReactionPlaying: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
description: "Remove the limit on Super Reactions playing at once",
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
superReactionPlayingLimit: {
|
|
|
|
description: "Max Super Reactions to play at once",
|
|
|
|
type: OptionType.SLIDER,
|
|
|
|
default: 20,
|
|
|
|
markers: [5, 10, 20, 40, 60, 80, 100],
|
|
|
|
stickToMarkers: true,
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
superReactionPlayingLimit: {
|
|
|
|
disabled() { return this.store.unlimitedSuperReactionPlaying; },
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default definePlugin({
|
|
|
|
name: "SuperReactionTweaks",
|
|
|
|
description: "Customize the limit of Super Reactions playing at once, and super react by default",
|
|
|
|
authors: [Devs.FieryFlames, Devs.ant0n],
|
|
|
|
patches: [
|
|
|
|
{
|
|
|
|
find: ",BURST_REACTION_EFFECT_PLAY",
|
|
|
|
replacement: {
|
2024-05-24 00:48:12 +00:00
|
|
|
match: /(BURST_REACTION_EFFECT_PLAY:\i=>{.{50,100})(\i\(\i,\i\))>=\d+/,
|
|
|
|
replace: "$1!$self.shouldPlayBurstReaction($2)"
|
2023-11-09 03:42:35 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-12-02 02:06:18 +00:00
|
|
|
find: ".trackEmojiSearchEmpty,200",
|
2023-11-09 03:42:35 +00:00
|
|
|
replacement: {
|
2023-12-02 02:06:18 +00:00
|
|
|
match: /(\.trackEmojiSearchEmpty,200(?=.+?isBurstReaction:(\i).+?(\i===\i\.EmojiIntention.REACTION)).+?\[\2,\i\]=\i\.useState\().+?\)/,
|
2024-02-23 12:06:03 +00:00
|
|
|
replace: (_, rest, isBurstReactionVariable, isReactionIntention) => `${rest}$self.shouldSuperReactByDefault&&${isReactionIntention})`
|
2023-11-09 03:42:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
settings,
|
|
|
|
|
|
|
|
shouldPlayBurstReaction(playingCount: number) {
|
|
|
|
if (settings.store.unlimitedSuperReactionPlaying) return true;
|
|
|
|
if (playingCount <= settings.store.superReactionPlayingLimit) return true;
|
|
|
|
return false;
|
2024-02-23 12:06:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
get shouldSuperReactByDefault() {
|
|
|
|
return settings.store.superReactByDefault && UserStore.getCurrentUser().premiumType != null;
|
2023-11-09 03:42:35 +00:00
|
|
|
}
|
|
|
|
});
|