BetterInvites: Update For New Invites
This commit is contained in:
parent
634a007d3b
commit
fe46731fdd
6 changed files with 92 additions and 30 deletions
|
|
@ -314,7 +314,7 @@ export default function PluginSettings() {
|
|||
const totalPlugins = Object.keys(Plugins).filter(p => !isApiPlugin(p));
|
||||
const enabledPlugins = Object.keys(Plugins).filter(p => Vencord.Plugins.isPluginEnabled(p) && !isApiPlugin(p));
|
||||
|
||||
const totalStockPlugins = totalPlugins.filter(p => !PluginMeta[p].userPlugin).length;
|
||||
const totalStockPlugins = totalPlugins.filter(p => !PluginMeta[p].userPlugin && !Plugins[p].hidden).length;
|
||||
const totalUserPlugins = totalPlugins.filter(p => PluginMeta[p].userPlugin).length;
|
||||
const enabledStockPlugins = enabledPlugins.filter(p => !PluginMeta[p].userPlugin).length;
|
||||
const enabledUserPlugins = enabledPlugins.filter(p => PluginMeta[p].userPlugin).length;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
import "./style.css";
|
||||
|
||||
import { InfoIcon } from "@components/Icons";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import { openUserProfile } from "@utils/discord";
|
||||
import { classes } from "@utils/misc";
|
||||
import definePlugin, { StartAt } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Parser } from "@webpack/common";
|
||||
|
||||
import { Parser, Tooltip, UserStore } from "@webpack/common";
|
||||
|
||||
const AvatarStyles = findByPropsLazy("avatar", "zalgo");
|
||||
const GuildManager = findByPropsLazy("joinGuild");
|
||||
|
|
@ -37,36 +37,77 @@ export default definePlugin({
|
|||
authors: [EquicordDevs.iamme],
|
||||
patches: [
|
||||
{
|
||||
find: "#{intl::HUB_INVITE_ANOTHER_SCHOOL_LINK}",
|
||||
find: ".hideDetailsButtonContainer,",
|
||||
replacement: [
|
||||
{
|
||||
match: /,(\i)&&(\(.{0,50}asContainer.+)(\i\.\i\.string\(\i\.\i#{intl::GUEST_MEMBERSHIP_EXPLANATION}\))/,
|
||||
replace: ",($1||((!$1)&&arguments[0].invite.expires_at)) && $2$self.RenderTip($1, $3, arguments[0].invite.expires_at)"
|
||||
},
|
||||
{
|
||||
match: /(\.jsx\)\(\i.\i.Info,{.+onClick:\i)/,
|
||||
replace: "$& || $self.Lurkable(arguments[0].invite.guild.id, arguments[0].invite.guild.features)"
|
||||
},
|
||||
{
|
||||
match: /(\.jsx\)\(\i\.\i\.Header,\{)text:(\i)/,
|
||||
replace: "$1text: $self.Header(arguments[0].currentUserId, arguments[0].invite.inviter, $2)"
|
||||
match: /banner\}\),.{0,25}profile:\i\}\),.{0,15}profile:\i/,
|
||||
replace: "$&,invite:arguments[0].invite"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
find: '"disableGuildNameClick"',
|
||||
replacement: [
|
||||
{
|
||||
match: /(?=children:\i\.name\}\)\):)/,
|
||||
replace: "onClick:$self.Lurkable(arguments[0].invite.guild.id,arguments[0].invite.guild.features),"
|
||||
},
|
||||
{
|
||||
match: /\),\{profile:\i,disableGuildNameClick:\i/,
|
||||
replace: "$&,invite:arguments[0].invite"
|
||||
},
|
||||
{
|
||||
match: /\}\)\)\}\),\i/,
|
||||
replace: "$&,$self.RenderTip(arguments[0].invite.expires_at)"
|
||||
},
|
||||
{
|
||||
match: /(?<=text:(\i\.name).*?\]\}\))/,
|
||||
replace: "$&,$self.Header(arguments[0].invite.inviter,$1)"
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
RenderTip(isGuest: boolean, message: string, expires_at: string) {
|
||||
return <>This invite will expire {Parser.parse(`<t:${Math.round(new Date(expires_at).getTime() / 1000)}:R>`)}{isGuest ? ". " + message : ""}</>;
|
||||
RenderTip(expires_at: string) {
|
||||
const timestamp = <>{Parser.parse(`<t:${Math.round(new Date(expires_at).getTime() / 1000)}:R>`)}</>;
|
||||
const tooltipText = (
|
||||
<>
|
||||
This invite will {expires_at ? <>expire {timestamp}</> : <>not expire</>}
|
||||
</>
|
||||
);
|
||||
|
||||
|
||||
return (
|
||||
<Tooltip text={tooltipText}>
|
||||
{({ onMouseEnter, onMouseLeave }) => (
|
||||
<div
|
||||
className="vc-bi-tooltip"
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
>
|
||||
<InfoIcon className="vc-bi-tooltip-icon" />
|
||||
</div>
|
||||
)}
|
||||
</Tooltip>
|
||||
);
|
||||
},
|
||||
Header(currentUserId: string, inviter: User | undefined, defaultMessage: string) {
|
||||
return <div className="vc-bi-header-inner">
|
||||
{(inviter && (currentUserId !== inviter.id)) ? <>
|
||||
Header(inviter: User | undefined, guildName: string) {
|
||||
const currentUserId = UserStore.getCurrentUser().id;
|
||||
if (!inviter || currentUserId === inviter.id) return null;
|
||||
return (
|
||||
<div className="vc-bi-header-inner">
|
||||
<img
|
||||
alt=""
|
||||
className={classes(AvatarStyles.avatar, AvatarStyles.clickable) + " vc-bi-inviter-avatar"}
|
||||
onClick={() => openUserProfile(inviter.id)}
|
||||
src={inviter.avatar ? `https://cdn.discordapp.com/avatars/${inviter.id}/${inviter.avatar}.webp?size=80` : "/assets/1f0bfc0865d324c2587920a7d80c609b.png?size=128"}
|
||||
/> {inviter.global_name ? inviter.global_name.toUpperCase() : inviter.username.toUpperCase()} HAS INVITED YOU TO JOIN
|
||||
</> : defaultMessage}</div>;
|
||||
src={inviter.avatar
|
||||
? `https://cdn.discordapp.com/avatars/${inviter.id}/${inviter.avatar}.webp?size=80`
|
||||
: "/assets/1f0bfc0865d324c2587920a7d80c609b.png?size=128"}
|
||||
/>
|
||||
<div className="vc-bi-header-text">
|
||||
{inviter.username} invited you to {guildName}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
Lurkable: (id: string, features: Iterable<string> | undefined) => {
|
||||
return new Set(features).has("DISCOVERABLE") ? () => lurk(id) : null;
|
||||
|
|
|
|||
|
|
@ -5,14 +5,30 @@ h3[class^="h5"]:has([class="vc-bi-header-inner"]) {
|
|||
|
||||
.vc-bi-inviter-avatar {
|
||||
margin: 0;
|
||||
margin-right: 5px;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
position: static;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.vc-bi-header-inner {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
margin-bottom: 5px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.vc-bi-header-text {
|
||||
flex: 1;
|
||||
white-space: normal;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.vc-bi-tooltip-icon {
|
||||
color: var(--text-muted);
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
|
@ -63,6 +63,10 @@ export default definePlugin({
|
|||
find: "#{intl::ADD_REACTION_NAMED}",
|
||||
group: true,
|
||||
replacement: [
|
||||
{
|
||||
match: /isEmojiPremiumLocked\(\{.{0,25}channel:(\i),/,
|
||||
replace: "$&guild_id:$1?.guild_id??null,"
|
||||
},
|
||||
// Override limit of emojis to display with offset hook.
|
||||
{
|
||||
match: /(\i)\.length>4&&\((\i)\.length=4\);/,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,11 @@
|
|||
}
|
||||
|
||||
.vc-findreply-div {
|
||||
background-color: var(--background-base-lower);
|
||||
background-color: var(--background-base-lowest);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
width: 270px;
|
||||
width: fit-content;
|
||||
padding: 10px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
|
@ -21,12 +21,10 @@ const settings = definePluginSettings({
|
|||
label: "Desktop",
|
||||
value: "desktop",
|
||||
default: true,
|
||||
hidden: IS_DISCORD_DESKTOP
|
||||
},
|
||||
{
|
||||
label: "Web",
|
||||
value: "web",
|
||||
hidden: IS_WEB
|
||||
},
|
||||
{
|
||||
label: "Xbox",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue