mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-15 09:33:03 -04:00
PronounDB: Add support for compact mode & clean up (#604)
This commit is contained in:
parent
e143260891
commit
b90392576e
6 changed files with 102 additions and 30 deletions
|
@ -16,11 +16,13 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import "./styles.css";
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
||||
import PronounsAboutComponent from "./components/PronounsAboutComponent";
|
||||
import PronounsChatComponent from "./components/PronounsChatComponent";
|
||||
import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } from "./components/PronounsChatComponent";
|
||||
import PronounsProfileWrapper from "./components/PronounsProfileWrapper";
|
||||
|
||||
export enum PronounsFormat {
|
||||
|
@ -30,22 +32,30 @@ export enum PronounsFormat {
|
|||
|
||||
export default definePlugin({
|
||||
name: "PronounDB",
|
||||
authors: [Devs.Tyman],
|
||||
authors: [Devs.Tyman, Devs.TheKodeToad],
|
||||
description: "Adds pronouns to user messages using pronoundb",
|
||||
patches: [
|
||||
// Patch the chat timestamp element
|
||||
// Add next to username (compact mode)
|
||||
{
|
||||
find: "showCommunicationDisabledStyles",
|
||||
replacement: {
|
||||
match: /(?<=return\s*\(0,\w{1,3}\.jsxs?\)\(.+!\w{1,3}&&)(\(0,\w{1,3}.jsxs?\)\(.+?\{.+?\}\))/,
|
||||
replace: "[$1, $self.PronounsChatComponent(e)]"
|
||||
match: /("span",{id:\i,className:\i,children:\i}\))/,
|
||||
replace: "$1, $self.CompactPronounsChatComponentWrapper(e)"
|
||||
}
|
||||
},
|
||||
// Patch the chat timestamp element (normal mode)
|
||||
{
|
||||
find: "showCommunicationDisabledStyles",
|
||||
replacement: {
|
||||
match: /(?<=return\s*\(0,\i\.jsxs?\)\(.+!\i&&)(\(0,\i.jsxs?\)\(.+?\{.+?\}\))/,
|
||||
replace: "[$1, $self.PronounsChatComponentWrapper(e)]"
|
||||
}
|
||||
},
|
||||
// Hijack the discord pronouns section and add a wrapper around the text section
|
||||
{
|
||||
find: ".Messages.BOT_PROFILE_SLASH_COMMANDS",
|
||||
replacement: {
|
||||
match: /\(0,.\.jsx\)\((?<PronounComponent>.{1,2}\..),(?<pronounProps>{currentPronouns.+?:(?<fullProps>.{1,2})\.pronouns.+?})\)/,
|
||||
match: /\(0,.\.jsx\)\((?<PronounComponent>\i\..),(?<pronounProps>{currentPronouns.+?:(?<fullProps>\i)\.pronouns.+?})\)/,
|
||||
replace: "$<fullProps>&&$self.PronounsProfileWrapper($<PronounComponent>,$<pronounProps>,$<fullProps>)"
|
||||
}
|
||||
},
|
||||
|
@ -79,10 +89,21 @@ export default definePlugin({
|
|||
type: OptionType.BOOLEAN,
|
||||
description: "Enable or disable showing pronouns for the current user",
|
||||
default: true
|
||||
},
|
||||
showInMessages: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show in messages",
|
||||
default: true
|
||||
},
|
||||
showInProfile: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show in profile",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
settingsAboutComponent: PronounsAboutComponent,
|
||||
// Re-export the components on the plugin object so it is easily accessible in patches
|
||||
PronounsChatComponent,
|
||||
PronounsChatComponentWrapper,
|
||||
CompactPronounsChatComponentWrapper,
|
||||
PronounsProfileWrapper
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue