Compare commits
6 commits
cdf72cf4be
...
0cea347264
Author | SHA1 | Date | |
---|---|---|---|
0cea347264 | |||
db2f5c9292 | |||
5bfc608f7d | |||
7d8214fc37 | |||
4b16fbcaa9 | |||
7ec842d4b0 |
|
@ -230,6 +230,10 @@ export function definePluginSettings<
|
||||||
if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized");
|
if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized");
|
||||||
return Settings.plugins[definedSettings.pluginName] as any;
|
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(
|
use: settings => useSettings(
|
||||||
settings?.map(name => `plugins.${definedSettings.pluginName}.${name}`) as UseSettings<Settings>[]
|
settings?.map(name => `plugins.${definedSettings.pluginName}.${name}`) as UseSettings<Settings>[]
|
||||||
).plugins[definedSettings.pluginName] as any,
|
).plugins[definedSettings.pluginName] as any,
|
||||||
|
|
3
src/plugins/alwaysExpandRoles/README.md
Normal file
3
src/plugins/alwaysExpandRoles/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Always Expand Roles
|
||||||
|
|
||||||
|
Always expands the role list in profile popouts
|
37
src/plugins/alwaysExpandRoles/index.ts
Normal file
37
src/plugins/alwaysExpandRoles/index.ts
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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)`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
|
@ -60,13 +60,6 @@ export default definePlugin({
|
||||||
replace: ""
|
replace: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
find: "notosans-400-normalitalic",
|
|
||||||
replacement: {
|
|
||||||
match: /,"notosans-.+?"/g,
|
|
||||||
replace: ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: 'console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");',
|
find: 'console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");',
|
||||||
all: true,
|
all: true,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# MentionAvatars
|
# 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/fc76ea47-5e19-4063-a592-c57785a75cc7)
|
||||||
|
![](https://github.com/user-attachments/assets/76c4c3d9-7cde-42db-ba84-903cbb40c163)
|
||||||
|
|
|
@ -10,21 +10,42 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
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";
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
showAtSymbol: {
|
showAtSymbol: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Whether the the @ symbol should be displayed",
|
description: "Whether the the @ symbol should be displayed on user mentions",
|
||||||
default: true
|
default: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function DefaultRoleIcon() {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
className="vc-mentionAvatars-icon vc-mentionAvatars-role-icon"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M14 8.00598C14 10.211 12.206 12.006 10 12.006C7.795 12.006 6 10.211 6 8.00598C6 5.80098 7.794 4.00598 10 4.00598C12.206 4.00598 14 5.80098 14 8.00598ZM2 19.006C2 15.473 5.29 13.006 10 13.006C14.711 13.006 18 15.473 18 19.006V20.006H2V19.006Z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M20.0001 20.006H22.0001V19.006C22.0001 16.4433 20.2697 14.4415 17.5213 13.5352C19.0621 14.9127 20.0001 16.8059 20.0001 19.006V20.006Z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M14.8834 11.9077C16.6657 11.5044 18.0001 9.9077 18.0001 8.00598C18.0001 5.96916 16.4693 4.28218 14.4971 4.0367C15.4322 5.09511 16.0001 6.48524 16.0001 8.00598C16.0001 9.44888 15.4889 10.7742 14.6378 11.8102C14.7203 11.8418 14.8022 11.8743 14.8834 11.9077Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "MentionAvatars",
|
name: "MentionAvatars",
|
||||||
description: "Shows user avatars inside mentions",
|
description: "Shows user avatars and role icons inside mentions",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven, Devs.SerStars],
|
||||||
|
|
||||||
patches: [{
|
patches: [{
|
||||||
find: ".USER_MENTION)",
|
find: ".USER_MENTION)",
|
||||||
|
@ -32,6 +53,13 @@ export default definePlugin({
|
||||||
match: /children:"@"\.concat\((null!=\i\?\i:\i)\)(?<=\.useName\((\i)\).+?)/,
|
match: /children:"@"\.concat\((null!=\i\?\i:\i)\)(?<=\.useName\((\i)\).+?)/,
|
||||||
replace: "children:$self.renderUsername({username:$1,user:$2})"
|
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,
|
settings,
|
||||||
|
@ -47,12 +75,31 @@ export default definePlugin({
|
||||||
onMouseEnter={() => setIsHovering(true)}
|
onMouseEnter={() => setIsHovering(true)}
|
||||||
onMouseLeave={() => setIsHovering(false)}
|
onMouseLeave={() => setIsHovering(false)}
|
||||||
>
|
>
|
||||||
<img src={user.getAvatarURL(SelectedGuildStore.getGuildId(), 16, isHovering)} className="vc-mentionAvatars-avatar" />
|
<img
|
||||||
|
src={user.getAvatarURL(SelectedGuildStore.getGuildId(), 16, isHovering)}
|
||||||
|
className="vc-mentionAvatars-icon"
|
||||||
|
style={{ borderRadius: "50%" }}
|
||||||
|
/>
|
||||||
{getUsernameString(username)}
|
{getUsernameString(username)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}, { 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 <DefaultRoleIcon />;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
className="vc-mentionAvatars-icon vc-mentionAvatars-role-icon"
|
||||||
|
src={`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${roleId}/${role.icon}.webp?size=24&quality=lossless`}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
function getUsernameString(username: string) {
|
function getUsernameString(username: string) {
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
.vc-mentionAvatars-avatar {
|
.vc-mentionAvatars-icon {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
width: 1em !important; /* insane discord sets width: 100% in channel topic */
|
width: 1em !important; /* insane discord sets width: 100% in channel topic */
|
||||||
height: 1em;
|
height: 1em;
|
||||||
margin: 0 4px 0.2rem 2px;
|
margin: 0 4px 0.2rem 2px;
|
||||||
border-radius: 50%;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-mentionAvatars-role-icon {
|
||||||
|
margin: 0 2px 0.2rem 4px;
|
||||||
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findLazy } from "@webpack";
|
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 { Permissions, RC } from "@webpack/types";
|
||||||
import type { Channel, Guild, Message, User } from "discord-types/general";
|
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 }])
|
tags.map(({ name, displayName }) => [name, { text: displayName, showInChat: true, showInNotChat: true }])
|
||||||
) as TagSettings;
|
) as TagSettings;
|
||||||
|
|
||||||
function SettingsComponent(props: { setValue(v: any): void; }) {
|
function SettingsComponent() {
|
||||||
settings.store.tagSettings ??= defaultSettings;
|
const tagSettings = settings.store.tagSettings ??= defaultSettings;
|
||||||
|
|
||||||
const [tagSettings, setTagSettings] = useState(settings.store.tagSettings as TagSettings);
|
|
||||||
const setValue = (v: TagSettings) => {
|
|
||||||
setTagSettings(v);
|
|
||||||
props.setValue(v);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex flexDirection="column">
|
<Flex flexDirection="column">
|
||||||
|
@ -137,19 +131,13 @@ function SettingsComponent(props: { setValue(v: any): void; }) {
|
||||||
type="text"
|
type="text"
|
||||||
value={tagSettings[t.name]?.text ?? t.displayName}
|
value={tagSettings[t.name]?.text ?? t.displayName}
|
||||||
placeholder={`Text on tag (default: ${t.displayName})`}
|
placeholder={`Text on tag (default: ${t.displayName})`}
|
||||||
onChange={v => {
|
onChange={v => tagSettings[t.name].text = v}
|
||||||
tagSettings[t.name].text = v;
|
|
||||||
setValue(tagSettings);
|
|
||||||
}}
|
|
||||||
className={Margins.bottom16}
|
className={Margins.bottom16}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
value={tagSettings[t.name]?.showInChat ?? true}
|
value={tagSettings[t.name]?.showInChat ?? true}
|
||||||
onChange={v => {
|
onChange={v => tagSettings[t.name].showInChat = v}
|
||||||
tagSettings[t.name].showInChat = v;
|
|
||||||
setValue(tagSettings);
|
|
||||||
}}
|
|
||||||
hideBorder
|
hideBorder
|
||||||
>
|
>
|
||||||
Show in messages
|
Show in messages
|
||||||
|
@ -157,10 +145,7 @@ function SettingsComponent(props: { setValue(v: any): void; }) {
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
value={tagSettings[t.name]?.showInNotChat ?? true}
|
value={tagSettings[t.name]?.showInNotChat ?? true}
|
||||||
onChange={v => {
|
onChange={v => tagSettings[t.name].showInNotChat = v}
|
||||||
tagSettings[t.name].showInNotChat = v;
|
|
||||||
setValue(tagSettings);
|
|
||||||
}}
|
|
||||||
hideBorder
|
hideBorder
|
||||||
>
|
>
|
||||||
Show in member list and profiles
|
Show in member list and profiles
|
||||||
|
@ -183,7 +168,7 @@ const settings = definePluginSettings({
|
||||||
tagSettings: {
|
tagSettings: {
|
||||||
type: OptionType.COMPONENT,
|
type: OptionType.COMPONENT,
|
||||||
component: SettingsComponent,
|
component: SettingsComponent,
|
||||||
description: "fill me",
|
description: "fill me"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ type UserPermissions = Array<UserPermission>;
|
||||||
|
|
||||||
const { RoleRootClasses, RoleClasses, RoleBorderClasses } = proxyLazyWebpack(() => {
|
const { RoleRootClasses, RoleClasses, RoleBorderClasses } = proxyLazyWebpack(() => {
|
||||||
const [RoleRootClasses, RoleClasses, RoleBorderClasses] = findBulk(
|
const [RoleRootClasses, RoleClasses, RoleBorderClasses] = findBulk(
|
||||||
filters.byProps("root", "showMoreButton", "collapseButton"),
|
filters.byProps("root", "expandButton", "collapseButton"),
|
||||||
filters.byProps("role", "roleCircle", "roleName"),
|
filters.byProps("role", "roleCircle", "roleName"),
|
||||||
filters.byProps("roleCircle", "dot", "dotBorderColor")
|
filters.byProps("roleCircle", "dot", "dotBorderColor")
|
||||||
) as Record<string, string>[];
|
) as Record<string, string>[];
|
||||||
|
|
|
@ -172,7 +172,7 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: ".VIEW_ALL_ROLES,",
|
find: ".VIEW_ALL_ROLES,",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /children:"\+"\.concat\(\i\.length-\i\.length\).{0,20}\}\),/,
|
match: /\.collapseButton,.+?}\)}\),/,
|
||||||
replace: "$&$self.ViewPermissionsButton(arguments[0]),"
|
replace: "$&$self.ViewPermissionsButton(arguments[0]),"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,6 +546,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "Lumap",
|
name: "Lumap",
|
||||||
id: 585278686291427338n,
|
id: 585278686291427338n,
|
||||||
},
|
},
|
||||||
|
SerStars: {
|
||||||
|
name: "SerStars",
|
||||||
|
id: 861631850681729045n,
|
||||||
|
},
|
||||||
} satisfies Record<string, Dev>);
|
} satisfies Record<string, Dev>);
|
||||||
|
|
||||||
// iife so #__PURE__ works correctly
|
// iife so #__PURE__ works correctly
|
||||||
|
|
|
@ -309,6 +309,8 @@ export interface DefinedSettings<
|
||||||
> {
|
> {
|
||||||
/** Shorthand for `Vencord.Settings.plugins.PluginName`, but with typings */
|
/** Shorthand for `Vencord.Settings.plugins.PluginName`, but with typings */
|
||||||
store: SettingsStore<Def> & PrivateSettings;
|
store: SettingsStore<Def> & PrivateSettings;
|
||||||
|
/** Shorthand for `Vencord.PlainSettings.plugins.PluginName`, but with typings */
|
||||||
|
plain: SettingsStore<Def> & PrivateSettings;
|
||||||
/**
|
/**
|
||||||
* React hook for getting the settings for this plugin
|
* React hook for getting the settings for this plugin
|
||||||
* @param filter optional filter to avoid rerenders for irrelevent settings
|
* @param filter optional filter to avoid rerenders for irrelevent settings
|
||||||
|
|
Loading…
Reference in a new issue