fix: fix icon being a single pixel off (#592)

* fix: fix icon being a single pixel off

* refactor: refactored and optimized patches
feat: display inviter global name
This commit is contained in:
iamme 2025-12-24 05:22:08 +03:00 • committed by GitHub
parent f3d63106c2
commit 92f847bb37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 22 deletions

View file

@ -11,6 +11,7 @@ import { Devs, EquicordDevs } from "@utils/constants";
import { openUserProfile } from "@utils/discord";
import { classes } from "@utils/misc";
import definePlugin, { StartAt } from "@utils/types";
import { Guild } from "@vencord/discord-types";
import { findByPropsLazy } from "@webpack";
import { Parser, Tooltip, UserStore } from "@webpack/common";
@ -48,20 +49,14 @@ export default definePlugin({
find: ".guildNameContainer,onClick:",
replacement: [
{
match: /children:\i\.name\}\).{0,100}\.guildNameContainer/,
replace: "onClick:$self.Lurkable(arguments[0].invite?.guild?.id,arguments[0].invite?.guild?.features),$&"
// make the button clickable
match: /children:(\i)\.name\}\).{0,100}\.guildNameContainer/,
replace: "onClick:$self.Lurkable($1),$&"
},
{
match: /\.nameContainer.{0,100}disableGuildNameClick:\i/,
replace: "$&,invite:arguments[0].invite"
},
{
match: /disableGuildNameClick:\i.{0,50}\}\),\i/,
replace: "$&,$self.RenderTip(arguments[0].invite?.expires_at)"
},
{
match: /\.nameContainer.{0,200}\]\}\)/,
replace: "$&,$self.Header(arguments[0].invite?.inviter,arguments[0].profile.name)"
// tip gets inserted in the name container, header gets inserted beside it
match: /(:(\i),disableGuildNameClick:.{0,20}\}\),\i)(\]\}\))/,
replace: "$1,$self.RenderTip(arguments[0].invite?.expires_at)$3,$self.Header(arguments[0].invite?.inviter,$2.name)"
}
]
},
@ -103,14 +98,14 @@ export default definePlugin({
: "/assets/1f0bfc0865d324c2587920a7d80c609b.png?size=128"}
/>
<div className="vc-bi-header-text">
{inviter.username} invited you to {guildName}
{inviter.global_name || inviter.username} invited you to {guildName}
</div>
</div>
);
},
Lurkable: (id: string, features: Iterable<string> | undefined) => {
if (!id || !features) return null;
return new Set(features).has("DISCOVERABLE") ? () => lurk(id) : null;
Lurkable: (guild?: Guild) => {
if (!guild) return null;
return new Set(guild.features).has("DISCOVERABLE") ? () => lurk(guild.id) : null;
},
startAt: StartAt.WebpackReady
});

View file

@ -1,8 +1,3 @@
h3[class*="h5"]:has([class="vc-bi-header-inner"]) {
display: flex;
margin: 0 !important;
}
.vc-bi-inviter-avatar {
margin: 0;
height: 14px;
@ -31,4 +26,5 @@ h3[class*="h5"]:has([class="vc-bi-header-inner"]) {
color: var(--text-muted);
width: 16px;
height: 16px;
}
margin-top: 1px;
}