Finish Suncord Port Hopefully (Equicord)

This commit is contained in:
thororen1234 2024-07-02 18:07:51 -04:00
parent ef086cd1c4
commit 0ef25db8ed
13 changed files with 171 additions and 110 deletions

View file

@ -1,6 +1,6 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated and contributors
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

View file

@ -23,7 +23,7 @@ export const Native = getNative();
import "./styles.css";
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { definePluginSettings, Settings } from "@api/Settings";
import { definePluginSettings, migratePluginSettings, Settings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import { Logger } from "@utils/Logger";
@ -53,6 +53,7 @@ export const cacheSentMessages = new LimitedMap<string, LoggedMessageJSON>();
const cacheThing = findByPropsLazy("commit", "getOrCreate");
let oldGetMessage: typeof MessageStore.getMessage;
const handledMessageIds = new Set();
async function messageDeleteHandler(payload: MessageDeletePayload & { isBulk: boolean; }) {
@ -72,7 +73,7 @@ async function messageDeleteHandler(payload: MessageDeletePayload & { isBulk: bo
handledMessageIds.add(payload.id);
let message: LoggedMessage | LoggedMessageJSON | null =
MessageStore.getMessage(payload.channelId, payload.id);
oldGetMessage?.(payload.channelId, payload.id);
if (message == null) {
// most likely an edited message
const cachedMessage = cacheSentMessages.get(`${payload.channelId},${payload.id}`);
@ -141,8 +142,7 @@ async function messageUpdateHandler(payload: MessageUpdatePayload) {
return;// Flogger.log("this message has been ignored", payload);
}
let message = MessageStore
.getMessage(payload.message.channel_id, payload.message.id) as LoggedMessage | LoggedMessageJSON | null;
let message = oldGetMessage?.(payload.message.channel_id, payload.message.id) as LoggedMessage | LoggedMessageJSON | null;
if (message == null) {
// MESSAGE_UPDATE gets dispatched when emebeds change too and content becomes null
@ -570,8 +570,9 @@ const contextMenuPath: NavContextMenuPatchCallback = (children, props) => {
}
};
migratePluginSettings("MessageLoggerEnhanced", "MLEnhanced");
export default definePlugin({
name: "MLEnhanced",
name: "MessageLoggerEnhanced",
authors: [Devs.Aria],
description: "G'day",
dependencies: ["MessageLogger"],
@ -747,7 +748,7 @@ export default definePlugin({
},
async start() {
this.oldGetMessage = MessageStore.getMessage;
this.oldGetMessage = oldGetMessage = MessageStore.getMessage;
// we have to do this because the original message logger fetches the message from the store now
MessageStore.getMessage = (channelId: string, messageId: string) => {
const MLMessage = LoggedMessageManager.getMessage(channelId, messageId);

View file

@ -79,4 +79,28 @@
.vc-updater-modal-content {
padding: 1rem 2rem;
}
}
div[class*="messagelogger-deleted"] [class*="contents"] > :is(div, h1, h2, h3, p) {
color: var(--text-normal) !important;
}
/* Markdown title highlighting */
div[class*="messagelogger-deleted"] [class*="contents"] :is(h1, h2, h3) {
color: var(--text-normal) !important;
}
/* Bot "thinking" text highlighting */
div[class*="messagelogger-deleted"] [class*="colorStandard"] {
color: var(--text-normal) !important;
}
/* Embed highlighting */
div[class*="messagelogger-deleted"] article :is(div, span, h1, h2, h3, p) {
color: var(--text-normal) !important;
}
div[class*="messagelogger-deleted"] a {
color: var(--text-link) !important;
text-decoration: underline;
}

View file

@ -5,7 +5,7 @@
*/
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
import { definePluginSettings } from "@api/Settings";
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
@ -28,8 +28,9 @@ function replaceQuestionMarks(content: string): string {
}
}
migratePluginSettings("QuestionMarkReplacement", "QuestionMarkReplace");
export default definePlugin({
name: "QuestionMarkReplace",
name: "QuestionMarkReplacement",
description: "Replace all question marks with chosen string, if message only contains question marks.",
authors: [Devs.nyx],

View file

@ -1,84 +0,0 @@
/*
* Vencord, a modification for Discord's desktop app
* Copyright (c) 2022 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 { ApplicationCommandOptionType, findOption } from "@api/Commands";
import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";
export default definePlugin({
name: "Search",
authors: [Devs.JacobTm, EquicordDevs.thororen],
description: "Searchs the web.",
dependencies: ["CommandsAPI"],
commands: [{
name: "search",
description: "Generates search link.",
options: [
{
type: ApplicationCommandOptionType.STRING,
name: "Search query",
description: "What do you want to search?",
required: true
},
{
type: ApplicationCommandOptionType.STRING,
name: "Search engine",
description: "What do you want to search?",
required: true,
choices: [
{ label: "Google", name: "Google", value: "google" },
{ label: "Bing", name: "Bing", value: "bing" },
{ label: "DuckDuckGo", name: "DuckDuckGo", value: "duckduckgo" },
{ label: "Brave", name: "Brave", value: "brave" },
{ label: "Yahoo", name: "Yahoo", value: "yahoo" },
{ label: "Yandex", name: "Yandex", value: "yandex" },
]
}
],
execute(args) {
const rfc3986EncodeURIComponent = str => encodeURIComponent(str).replace(/[!'()*]/g, escape);
const query = findOption<string>(args, "Search query");
const engine = findOption<string>(args, "Search engine");
let link;
switch (engine) {
case "google":
link = `https://google.com/search?query=${rfc3986EncodeURIComponent(query)}`;
break;
case "bing":
link = `https://bing.com/search?q=${rfc3986EncodeURIComponent(query)}`;
break;
case "duckduckgo":
link = `https://duckduckgo.com/${rfc3986EncodeURIComponent(query)}`;
break;
case "brave":
link = `https://search.brave.com/search?q=${rfc3986EncodeURIComponent(query)}`;
break;
case "yahoo":
link = `https://search.yahoo.com/search?p=${rfc3986EncodeURIComponent(query)}`;
break;
case "yandex":
link = `https://yandex.com/search?text=${rfc3986EncodeURIComponent(query)}`;
break;
}
return {
content: link
};
}
}],
});

View file

@ -6,7 +6,7 @@
import { addDecoration, removeDecoration } from "@api/MessageDecorations";
import { Devs, EquicordDevs } from "@utils/constants";
import { isEquicordPluginDev, isPluginDev } from "@utils/misc";
import { isEquicordPluginDev, isPluginDev, isSuncordPluginDev } from "@utils/misc";
import definePlugin from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
import badges from "plugins/_api/badges";
@ -60,6 +60,30 @@ function CheckBadge({ badge, author }: { badge: string; author: User; }): JSX.El
/>
</span>
) : null;
case "SuncordDonor":
return (
<span style={{ order: settings.store.SuncordDonorPosition }}>
{badges.getSuncordDonorBadges(author.id)?.map((badge: any) => (
<RoleIconComponent
className={roleIconClassName}
name={badge.description}
size={20}
src={badge.image}
/>
))}
</span>
);
case "SuncordContributer":
return isSuncordPluginDev(author.id) ? (
<span style={{ order: settings.store.SuncordContributorPosition }}>
<RoleIconComponent
className={roleIconClassName}
name={"Suncord Contributor"}
size={20}
src={"https://raw.githubusercontent.com/verticalsync/Suncord/main/src/assets/icon.png"}
/>
</span>
) : null;
case "VencordDonor":
return (
<span style={{ order: settings.store.VencordDonorPosition }}>
@ -126,6 +150,8 @@ function ChatBadges({ author }: { author: User; }) {
<span className="vc-sbic-badge-row">
{settings.store.showEquicordDonor && <CheckBadge badge={"EquicordDonor"} author={author} />}
{settings.store.showEquicordContributor && <CheckBadge badge={"EquicordContributer"} author={author} />}
{settings.store.showSuncordDonor && <CheckBadge badge={"SuncordDonor"} author={author} />}
{settings.store.showSuncordContributor && <CheckBadge badge={"SuncordContributer"} author={author} />}
{settings.store.showVencordDonor && <CheckBadge badge={"VencordDonor"} author={author} />}
{settings.store.showVencordContributor && <CheckBadge badge={"VencordContributer"} author={author} />}
{settings.store.showDiscordProfile && <CheckBadge badge={"DiscordProfile"} author={author} />}

View file

@ -33,6 +33,30 @@ const settings = definePluginSettings({
hidden: true,
default: 1
},
showSuncordDonor: {
type: OptionType.BOOLEAN,
description: "Enable to show Suncord Donor badges in chat.",
hidden: true,
default: true
},
SuncordDonorPosition: {
type: OptionType.NUMBER,
description: "The position of the Suncord Donor badges.",
hidden: true,
default: 2
},
showSuncordContributor: {
type: OptionType.BOOLEAN,
description: "Enable to show Suncord Contributor badges in chat.",
hidden: true,
default: true
},
SuncordContributorPosition: {
type: OptionType.NUMBER,
description: "The position of the Suncord Contributor badge.",
hidden: true,
default: 3
},
showVencordDonor: {
type: OptionType.BOOLEAN,
description: "Enable to show Vencord donor badges in chat.",
@ -43,7 +67,7 @@ const settings = definePluginSettings({
type: OptionType.NUMBER,
description: "The position of the Vencord Donor badges.",
hidden: true,
default: 2
default: 4
},
showVencordContributor: {
type: OptionType.BOOLEAN,
@ -55,7 +79,7 @@ const settings = definePluginSettings({
type: OptionType.NUMBER,
description: "The position of the Vencord Contributor badge.",
hidden: true,
default: 3
default: 5
},
showDiscordProfile: {
type: OptionType.BOOLEAN,
@ -67,7 +91,7 @@ const settings = definePluginSettings({
type: OptionType.NUMBER,
description: "The position of the Discord profile badges.",
hidden: true,
default: 4
default: 6
},
showDiscordNitro: {
type: OptionType.BOOLEAN,
@ -79,7 +103,7 @@ const settings = definePluginSettings({
type: OptionType.NUMBER,
description: "The position of the Discord Nitro badge.",
hidden: true,
default: 5
default: 7
},
badgeSettings: {
type: OptionType.COMPONENT,
@ -94,6 +118,8 @@ const BadgeSettings = () => {
const [images, setImages] = useState([
{ src: "https://i.imgur.com/KsxHlbD.png", shown: settings.store.showEquicordDonor, title: "Equicord donor badges", key: "EquicordDonor", position: settings.store.EquicordDonorPosition },
{ src: "https://i.imgur.com/rJDRtUB.png", shown: settings.store.showEquicordContributor, title: "Equicord contributor badge", key: "EquicordContributer", position: settings.store.EquicordContributorPosition },
{ src: "https://i.imgur.com/H3GPhpd.png", shown: settings.store.showSuncordDonor, title: "Suncord donor badges", key: "SuncordDonor", position: settings.store.SuncordDonorPosition },
{ src: "https://raw.githubusercontent.com/verticalsync/Suncord/main/src/assets/icon.png", shown: settings.store.showSuncordContributor, title: "Suncord contributor badge", key: "SuncordContributer", position: settings.store.SuncordContributorPosition },
{ src: "https://cdn.discordapp.com/emojis/1026533070955872337.png", shown: settings.store.showVencordDonor, title: "Vencord donor badges", key: "VencordDonor", position: settings.store.VencordDonorPosition },
{ src: "https://vencord.dev/assets/favicon.png", shown: settings.store.showVencordContributor, title: "Vencord contributor badge", key: "VencordContributer", position: settings.store.VencordContributorPosition },
{ src: "https://cdn.discordapp.com/badge-icons/bf01d1073931f921909045f3a39fd264.png", shown: settings.store.showDiscordProfile, title: "Discord profile badges (HypeSquad, Discord Staff, Active Developer, etc.)", key: "DiscordProfile", position: settings.store.DiscordProfilePosition },
@ -111,6 +137,14 @@ const BadgeSettings = () => {
settings.store.EquicordContributorPosition = image.position;
settings.store.showEquicordContributor = image.shown;
break;
case "SuncordDonor":
settings.store.SuncordDonorPosition = image.position;
settings.store.showSuncordDonor = image.shown;
break;
case "SuncordContributer":
settings.store.SuncordContributorPosition = image.position;
settings.store.showSuncordContributor = image.shown;
break;
case "VencordDonor":
settings.store.VencordDonorPosition = image.position;
settings.store.showVencordDonor = image.shown;