mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 18:06:22 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
2dec657e9b
25 changed files with 144 additions and 104 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.9.9",
|
"version": "1.10.1",
|
||||||
"description": "The cutest Discord client mod",
|
"description": "The cutest Discord client mod",
|
||||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Logger } from "@utils/Logger";
|
||||||
import { makeCodeblock } from "@utils/text";
|
import { makeCodeblock } from "@utils/text";
|
||||||
|
|
||||||
import { sendBotMessage } from "./commandHelpers";
|
import { sendBotMessage } from "./commandHelpers";
|
||||||
|
@ -46,10 +47,10 @@ export let RequiredMessageOption: Option = ReqPlaceholder;
|
||||||
export const _init = function (cmds: Command[]) {
|
export const _init = function (cmds: Command[]) {
|
||||||
try {
|
try {
|
||||||
BUILT_IN = cmds;
|
BUILT_IN = cmds;
|
||||||
OptionalMessageOption = cmds.find(c => c.name === "shrug")!.options![0];
|
OptionalMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "shrug")!.options![0];
|
||||||
RequiredMessageOption = cmds.find(c => c.name === "me")!.options![0];
|
RequiredMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "me")!.options![0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to load CommandsApi");
|
new Logger("CommandsAPI").error("Failed to load CommandsApi", e, " - cmds is", cmds);
|
||||||
}
|
}
|
||||||
return cmds;
|
return cmds;
|
||||||
} as never;
|
} as never;
|
||||||
|
@ -138,6 +139,8 @@ export function registerCommand<C extends Command>(command: C, plugin: string) {
|
||||||
throw new Error(`Command '${command.name}' already exists.`);
|
throw new Error(`Command '${command.name}' already exists.`);
|
||||||
|
|
||||||
command.isVencordCommand = true;
|
command.isVencordCommand = true;
|
||||||
|
command.untranslatedName ??= command.name;
|
||||||
|
command.untranslatedDescription ??= command.description;
|
||||||
command.id ??= `-${BUILT_IN.length + 1}`;
|
command.id ??= `-${BUILT_IN.length + 1}`;
|
||||||
command.applicationId ??= "-1"; // BUILT_IN;
|
command.applicationId ??= "-1"; // BUILT_IN;
|
||||||
command.type ??= ApplicationCommandType.CHAT_INPUT;
|
command.type ??= ApplicationCommandType.CHAT_INPUT;
|
||||||
|
|
|
@ -93,8 +93,10 @@ export interface Command {
|
||||||
isVencordCommand?: boolean;
|
isVencordCommand?: boolean;
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
|
untranslatedName?: string;
|
||||||
displayName?: string;
|
displayName?: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
untranslatedDescription?: string;
|
||||||
displayDescription?: string;
|
displayDescription?: string;
|
||||||
|
|
||||||
options?: Option[];
|
options?: Option[];
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[class*="profileBadges"] {
|
|
||||||
flex: none;
|
|
||||||
}
|
|
|
@ -16,8 +16,6 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "./fixBadgeOverflow.css";
|
|
||||||
|
|
||||||
import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
|
import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
|
||||||
import DonateButton from "@components/DonateButton";
|
import DonateButton from "@components/DonateButton";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
@ -79,7 +77,7 @@ export default definePlugin({
|
||||||
replace: "...$1.props,$& $1.image??"
|
replace: "...$1.props,$& $1.image??"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(?<=text:(\i)\.description,.{0,50})children:/,
|
match: /(?<=text:(\i)\.description,.{0,200})children:/,
|
||||||
replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
|
replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
|
||||||
},
|
},
|
||||||
// conditionally override their onClick with badge.onClick if it exists
|
// conditionally override their onClick with badge.onClick if it exists
|
||||||
|
|
|
@ -34,7 +34,7 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "Messages.SERVERS,children",
|
find: "Messages.SERVERS,children",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=Messages\.SERVERS,children:).+?default:return null\}\}\)/,
|
match: /(?<=Messages\.SERVERS,children:)\i\.map\(\i\)/,
|
||||||
replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)"
|
replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,8 +132,8 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
// Export the isBetterFolders variable to the folders component
|
// Export the isBetterFolders variable to the folders component
|
||||||
{
|
{
|
||||||
match: /(?<=\.Messages\.SERVERS.+?switch\((\i)\.type\){case \i\.\i\.FOLDER:.+?folderNode:\i,)/,
|
match: /switch\(\i\.type\){case \i\.\i\.FOLDER:.+?folderNode:\i,/,
|
||||||
replace: 'isBetterFolders:typeof isBetterFolders!=="undefined"?isBetterFolders:false,'
|
replace: '$&isBetterFolders:typeof isBetterFolders!=="undefined"?isBetterFolders:false,'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -46,7 +46,7 @@ const embedUrlRe = /https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]{11})/;
|
||||||
async function embedDidMount(this: Component<Props>) {
|
async function embedDidMount(this: Component<Props>) {
|
||||||
try {
|
try {
|
||||||
const { embed } = this.props;
|
const { embed } = this.props;
|
||||||
const { replaceElements } = settings.store;
|
const { replaceElements, dearrowByDefault } = settings.store;
|
||||||
|
|
||||||
if (!embed || embed.dearrow || embed.provider?.name !== "YouTube" || !embed.video?.url) return;
|
if (!embed || embed.dearrow || embed.provider?.name !== "YouTube" || !embed.video?.url) return;
|
||||||
|
|
||||||
|
@ -63,18 +63,22 @@ async function embedDidMount(this: Component<Props>) {
|
||||||
|
|
||||||
if (!hasTitle && !hasThumb) return;
|
if (!hasTitle && !hasThumb) return;
|
||||||
|
|
||||||
|
|
||||||
embed.dearrow = {
|
embed.dearrow = {
|
||||||
enabled: true
|
enabled: dearrowByDefault
|
||||||
};
|
};
|
||||||
|
|
||||||
if (hasTitle && replaceElements !== ReplaceElements.ReplaceThumbnailsOnly) {
|
if (hasTitle && replaceElements !== ReplaceElements.ReplaceThumbnailsOnly) {
|
||||||
embed.dearrow.oldTitle = embed.rawTitle;
|
const replacementTitle = titles[0].title.replace(/(^|\s)>(\S)/g, "$1$2");
|
||||||
embed.rawTitle = titles[0].title.replace(/(^|\s)>(\S)/g, "$1$2");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
embed.dearrow.oldTitle = dearrowByDefault ? embed.rawTitle : replacementTitle;
|
||||||
|
if (dearrowByDefault) embed.rawTitle = replacementTitle;
|
||||||
|
}
|
||||||
if (hasThumb && replaceElements !== ReplaceElements.ReplaceTitlesOnly) {
|
if (hasThumb && replaceElements !== ReplaceElements.ReplaceTitlesOnly) {
|
||||||
embed.dearrow.oldThumb = embed.thumbnail.proxyURL;
|
const replacementProxyURL = `https://dearrow-thumb.ajay.app/api/v1/getThumbnail?videoID=${videoId}&time=${thumbnails[0].timestamp}`;
|
||||||
embed.thumbnail.proxyURL = `https://dearrow-thumb.ajay.app/api/v1/getThumbnail?videoID=${videoId}&time=${thumbnails[0].timestamp}`;
|
|
||||||
|
embed.dearrow.oldThumb = dearrowByDefault ? embed.thumbnail.proxyURL : replacementProxyURL;
|
||||||
|
if (dearrowByDefault) embed.thumbnail.proxyURL = replacementProxyURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
|
@ -96,6 +100,7 @@ function DearrowButton({ component }: { component: Component<Props>; }) {
|
||||||
className={"vc-dearrow-toggle-" + (embed.dearrow.enabled ? "on" : "off")}
|
className={"vc-dearrow-toggle-" + (embed.dearrow.enabled ? "on" : "off")}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const { enabled, oldThumb, oldTitle } = embed.dearrow;
|
const { enabled, oldThumb, oldTitle } = embed.dearrow;
|
||||||
|
settings.store.dearrowByDefault = !enabled;
|
||||||
embed.dearrow.enabled = !enabled;
|
embed.dearrow.enabled = !enabled;
|
||||||
if (oldTitle) {
|
if (oldTitle) {
|
||||||
embed.dearrow.oldTitle = embed.rawTitle;
|
embed.dearrow.oldTitle = embed.rawTitle;
|
||||||
|
@ -153,6 +158,12 @@ const settings = definePluginSettings({
|
||||||
{ label: "Titles", value: ReplaceElements.ReplaceTitlesOnly },
|
{ label: "Titles", value: ReplaceElements.ReplaceTitlesOnly },
|
||||||
{ label: "Thumbnails", value: ReplaceElements.ReplaceThumbnailsOnly },
|
{ label: "Thumbnails", value: ReplaceElements.ReplaceThumbnailsOnly },
|
||||||
],
|
],
|
||||||
|
},
|
||||||
|
dearrowByDefault: {
|
||||||
|
description: "Dearrow videos automatically",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: true,
|
||||||
|
restartNeeded: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,15 @@
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getCurrentChannel } from "@utils/discord";
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
import { Logger } from "@utils/Logger";
|
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findLazy } from "@webpack";
|
import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
||||||
import { Heading, RelationshipStore, Text } from "@webpack/common";
|
import { RelationshipStore, Text } from "@webpack/common";
|
||||||
|
|
||||||
const containerWrapper = findByPropsLazy("memberSinceWrapper");
|
const containerWrapper = findByPropsLazy("memberSinceWrapper");
|
||||||
const container = findByPropsLazy("memberSince");
|
const container = findByPropsLazy("memberSince");
|
||||||
const getCreatedAtDate = findByCodeLazy('month:"short",day:"numeric"');
|
const getCreatedAtDate = findByCodeLazy('month:"short",day:"numeric"');
|
||||||
const locale = findByPropsLazy("getLocale");
|
const locale = findByPropsLazy("getLocale");
|
||||||
const section = findLazy((m: any) => m.section !== void 0 && m.heading !== void 0 && Object.values(m).length === 2);
|
const Section = findComponentByCodeLazy('"auto":"smooth"', ".section");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "FriendsSince",
|
name: "FriendsSince",
|
||||||
|
@ -28,7 +27,7 @@ export default definePlugin({
|
||||||
find: ".PANEL}),nicknameIcons",
|
find: ".PANEL}),nicknameIcons",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id)}\)}\)/,
|
match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id)}\)}\)/,
|
||||||
replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:true})"
|
replace: "$&,$self.FriendsSinceComponent({userId:$1,isSidebar:true})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// User Profile Modal
|
// User Profile Modal
|
||||||
|
@ -36,34 +35,19 @@ export default definePlugin({
|
||||||
find: "action:\"PRESS_APP_CONNECTION\"",
|
find: "action:\"PRESS_APP_CONNECTION\"",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id),.{0,100}}\)}\),/,
|
match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id),.{0,100}}\)}\),/,
|
||||||
replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:false}),"
|
replace: "$&,$self.FriendsSinceComponent({userId:$1,isSidebar:false}),"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
getFriendSince(userId: string) {
|
FriendsSinceComponent: ErrorBoundary.wrap(({ userId, isSidebar }: { userId: string; isSidebar: boolean; }) => {
|
||||||
try {
|
|
||||||
if (!RelationshipStore.isFriend(userId)) return null;
|
|
||||||
|
|
||||||
return RelationshipStore.getSince(userId);
|
|
||||||
} catch (err) {
|
|
||||||
new Logger("FriendsSince").error(err);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
friendsSinceNew: ErrorBoundary.wrap(({ userId, isSidebar }: { userId: string; isSidebar: boolean; }) => {
|
|
||||||
if (!RelationshipStore.isFriend(userId)) return null;
|
if (!RelationshipStore.isFriend(userId)) return null;
|
||||||
|
|
||||||
const friendsSince = RelationshipStore.getSince(userId);
|
const friendsSince = RelationshipStore.getSince(userId);
|
||||||
if (!friendsSince) return null;
|
if (!friendsSince) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={section.section}>
|
<Section heading="Friends Since">
|
||||||
<Heading variant="text-xs/semibold" style={isSidebar ? {} : { color: "var(--header-secondary)" }}>
|
|
||||||
Friends Since
|
|
||||||
</Heading>
|
|
||||||
|
|
||||||
{
|
{
|
||||||
isSidebar ? (
|
isSidebar ? (
|
||||||
<Text variant="text-sm/normal">
|
<Text variant="text-sm/normal">
|
||||||
|
@ -91,8 +75,7 @@ export default definePlugin({
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
</Section>
|
||||||
</section>
|
|
||||||
);
|
);
|
||||||
}, { noop: true }),
|
}, { noop: true }),
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { OnlineMemberCountStore } from "./OnlineMemberCountStore";
|
||||||
export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) {
|
export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) {
|
||||||
const currentChannel = useStateFromStores([SelectedChannelStore], () => getCurrentChannel());
|
const currentChannel = useStateFromStores([SelectedChannelStore], () => getCurrentChannel());
|
||||||
|
|
||||||
const guildId = isTooltip ? tooltipGuildId! : currentChannel.guild_id;
|
const guildId = isTooltip ? tooltipGuildId! : currentChannel?.guild_id;
|
||||||
|
|
||||||
const totalCount = useStateFromStores(
|
const totalCount = useStateFromStores(
|
||||||
[GuildMemberCountStore],
|
[GuildMemberCountStore],
|
||||||
|
@ -33,7 +33,7 @@ export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; t
|
||||||
|
|
||||||
const threadGroups = useStateFromStores(
|
const threadGroups = useStateFromStores(
|
||||||
[ThreadMemberListStore],
|
[ThreadMemberListStore],
|
||||||
() => ThreadMemberListStore.getMemberListSections(currentChannel.id)
|
() => ThreadMemberListStore.getMemberListSections(currentChannel?.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isTooltip && (groups.length >= 1 || groups[0].id !== "unknown")) {
|
if (!isTooltip && (groups.length >= 1 || groups[0].id !== "unknown")) {
|
||||||
|
|
|
@ -15,8 +15,8 @@ export const OnlineMemberCountStore = proxyLazy(() => {
|
||||||
const onlineMemberMap = new Map<string, number>();
|
const onlineMemberMap = new Map<string, number>();
|
||||||
|
|
||||||
class OnlineMemberCountStore extends Flux.Store {
|
class OnlineMemberCountStore extends Flux.Store {
|
||||||
getCount(guildId: string) {
|
getCount(guildId?: string) {
|
||||||
return onlineMemberMap.get(guildId);
|
return onlineMemberMap.get(guildId!);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _ensureCount(guildId: string) {
|
async _ensureCount(guildId: string) {
|
||||||
|
@ -25,8 +25,8 @@ export const OnlineMemberCountStore = proxyLazy(() => {
|
||||||
await PrivateChannelsStore.preload(guildId, GuildChannelStore.getDefaultChannel(guildId).id);
|
await PrivateChannelsStore.preload(guildId, GuildChannelStore.getDefaultChannel(guildId).id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureCount(guildId: string) {
|
ensureCount(guildId?: string) {
|
||||||
if (onlineMemberMap.has(guildId)) return;
|
if (!guildId || onlineMemberMap.has(guildId)) return;
|
||||||
|
|
||||||
preloadQueue.push(() =>
|
preloadQueue.push(() =>
|
||||||
this._ensureCount(guildId)
|
this._ensureCount(guildId)
|
||||||
|
|
|
@ -28,12 +28,12 @@ import { FluxStore } from "@webpack/types";
|
||||||
|
|
||||||
import { MemberCount } from "./MemberCount";
|
import { MemberCount } from "./MemberCount";
|
||||||
|
|
||||||
export const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; };
|
export const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId?: string): number | null; };
|
||||||
export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
|
export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
|
||||||
getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; };
|
getProps(guildId?: string, channelId?: string): { groups: { count: number; id: string; }[]; };
|
||||||
};
|
};
|
||||||
export const ThreadMemberListStore = findStoreLazy("ThreadMemberListStore") as FluxStore & {
|
export const ThreadMemberListStore = findStoreLazy("ThreadMemberListStore") as FluxStore & {
|
||||||
getMemberListSections(channelId: string): { [sectionId: string]: { sectionId: string; userIds: string[]; }; };
|
getMemberListSections(channelId?: string): { [sectionId: string]: { sectionId: string; userIds: string[]; }; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,3 +9,8 @@
|
||||||
.vc-mentionAvatars-role-icon {
|
.vc-mentionAvatars-role-icon {
|
||||||
margin: 0 2px 0.2rem 4px;
|
margin: 0 2px 0.2rem 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** don't display inside the ServerInfo modal owner mention */
|
||||||
|
.vc-gp-owner .vc-mentionAvatars-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
shouldSkip(guildId: string, emoji: any) {
|
shouldSkip(guildId: string, emoji: any) {
|
||||||
if (emoji.type !== "GUILD_EMOJI") {
|
if (emoji.type !== 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (settings.store.shownEmojis === "onlyUnicode") {
|
if (settings.store.shownEmojis === "onlyUnicode") {
|
||||||
|
|
|
@ -57,7 +57,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /text:\i\.\i.Messages.USER_PROFILE_PRONOUNS/,
|
match: /text:\i\.\i.Messages.USER_PROFILE_PRONOUNS/,
|
||||||
replace: '$&+vcHasPendingPronouns?"":` (${vcPronounSource})`'
|
replace: '$&+(vcHasPendingPronouns?"":` (${vcPronounSource})`)'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(\.pronounsText.+?children:)(\i)/,
|
match: /(\.pronounsText.+?children:)(\i)/,
|
||||||
|
|
|
@ -22,12 +22,13 @@ import { useForceUpdater } from "@utils/react";
|
||||||
import { Paginator, Text, useRef, useState } from "@webpack/common";
|
import { Paginator, Text, useRef, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { Auth } from "../auth";
|
import { Auth } from "../auth";
|
||||||
|
import { ReviewType } from "../entities";
|
||||||
import { Response, REVIEWS_PER_PAGE } from "../reviewDbApi";
|
import { Response, REVIEWS_PER_PAGE } from "../reviewDbApi";
|
||||||
import { cl } from "../utils";
|
import { cl } from "../utils";
|
||||||
import ReviewComponent from "./ReviewComponent";
|
import ReviewComponent from "./ReviewComponent";
|
||||||
import ReviewsView, { ReviewsInputComponent } from "./ReviewsView";
|
import ReviewsView, { ReviewsInputComponent } from "./ReviewsView";
|
||||||
|
|
||||||
function Modal({ modalProps, modalKey, discordId, name }: { modalProps: any; modalKey: string, discordId: string; name: string; }) {
|
function Modal({ modalProps, modalKey, discordId, name, type }: { modalProps: any; modalKey: string, discordId: string; name: string; type: ReviewType; }) {
|
||||||
const [data, setData] = useState<Response>();
|
const [data, setData] = useState<Response>();
|
||||||
const [signal, refetch] = useForceUpdater(true);
|
const [signal, refetch] = useForceUpdater(true);
|
||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
|
@ -58,6 +59,7 @@ function Modal({ modalProps, modalKey, discordId, name }: { modalProps: any; mod
|
||||||
onFetchReviews={setData}
|
onFetchReviews={setData}
|
||||||
scrollToTop={() => ref.current?.scrollTo({ top: 0, behavior: "smooth" })}
|
scrollToTop={() => ref.current?.scrollTo({ top: 0, behavior: "smooth" })}
|
||||||
hideOwnReview
|
hideOwnReview
|
||||||
|
type={type}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
@ -95,7 +97,7 @@ function Modal({ modalProps, modalKey, discordId, name }: { modalProps: any; mod
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openReviewsModal(discordId: string, name: string) {
|
export function openReviewsModal(discordId: string, name: string, type: ReviewType) {
|
||||||
const modalKey = "vc-rdb-modal-" + Date.now();
|
const modalKey = "vc-rdb-modal-" + Date.now();
|
||||||
|
|
||||||
openModal(props => (
|
openModal(props => (
|
||||||
|
@ -104,6 +106,7 @@ export function openReviewsModal(discordId: string, name: string) {
|
||||||
modalProps={props}
|
modalProps={props}
|
||||||
discordId={discordId}
|
discordId={discordId}
|
||||||
name={name}
|
name={name}
|
||||||
|
type={type}
|
||||||
/>
|
/>
|
||||||
), { modalKey });
|
), { modalKey });
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpa
|
||||||
import { Forms, React, RelationshipStore, useRef, UserStore } from "@webpack/common";
|
import { Forms, React, RelationshipStore, useRef, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
import { Auth, authorize } from "../auth";
|
import { Auth, authorize } from "../auth";
|
||||||
import { Review } from "../entities";
|
import { Review, ReviewType } from "../entities";
|
||||||
import { addReview, getReviews, Response, REVIEWS_PER_PAGE } from "../reviewDbApi";
|
import { addReview, getReviews, Response, REVIEWS_PER_PAGE } from "../reviewDbApi";
|
||||||
import { settings } from "../settings";
|
import { settings } from "../settings";
|
||||||
import { cl, showToast } from "../utils";
|
import { cl, showToast } from "../utils";
|
||||||
|
@ -45,6 +45,7 @@ interface Props extends UserProps {
|
||||||
page?: number;
|
page?: number;
|
||||||
scrollToTop?(): void;
|
scrollToTop?(): void;
|
||||||
hideOwnReview?: boolean;
|
hideOwnReview?: boolean;
|
||||||
|
type: ReviewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ReviewsView({
|
export default function ReviewsView({
|
||||||
|
@ -56,6 +57,7 @@ export default function ReviewsView({
|
||||||
page = 1,
|
page = 1,
|
||||||
showInput = false,
|
showInput = false,
|
||||||
hideOwnReview = false,
|
hideOwnReview = false,
|
||||||
|
type,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const [signal, refetch] = useForceUpdater(true);
|
const [signal, refetch] = useForceUpdater(true);
|
||||||
|
|
||||||
|
@ -80,6 +82,7 @@ export default function ReviewsView({
|
||||||
reviews={reviewData!.reviews}
|
reviews={reviewData!.reviews}
|
||||||
hideOwnReview={hideOwnReview}
|
hideOwnReview={hideOwnReview}
|
||||||
profileId={discordId}
|
profileId={discordId}
|
||||||
|
type={type}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{showInput && (
|
{showInput && (
|
||||||
|
@ -94,7 +97,7 @@ export default function ReviewsView({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ReviewList({ refetch, reviews, hideOwnReview, profileId }: { refetch(): void; reviews: Review[]; hideOwnReview: boolean; profileId: string; }) {
|
function ReviewList({ refetch, reviews, hideOwnReview, profileId, type }: { refetch(): void; reviews: Review[]; hideOwnReview: boolean; profileId: string; type: ReviewType; }) {
|
||||||
const myId = UserStore.getCurrentUser().id;
|
const myId = UserStore.getCurrentUser().id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -111,7 +114,7 @@ function ReviewList({ refetch, reviews, hideOwnReview, profileId }: { refetch():
|
||||||
|
|
||||||
{reviews?.length === 0 && (
|
{reviews?.length === 0 && (
|
||||||
<Forms.FormText className={cl("placeholder")}>
|
<Forms.FormText className={cl("placeholder")}>
|
||||||
Looks like nobody reviewed this user yet. You could be the first!
|
Looks like nobody reviewed this {type === ReviewType.User ? "user" : "server"} yet. You could be the first!
|
||||||
</Forms.FormText>
|
</Forms.FormText>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -30,7 +30,7 @@ import { Guild, User } from "discord-types/general";
|
||||||
|
|
||||||
import { Auth, initAuth, updateAuth } from "./auth";
|
import { Auth, initAuth, updateAuth } from "./auth";
|
||||||
import { openReviewsModal } from "./components/ReviewModal";
|
import { openReviewsModal } from "./components/ReviewModal";
|
||||||
import { NotificationType } from "./entities";
|
import { NotificationType, ReviewType } from "./entities";
|
||||||
import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
|
import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
|
||||||
import { settings } from "./settings";
|
import { settings } from "./settings";
|
||||||
import { showToast } from "./utils";
|
import { showToast } from "./utils";
|
||||||
|
@ -44,7 +44,7 @@ const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { gu
|
||||||
label="View Reviews"
|
label="View Reviews"
|
||||||
id="vc-rdb-server-reviews"
|
id="vc-rdb-server-reviews"
|
||||||
icon={OpenExternalIcon}
|
icon={OpenExternalIcon}
|
||||||
action={() => openReviewsModal(guild.id, guild.name)}
|
action={() => openReviewsModal(guild.id, guild.name, ReviewType.Server)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -56,7 +56,7 @@ const userContextPatch: NavContextMenuPatchCallback = (children, { user }: { use
|
||||||
label="View Reviews"
|
label="View Reviews"
|
||||||
id="vc-rdb-user-reviews"
|
id="vc-rdb-user-reviews"
|
||||||
icon={OpenExternalIcon}
|
icon={OpenExternalIcon}
|
||||||
action={() => openReviewsModal(user.id, user.username)}
|
action={() => openReviewsModal(user.id, user.username, ReviewType.User)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -157,7 +157,7 @@ export default definePlugin({
|
||||||
return (
|
return (
|
||||||
<TooltipContainer text="View Reviews">
|
<TooltipContainer text="View Reviews">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => openReviewsModal(user.id, user.username)}
|
onClick={() => openReviewsModal(user.id, user.username, ReviewType.User)}
|
||||||
look={Button.Looks.FILLED}
|
look={Button.Looks.FILLED}
|
||||||
size={Button.Sizes.NONE}
|
size={Button.Sizes.NONE}
|
||||||
color={RoleButtonClasses.bannerColor}
|
color={RoleButtonClasses.bannerColor}
|
||||||
|
|
|
@ -57,7 +57,7 @@ export default definePlugin({
|
||||||
patches: [
|
patches: [
|
||||||
// Chat Mentions
|
// Chat Mentions
|
||||||
{
|
{
|
||||||
find: 'location:"UserMention',
|
find: ".USER_MENTION)",
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /onContextMenu:\i,color:\i,\.\.\.\i(?=,children:)(?<=user:(\i),channel:(\i).{0,500}?)/,
|
match: /onContextMenu:\i,color:\i,\.\.\.\i(?=,children:)(?<=user:(\i),channel:(\i).{0,500}?)/,
|
||||||
|
|
|
@ -4,21 +4,38 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
onlySnow: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Only play the Snow Halation Theme",
|
||||||
|
default: false,
|
||||||
|
restartNeeded: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// NOTE - Ultimately should probably be turned into a ringtone picker plugin
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "SecretRingToneEnabler",
|
name: "SecretRingToneEnabler",
|
||||||
description: "Always play the secret version of the discord ringtone (except during special ringtone events)",
|
description: "Always play the secret version of the discord ringtone (except during special ringtone events)",
|
||||||
authors: [Devs.AndrewDLO, Devs.FieryFlames],
|
authors: [Devs.AndrewDLO, Devs.FieryFlames, Devs.RamziAH],
|
||||||
|
settings,
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: '"call_ringing_beat"',
|
find: '"call_ringing_beat"',
|
||||||
replacement: {
|
replacement: [
|
||||||
match: /500!==\i\(\)\.random\(1,1e3\)/,
|
{
|
||||||
replace: "false",
|
match: /500!==\i\(\)\.random\(1,1e3\)/,
|
||||||
}
|
replace: "false"
|
||||||
},
|
},
|
||||||
],
|
{
|
||||||
|
predicate: () => settings.store.onlySnow,
|
||||||
|
match: /"call_ringing_beat",/,
|
||||||
|
replace: ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,7 +39,7 @@ interface StreamData {
|
||||||
gainNode?: GainNode,
|
gainNode?: GainNode,
|
||||||
id: string,
|
id: string,
|
||||||
levelNode: AudioWorkletNode,
|
levelNode: AudioWorkletNode,
|
||||||
sinkId: string,
|
sinkId: string | "default",
|
||||||
stream: MediaStream,
|
stream: MediaStream,
|
||||||
streamSourceNode?: MediaStreamAudioSourceNode,
|
streamSourceNode?: MediaStreamAudioSourceNode,
|
||||||
videoStreamId: string,
|
videoStreamId: string,
|
||||||
|
@ -128,6 +128,12 @@ export default definePlugin({
|
||||||
gain.connect(data.audioContext.destination);
|
gain.connect(data.audioContext.destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
|
if (data.sinkId != null && data.sinkId !== data.audioContext.sinkId && "setSinkId" in AudioContext.prototype) {
|
||||||
|
// @ts-expect-error https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/setSinkId
|
||||||
|
data.audioContext.setSinkId(data.sinkId);
|
||||||
|
}
|
||||||
|
|
||||||
data.gainNode.gain.value = data._mute
|
data.gainNode.gain.value = data._mute
|
||||||
? 0
|
? 0
|
||||||
: data._volume / 100;
|
: data._volume / 100;
|
||||||
|
|
|
@ -86,7 +86,7 @@ interface NotificationObject {
|
||||||
title: string;
|
title: string;
|
||||||
content: string;
|
content: string;
|
||||||
useBase64Icon: boolean;
|
useBase64Icon: boolean;
|
||||||
icon: ArrayBuffer | string;
|
icon: string;
|
||||||
sourceApp: string;
|
sourceApp: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,23 +320,29 @@ function shouldIgnoreForChannelType(channel: Channel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMsgNotif(titleString: string, content: string, message: Message) {
|
function sendMsgNotif(titleString: string, content: string, message: Message) {
|
||||||
fetch(`https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.png?size=128`).then(response => response.arrayBuffer()).then(result => {
|
fetch(`https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.png?size=128`)
|
||||||
const msgData: NotificationObject = {
|
.then(response => response.blob())
|
||||||
type: 1,
|
.then(blob => new Promise<string>(resolve => {
|
||||||
timeout: settings.store.lengthBasedTimeout ? calculateTimeout(content) : settings.store.timeout,
|
const r = new FileReader();
|
||||||
height: calculateHeight(content),
|
r.onload = () => resolve((r.result as string).split(",")[1]);
|
||||||
opacity: settings.store.opacity,
|
r.readAsDataURL(blob);
|
||||||
volume: settings.store.volume,
|
})).then(result => {
|
||||||
audioPath: settings.store.soundPath,
|
const msgData: NotificationObject = {
|
||||||
title: titleString,
|
type: 1,
|
||||||
content: content,
|
timeout: settings.store.lengthBasedTimeout ? calculateTimeout(content) : settings.store.timeout,
|
||||||
useBase64Icon: true,
|
height: calculateHeight(content),
|
||||||
icon: new TextDecoder().decode(result),
|
opacity: settings.store.opacity,
|
||||||
sourceApp: "Vencord"
|
volume: settings.store.volume,
|
||||||
};
|
audioPath: settings.store.soundPath,
|
||||||
|
title: titleString,
|
||||||
|
content: content,
|
||||||
|
useBase64Icon: true,
|
||||||
|
icon: result,
|
||||||
|
sourceApp: "Vencord"
|
||||||
|
};
|
||||||
|
|
||||||
sendToOverlay(msgData);
|
sendToOverlay(msgData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendOtherNotif(content: string, titleString: string) {
|
function sendOtherNotif(content: string, titleString: string) {
|
||||||
|
|
|
@ -570,6 +570,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "niko",
|
name: "niko",
|
||||||
id: 341377368075796483n,
|
id: 341377368075796483n,
|
||||||
},
|
},
|
||||||
|
RamziAH: {
|
||||||
|
name: "RamziAH",
|
||||||
|
id: 1279957227612147747n,
|
||||||
|
},
|
||||||
} satisfies Record<string, Dev>);
|
} satisfies Record<string, Dev>);
|
||||||
|
|
||||||
// iife so #__PURE__ works correctly
|
// iife so #__PURE__ works correctly
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
import { MessageObject } from "@api/MessageEvents";
|
import { MessageObject } from "@api/MessageEvents";
|
||||||
import { ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, InviteActions, MaskedLink, MessageActions, ModalImageClasses, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
import { ChannelStore, ComponentDispatch, Constants, 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 { Channel, Guild, Message, User } from "discord-types/general";
|
||||||
|
|
||||||
import { ImageModal, ModalRoot, ModalSize, openModal } from "./modal";
|
import { ImageModal, ModalRoot, ModalSize, openModal } from "./modal";
|
||||||
|
|
||||||
|
@ -54,12 +54,12 @@ export async function openInviteModal(code: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentChannel() {
|
export function getCurrentChannel(): Channel | undefined {
|
||||||
return ChannelStore.getChannel(SelectedChannelStore.getChannelId());
|
return ChannelStore.getChannel(SelectedChannelStore.getChannelId());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentGuild(): Guild | undefined {
|
export function getCurrentGuild(): Guild | undefined {
|
||||||
return GuildStore.getGuild(getCurrentChannel()?.guild_id);
|
return GuildStore.getGuild(getCurrentChannel()?.guild_id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openPrivateChannel(userId: string) {
|
export function openPrivateChannel(userId: string) {
|
||||||
|
|
18
src/webpack/common/types/components.d.ts
vendored
18
src/webpack/common/types/components.d.ts
vendored
|
@ -91,7 +91,7 @@ export type Tooltip = ComponentType<{
|
||||||
/** Tooltip.Colors.BLACK */
|
/** Tooltip.Colors.BLACK */
|
||||||
color?: string;
|
color?: string;
|
||||||
/** TooltipPositions.TOP */
|
/** TooltipPositions.TOP */
|
||||||
position?: string;
|
position?: PopoutPosition;
|
||||||
|
|
||||||
tooltipClassName?: string;
|
tooltipClassName?: string;
|
||||||
tooltipContentClassName?: string;
|
tooltipContentClassName?: string;
|
||||||
|
@ -110,7 +110,7 @@ export type TooltipContainer = ComponentType<PropsWithChildren<{
|
||||||
/** Tooltip.Colors.BLACK */
|
/** Tooltip.Colors.BLACK */
|
||||||
color?: string;
|
color?: string;
|
||||||
/** TooltipPositions.TOP */
|
/** TooltipPositions.TOP */
|
||||||
position?: string;
|
position?: PopoutPosition;
|
||||||
spacing?: number;
|
spacing?: number;
|
||||||
|
|
||||||
className?: string;
|
className?: string;
|
||||||
|
@ -252,7 +252,7 @@ export type Select = ComponentType<PropsWithChildren<{
|
||||||
look?: 0 | 1;
|
look?: 0 | 1;
|
||||||
className?: string;
|
className?: string;
|
||||||
popoutClassName?: string;
|
popoutClassName?: string;
|
||||||
popoutPosition?: "top" | "left" | "right" | "bottom" | "center" | "window_center";
|
popoutPosition?: PopoutPosition;
|
||||||
optionClassName?: string;
|
optionClassName?: string;
|
||||||
|
|
||||||
autoFocus?: boolean;
|
autoFocus?: boolean;
|
||||||
|
@ -293,7 +293,7 @@ export type SearchableSelect = ComponentType<PropsWithChildren<{
|
||||||
className?: string;
|
className?: string;
|
||||||
popoutClassName?: string;
|
popoutClassName?: string;
|
||||||
wrapperClassName?: string;
|
wrapperClassName?: string;
|
||||||
popoutPosition?: "top" | "left" | "right" | "bottom" | "center" | "window_center";
|
popoutPosition?: PopoutPosition;
|
||||||
optionClassName?: string;
|
optionClassName?: string;
|
||||||
|
|
||||||
autoFocus?: boolean;
|
autoFocus?: boolean;
|
||||||
|
@ -376,6 +376,8 @@ declare enum PopoutAnimation {
|
||||||
FADE = "4"
|
FADE = "4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PopoutPosition = "top" | "bottom" | "left" | "right" | "center" | "window_center";
|
||||||
|
|
||||||
export type Popout = ComponentType<{
|
export type Popout = ComponentType<{
|
||||||
children(
|
children(
|
||||||
thing: {
|
thing: {
|
||||||
|
@ -387,7 +389,7 @@ export type Popout = ComponentType<{
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
isShown: boolean;
|
isShown: boolean;
|
||||||
position: string;
|
position: PopoutPosition;
|
||||||
}
|
}
|
||||||
): ReactNode;
|
): ReactNode;
|
||||||
shouldShow?: boolean;
|
shouldShow?: boolean;
|
||||||
|
@ -395,7 +397,7 @@ export type Popout = ComponentType<{
|
||||||
closePopout(): void;
|
closePopout(): void;
|
||||||
isPositioned: boolean;
|
isPositioned: boolean;
|
||||||
nudge: number;
|
nudge: number;
|
||||||
position: string;
|
position: PopoutPosition;
|
||||||
setPopoutRef(ref: any): void;
|
setPopoutRef(ref: any): void;
|
||||||
updatePosition(): void;
|
updatePosition(): void;
|
||||||
}): ReactNode;
|
}): ReactNode;
|
||||||
|
@ -404,13 +406,13 @@ export type Popout = ComponentType<{
|
||||||
onRequestClose?(): void;
|
onRequestClose?(): void;
|
||||||
|
|
||||||
/** "center" and others */
|
/** "center" and others */
|
||||||
align?: string;
|
align?: "left" | "right" | "center";
|
||||||
/** Popout.Animation */
|
/** Popout.Animation */
|
||||||
animation?: PopoutAnimation;
|
animation?: PopoutAnimation;
|
||||||
autoInvert?: boolean;
|
autoInvert?: boolean;
|
||||||
nudgeAlignIntoViewport?: boolean;
|
nudgeAlignIntoViewport?: boolean;
|
||||||
/** "bottom" and others */
|
/** "bottom" and others */
|
||||||
position?: string;
|
position?: PopoutPosition;
|
||||||
positionKey?: string;
|
positionKey?: string;
|
||||||
spacing?: number;
|
spacing?: number;
|
||||||
}> & {
|
}> & {
|
||||||
|
|
Loading…
Reference in a new issue