mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-11 02:16:23 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
e12a7565d8
15 changed files with 116 additions and 24 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "vencord",
|
||||
"private": "true",
|
||||
"version": "1.7.1",
|
||||
"version": "1.7.2",
|
||||
"description": "The cutest Discord client mod",
|
||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||
"bugs": {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getCurrentGuild } from "@utils/discord";
|
||||
import { getCurrentGuild, getGuildRoles } from "@utils/discord";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Clipboard, Menu, PermissionStore, TextAndImagesSettingsStores } from "@webpack/common";
|
||||
|
@ -47,7 +47,9 @@ export default definePlugin({
|
|||
contextMenus: {
|
||||
"dev-context"(children, { id }: { id: string; }) {
|
||||
const guild = getCurrentGuild();
|
||||
const role = guild?.roles[id];
|
||||
if (!guild) return;
|
||||
|
||||
const role = getGuildRoles(guild.id)[id];
|
||||
if (!role) return;
|
||||
|
||||
if (role.colorString) {
|
||||
|
|
|
@ -131,9 +131,10 @@ export default definePlugin({
|
|||
getDecorAvatarDecorationURL({ avatarDecoration, canAnimate }: { avatarDecoration: AvatarDecoration | null; canAnimate?: boolean; }) {
|
||||
// Only Decor avatar decorations have this SKU ID
|
||||
if (avatarDecoration?.skuId === SKU_ID) {
|
||||
const url = new URL(`${CDN_URL}/${avatarDecoration.asset}.png`);
|
||||
url.searchParams.set("animate", (!!canAnimate && isAnimatedAvatarDecoration(avatarDecoration.asset)).toString());
|
||||
return url.toString();
|
||||
const parts = avatarDecoration.asset.split("_");
|
||||
// Remove a_ prefix if it's animated and animation is disabled
|
||||
if (isAnimatedAvatarDecoration(avatarDecoration.asset) && !canAnimate) parts.shift();
|
||||
return `${CDN_URL}/${parts.join("_")}.png`;
|
||||
} else if (avatarDecoration?.skuId === RAW_SKU_ID) {
|
||||
return avatarDecoration.asset;
|
||||
}
|
||||
|
|
5
src/plugins/friendsSince/README.md
Normal file
5
src/plugins/friendsSince/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# FriendsSince
|
||||
|
||||
Shows when you became friends with someone in the user popout
|
||||
|
||||
![](https://github.com/Vendicated/Vencord/assets/45497981/bb258188-ab48-4c4d-9858-1e90ba41e926)
|
60
src/plugins/friendsSince/index.tsx
Normal file
60
src/plugins/friendsSince/index.tsx
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { React, RelationshipStore } from "@webpack/common";
|
||||
|
||||
const { Heading, Text } = findByPropsLazy("Heading", "Text");
|
||||
const container = findByPropsLazy("memberSinceContainer");
|
||||
const { getCreatedAtDate } = findByPropsLazy("getCreatedAtDate");
|
||||
const clydeMoreInfo = findByPropsLazy("clydeMoreInfo");
|
||||
const locale = findByPropsLazy("getLocale");
|
||||
const lastSection = findByPropsLazy("lastSection");
|
||||
|
||||
export default definePlugin({
|
||||
name: "FriendsSince",
|
||||
description: "Shows when you became friends with someone in the user popout",
|
||||
authors: [Devs.Elvyra],
|
||||
patches: [
|
||||
{
|
||||
find: ".AnalyticsSections.USER_PROFILE}",
|
||||
replacement: {
|
||||
match: /\i.default,\{userId:(\i.id).{0,30}}\)/,
|
||||
replace: "$&,$self.friendsSince({ userId: $1 })"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: ".UserPopoutUpsellSource.PROFILE_PANEL,",
|
||||
replacement: {
|
||||
match: /\i.default,\{userId:(\i)}\)/,
|
||||
replace: "$&,$self.friendsSince({ userId: $1 })"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
friendsSince: ErrorBoundary.wrap(({ userId }: { userId: string; }) => {
|
||||
const friendsSince = RelationshipStore.getSince(userId);
|
||||
if (!friendsSince) return null;
|
||||
|
||||
return (
|
||||
<div className={lastSection.section}>
|
||||
<Heading variant="eyebrow" className={clydeMoreInfo.title}>
|
||||
Friends Since
|
||||
</Heading>
|
||||
|
||||
<div className={container.memberSinceContainer}>
|
||||
<Text variant="text-sm/normal" className={clydeMoreInfo.body}>
|
||||
{getCreatedAtDate(friendsSince, locale.getLocale())}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}, { noop: true })
|
||||
});
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Flex } from "@components/Flex";
|
||||
import { InfoIcon, OwnerCrownIcon } from "@components/Icons";
|
||||
import { getUniqueUsername } from "@utils/discord";
|
||||
import { getGuildRoles, getUniqueUsername } from "@utils/discord";
|
||||
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import { ContextMenuApi, FluxDispatcher, GuildMemberStore, Menu, PermissionsBits, Text, Tooltip, useEffect, UserStore, useState, useStateFromStores } from "@webpack/common";
|
||||
import type { Guild } from "discord-types/general";
|
||||
|
@ -78,6 +78,8 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
|||
const [selectedItemIndex, selectItem] = useState(0);
|
||||
const selectedItem = permissions[selectedItemIndex];
|
||||
|
||||
const roles = getGuildRoles(guild.id);
|
||||
|
||||
return (
|
||||
<ModalRoot
|
||||
{...modalProps}
|
||||
|
@ -100,7 +102,7 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
|||
<div className={cl("perms-list")}>
|
||||
{permissions.map((permission, index) => {
|
||||
const user = UserStore.getUser(permission.id ?? "");
|
||||
const role = guild.roles[permission.id ?? ""];
|
||||
const role = roles[permission.id ?? ""];
|
||||
|
||||
return (
|
||||
<button
|
||||
|
@ -201,7 +203,7 @@ function RoleContextMenu({ guild, roleId, onClose }: { guild: Guild; roleId: str
|
|||
id="vc-pw-view-as-role"
|
||||
label="View As Role"
|
||||
action={() => {
|
||||
const role = guild.roles[roleId];
|
||||
const role = getGuildRoles(guild.id)[roleId];
|
||||
if (!role) return;
|
||||
|
||||
onClose();
|
||||
|
|
|
@ -21,6 +21,7 @@ import "./styles.css";
|
|||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getGuildRoles } from "@utils/discord";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { ChannelStore, GuildMemberStore, GuildStore, Menu, PermissionsBits, UserStore } from "@webpack/common";
|
||||
import type { Guild, GuildMember } from "discord-types/general";
|
||||
|
@ -107,7 +108,7 @@ function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
|||
}
|
||||
|
||||
default: {
|
||||
permissions = Object.values(guild.roles).map(role => ({
|
||||
permissions = Object.values(getGuildRoles(guild.id)).map(role => ({
|
||||
type: PermissionType.Role,
|
||||
...role
|
||||
}));
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
*/
|
||||
|
||||
import { classNameFactory } from "@api/Styles";
|
||||
import { getGuildRoles } from "@utils/discord";
|
||||
import { wordsToTitle } from "@utils/text";
|
||||
import { GuildStore, i18n, Parser } from "@webpack/common";
|
||||
import { i18n, Parser } from "@webpack/common";
|
||||
import { Guild, GuildMember, Role } from "discord-types/general";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
|
@ -67,7 +68,9 @@ export function getPermissionDescription(permission: string): ReactNode {
|
|||
return "";
|
||||
}
|
||||
|
||||
export function getSortedRoles({ roles, id }: Guild, member: GuildMember) {
|
||||
export function getSortedRoles({ id }: Guild, member: GuildMember) {
|
||||
const roles = getGuildRoles(id);
|
||||
|
||||
return [...member.roles, id]
|
||||
.map(id => roles[id])
|
||||
.sort((a, b) => b.position - a.position);
|
||||
|
@ -85,13 +88,13 @@ export function sortUserRoles(roles: Role[]) {
|
|||
}
|
||||
|
||||
export function sortPermissionOverwrites<T extends { id: string; type: number; }>(overwrites: T[], guildId: string) {
|
||||
const guild = GuildStore.getGuild(guildId);
|
||||
const roles = getGuildRoles(guildId);
|
||||
|
||||
return overwrites.sort((a, b) => {
|
||||
if (a.type !== PermissionType.Role || b.type !== PermissionType.Role) return 0;
|
||||
|
||||
const roleA = guild.roles[a.id];
|
||||
const roleB = guild.roles[b.id];
|
||||
const roleA = roles[a.id];
|
||||
const roleB = roles[b.id];
|
||||
|
||||
return roleB.position - roleA.position;
|
||||
});
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
Brings back the phased out [Server Home](https://support.discord.com/hc/en-us/articles/6156116949911-Server-Home-Beta) feature!
|
||||
|
||||
![](https://private-user-images.githubusercontent.com/47677887/309572891-a9ee7354-9e5e-4b81-8faf-304d9c44f512.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDk0OTE5MTIsIm5iZiI6MTcwOTQ5MTYxMiwicGF0aCI6Ii80NzY3Nzg4Ny8zMDk1NzI4OTEtYTllZTczNTQtOWU1ZS00YjgxLThmYWYtMzA0ZDljNDRmNTEyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAzMDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMzAzVDE4NDY1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBhYzUxMWY1MzQxNTA4NDE1MWU0YjAxNzM1NzI1YWJkMTNiZmNkNjRmYTRkZDg1ZDE5NzdkMjM0MGVjMDA0OWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TPYWPRWHTJstfviT9HOaBWFkbBhokyxiDC-gOVL2dqs)
|
||||
![](https://github.com/Vendicated/Vencord/assets/61953774/98d5d667-bbb9-48b8-872d-c9b3980f6506)
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
import { definePluginSettings } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getGuildRoles } from "@utils/discord";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { ChannelStore, GuildMemberStore, GuildStore } from "@webpack/common";
|
||||
import { ChannelStore, GuildMemberStore } from "@webpack/common";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
chatMentions: {
|
||||
|
@ -114,8 +115,7 @@ export default definePlugin({
|
|||
},
|
||||
|
||||
roleGroupColor: ErrorBoundary.wrap(({ id, count, title, guildId, label }: { id: string; count: number; title: string; guildId: string; label: string; }) => {
|
||||
const guild = GuildStore.getGuild(guildId);
|
||||
const role = guild?.roles[id];
|
||||
const role = getGuildRoles(guildId)[id];
|
||||
|
||||
return (
|
||||
<span style={{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import "./styles.css";
|
||||
|
||||
import { classNameFactory } from "@api/Styles";
|
||||
import { openImageModal, openUserProfile } from "@utils/discord";
|
||||
import { getGuildRoles, openImageModal, openUserProfile } from "@utils/discord";
|
||||
import { classes } from "@utils/misc";
|
||||
import { ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import { useAwaiter } from "@utils/react";
|
||||
|
@ -172,7 +172,7 @@ function ServerInfoTab({ guild }: GuildProps) {
|
|||
"Verification Level": ["None", "Low", "Medium", "High", "Highest"][guild.verificationLevel] || "?",
|
||||
"Nitro Boosts": `${guild.premiumSubscriberCount ?? 0} (Level ${guild.premiumTier ?? 0})`,
|
||||
"Channels": GuildChannelStore.getChannels(guild.id)?.count - 1 || "?", // - null category
|
||||
"Roles": Object.keys(guild.roles).length - 1, // - @everyone
|
||||
"Roles": Object.keys(getGuildRoles(guild.id)).length - 1, // - @everyone
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
@ -4,8 +4,13 @@
|
|||
}
|
||||
|
||||
.vc-gp-banner {
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
aspect-ratio: auto 240 / 135;
|
||||
height: 334px;
|
||||
width: 100%;
|
||||
object-fit: cover;
|
||||
overflow: clip;
|
||||
overflow-clip-margin: content-box;
|
||||
}
|
||||
|
||||
.vc-gp-header {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import { definePluginSettings } from "@api/Settings";
|
||||
import { makeRange } from "@components/PluginSettings/components";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getGuildRoles } from "@utils/discord";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin, { OptionType, PluginNative } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
|
@ -196,7 +197,7 @@ export default definePlugin({
|
|||
|
||||
if (message.mention_roles.length > 0) {
|
||||
for (const roleId of message.mention_roles) {
|
||||
const role = GuildStore.getGuild(channel.guild_id).roles[roleId];
|
||||
const role = getGuildRoles(channel.guild_id)[roleId];
|
||||
if (!role) continue;
|
||||
const roleColor = role.colorString ?? `#${pingColor}`;
|
||||
finalMsg = finalMsg.replace(`<@&${roleId}>`, `<b><color=${roleColor}>@${role.name}</color></b>`);
|
||||
|
|
|
@ -428,6 +428,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
id: 347096063569559553n
|
||||
},
|
||||
|
||||
Elvyra: {
|
||||
name: "Elvyra",
|
||||
id: 708275751816003615n,
|
||||
}
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
// iife so #__PURE__ works correctly
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import { MessageObject } from "@api/MessageEvents";
|
||||
import { ChannelStore, ComponentDispatch, FluxDispatcher, GuildStore, InviteActions, MaskedLink, MessageActions, ModalImageClasses, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
||||
import { Guild, Message, User } from "discord-types/general";
|
||||
import { Guild, Message, Role, User } from "discord-types/general";
|
||||
|
||||
import { ImageModal, ModalRoot, ModalSize, openModal } from "./modal";
|
||||
|
||||
|
@ -185,3 +185,11 @@ export async function fetchUserProfile(id: string, options?: FetchUserProfileOpt
|
|||
export function getUniqueUsername(user: User) {
|
||||
return user.discriminator === "0" ? user.username : user.tag;
|
||||
}
|
||||
|
||||
// FIXME: remove this once discord merges the role change into stable
|
||||
export function getGuildRoles(guildId: string): Record<string, Role> {
|
||||
if ("getRoles" in GuildStore)
|
||||
return (GuildStore as any).getRoles(guildId);
|
||||
|
||||
return GuildStore.getGuild(guildId)?.roles ?? {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue