diff --git a/src/api/Settings.ts b/src/api/Settings.ts index 88337a917..ac116f547 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -230,6 +230,10 @@ export function definePluginSettings< if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized"); return Settings.plugins[definedSettings.pluginName] as any; }, + get plain() { + if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized"); + return PlainSettings.plugins[definedSettings.pluginName] as any; + }, use: settings => useSettings( settings?.map(name => `plugins.${definedSettings.pluginName}.${name}`) as UseSettings[] ).plugins[definedSettings.pluginName] as any, diff --git a/src/plugins/alwaysExpandRoles/README.md b/src/plugins/alwaysExpandRoles/README.md new file mode 100644 index 000000000..344268cbf --- /dev/null +++ b/src/plugins/alwaysExpandRoles/README.md @@ -0,0 +1,3 @@ +# Always Expand Roles + +Always expands the role list in profile popouts diff --git a/src/plugins/alwaysExpandRoles/index.ts b/src/plugins/alwaysExpandRoles/index.ts new file mode 100644 index 000000000..1c20b9777 --- /dev/null +++ b/src/plugins/alwaysExpandRoles/index.ts @@ -0,0 +1,37 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { migratePluginSettings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +migratePluginSettings("AlwaysExpandRoles", "ShowAllRoles"); +export default definePlugin({ + name: "AlwaysExpandRoles", + description: "Always expands the role list in profile popouts", + authors: [Devs.surgedevs], + patches: [ + { + find: 'action:"EXPAND_ROLES"', + replacement: { + match: /(roles:\i(?=.+?(\i)\(!0\)[,;]\i\({action:"EXPAND_ROLES"}\)).+?\[\i,\2\]=\i\.useState\()!1\)/, + replace: (_, rest, setExpandedRoles) => `${rest}!0)` + } + } + ] +}); diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index dfb59957d..e847c4124 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -60,13 +60,6 @@ export default definePlugin({ replace: "" } }, - { - find: "notosans-400-normalitalic", - replacement: { - match: /,"notosans-.+?"/g, - replace: "" - } - }, { find: 'console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");', all: true, diff --git a/src/plugins/mentionAvatars/README.md b/src/plugins/mentionAvatars/README.md index 912b51916..5e553419e 100644 --- a/src/plugins/mentionAvatars/README.md +++ b/src/plugins/mentionAvatars/README.md @@ -1,5 +1,6 @@ # MentionAvatars -Shows user avatars inside mentions +Shows user avatars and role icons inside mentions ![](https://github.com/user-attachments/assets/fc76ea47-5e19-4063-a592-c57785a75cc7) +![](https://github.com/user-attachments/assets/76c4c3d9-7cde-42db-ba84-903cbb40c163) diff --git a/src/plugins/mentionAvatars/index.tsx b/src/plugins/mentionAvatars/index.tsx index 311303ab9..53ab93e38 100644 --- a/src/plugins/mentionAvatars/index.tsx +++ b/src/plugins/mentionAvatars/index.tsx @@ -10,21 +10,42 @@ import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { SelectedGuildStore, useState } from "@webpack/common"; +import { GuildStore, SelectedGuildStore, useState } from "@webpack/common"; import { User } from "discord-types/general"; const settings = definePluginSettings({ showAtSymbol: { type: OptionType.BOOLEAN, - description: "Whether the the @ symbol should be displayed", + description: "Whether the the @ symbol should be displayed on user mentions", default: true } }); +function DefaultRoleIcon() { + return ( + + + + + + ); +} + export default definePlugin({ name: "MentionAvatars", - description: "Shows user avatars inside mentions", - authors: [Devs.Ven], + description: "Shows user avatars and role icons inside mentions", + authors: [Devs.Ven, Devs.SerStars], patches: [{ find: ".USER_MENTION)", @@ -32,6 +53,13 @@ export default definePlugin({ match: /children:"@"\.concat\((null!=\i\?\i:\i)\)(?<=\.useName\((\i)\).+?)/, replace: "children:$self.renderUsername({username:$1,user:$2})" } + }, + { + find: ".ROLE_MENTION)", + replacement: { + match: /children:\[\i&&.{0,50}\.RoleDot.{0,300},\i(?=\])/, + replace: "$&,$self.renderRoleIcon(arguments[0])" + } }], settings, @@ -47,12 +75,31 @@ export default definePlugin({ onMouseEnter={() => setIsHovering(true)} onMouseLeave={() => setIsHovering(false)} > - + {getUsernameString(username)} ); - }, { noop: true }) + }, { noop: true }), + renderRoleIcon: ErrorBoundary.wrap(({ roleId, guildId }: { roleId: string, guildId: string; }) => { + // Discord uses Role Mentions for uncached users because .... idk + if (!roleId) return null; + + const role = GuildStore.getRole(guildId, roleId); + + if (!role?.icon) return ; + + return ( + + ); + }), }); function getUsernameString(username: string) { diff --git a/src/plugins/mentionAvatars/styles.css b/src/plugins/mentionAvatars/styles.css index 022f968c0..64eb41416 100644 --- a/src/plugins/mentionAvatars/styles.css +++ b/src/plugins/mentionAvatars/styles.css @@ -1,8 +1,11 @@ -.vc-mentionAvatars-avatar { +.vc-mentionAvatars-icon { vertical-align: middle; width: 1em !important; /* insane discord sets width: 100% in channel topic */ height: 1em; margin: 0 4px 0.2rem 2px; - border-radius: 50%; box-sizing: border-box; } + +.vc-mentionAvatars-role-icon { + margin: 0 2px 0.2rem 4px; +} diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index 4802f04a1..0a87c57a9 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -22,7 +22,7 @@ import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findLazy } from "@webpack"; -import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip, useState } from "@webpack/common"; +import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip } from "@webpack/common"; import type { Permissions, RC } from "@webpack/types"; import type { Channel, Guild, Message, User } from "discord-types/general"; @@ -107,14 +107,8 @@ const defaultSettings = Object.fromEntries( tags.map(({ name, displayName }) => [name, { text: displayName, showInChat: true, showInNotChat: true }]) ) as TagSettings; -function SettingsComponent(props: { setValue(v: any): void; }) { - settings.store.tagSettings ??= defaultSettings; - - const [tagSettings, setTagSettings] = useState(settings.store.tagSettings as TagSettings); - const setValue = (v: TagSettings) => { - setTagSettings(v); - props.setValue(v); - }; +function SettingsComponent() { + const tagSettings = settings.store.tagSettings ??= defaultSettings; return ( @@ -137,19 +131,13 @@ function SettingsComponent(props: { setValue(v: any): void; }) { type="text" value={tagSettings[t.name]?.text ?? t.displayName} placeholder={`Text on tag (default: ${t.displayName})`} - onChange={v => { - tagSettings[t.name].text = v; - setValue(tagSettings); - }} + onChange={v => tagSettings[t.name].text = v} className={Margins.bottom16} /> { - tagSettings[t.name].showInChat = v; - setValue(tagSettings); - }} + onChange={v => tagSettings[t.name].showInChat = v} hideBorder > Show in messages @@ -157,10 +145,7 @@ function SettingsComponent(props: { setValue(v: any): void; }) { { - tagSettings[t.name].showInNotChat = v; - setValue(tagSettings); - }} + onChange={v => tagSettings[t.name].showInNotChat = v} hideBorder > Show in member list and profiles @@ -183,7 +168,7 @@ const settings = definePluginSettings({ tagSettings: { type: OptionType.COMPONENT, component: SettingsComponent, - description: "fill me", + description: "fill me" } }); diff --git a/src/plugins/permissionsViewer/components/UserPermissions.tsx b/src/plugins/permissionsViewer/components/UserPermissions.tsx index f53f93b6d..dc2aa6fa4 100644 --- a/src/plugins/permissionsViewer/components/UserPermissions.tsx +++ b/src/plugins/permissionsViewer/components/UserPermissions.tsx @@ -37,7 +37,7 @@ type UserPermissions = Array; const { RoleRootClasses, RoleClasses, RoleBorderClasses } = proxyLazyWebpack(() => { const [RoleRootClasses, RoleClasses, RoleBorderClasses] = findBulk( - filters.byProps("root", "showMoreButton", "collapseButton"), + filters.byProps("root", "expandButton", "collapseButton"), filters.byProps("role", "roleCircle", "roleName"), filters.byProps("roleCircle", "dot", "dotBorderColor") ) as Record[]; diff --git a/src/plugins/permissionsViewer/index.tsx b/src/plugins/permissionsViewer/index.tsx index 5039d04f8..7c3967a37 100644 --- a/src/plugins/permissionsViewer/index.tsx +++ b/src/plugins/permissionsViewer/index.tsx @@ -172,7 +172,7 @@ export default definePlugin({ { find: ".VIEW_ALL_ROLES,", replacement: { - match: /children:"\+"\.concat\(\i\.length-\i\.length\).{0,20}\}\),/, + match: /\.collapseButton,.+?}\)}\),/, replace: "$&$self.ViewPermissionsButton(arguments[0])," } } diff --git a/src/utils/constants.ts b/src/utils/constants.ts index febb8f9af..d27759e95 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -546,6 +546,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Lumap", id: 585278686291427338n, }, + SerStars: { + name: "SerStars", + id: 861631850681729045n, + }, } satisfies Record); // iife so #__PURE__ works correctly diff --git a/src/utils/types.ts b/src/utils/types.ts index 8c24843f8..e5486e9a5 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -309,6 +309,8 @@ export interface DefinedSettings< > { /** Shorthand for `Vencord.Settings.plugins.PluginName`, but with typings */ store: SettingsStore & PrivateSettings; + /** Shorthand for `Vencord.PlainSettings.plugins.PluginName`, but with typings */ + plain: SettingsStore & PrivateSettings; /** * React hook for getting the settings for this plugin * @param filter optional filter to avoid rerenders for irrelevent settings