From c83627032091d3265ca22f8089b4857df9832087 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sun, 26 May 2024 18:24:02 +0200 Subject: [PATCH] fix minor bugs in various plugins - FriendsSince: Don't show for friend requests - FakeNitro: Fix attempting to bypass unicode emojis #2503 - MessageLatency: ignore bots #2504 - CtrlEnterSend: use cmd+enter on macOS #2502 - ReplaceGoogleSearch: trim LF character #2488 Co-authored-by: AutumnVN Co-authored-by: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Co-authored-by: Lumap Co-authored-by: Mylloon --- src/plugins/ctrlEnterSend/index.ts | 4 ++-- src/plugins/fakeNitro/index.tsx | 2 +- src/plugins/friendsSince/index.tsx | 4 ++++ src/plugins/messageLatency/index.tsx | 3 +++ src/plugins/replaceGoogleSearch/index.tsx | 2 +- src/webpack/common/types/stores.d.ts | 4 ++-- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/plugins/ctrlEnterSend/index.ts b/src/plugins/ctrlEnterSend/index.ts index 4b9dd8e06..817da0532 100644 --- a/src/plugins/ctrlEnterSend/index.ts +++ b/src/plugins/ctrlEnterSend/index.ts @@ -18,7 +18,7 @@ export default definePlugin({ type: OptionType.SELECT, options: [ { - label: "Ctrl+Enter (Enter or Shift+Enter for new line)", + label: "Ctrl+Enter (Enter or Shift+Enter for new line) (cmd+enter on macOS)", value: "ctrl+enter" }, { @@ -54,7 +54,7 @@ export default definePlugin({ result = event.shiftKey; break; case "ctrl+enter": - result = event.ctrlKey; + result = navigator.platform.includes("Mac") ? event.metaKey : event.ctrlKey; break; case "enter": result = !event.shiftKey && !event.ctrlKey; diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index 4ab0e18ee..427f36ce8 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -813,7 +813,7 @@ export default definePlugin({ }, canUseEmote(e: Emoji, channelId: string) { - if (e.type === "UNICODE") return true; + if (e.type === 0) return true; if (e.available === false) return false; const isUnusableRoleSubEmoji = RoleSubscriptionEmojiUtils.isUnusableRoleSubscriptionEmojiOriginal ?? RoleSubscriptionEmojiUtils.isUnusableRoleSubscriptionEmoji; diff --git a/src/plugins/friendsSince/index.tsx b/src/plugins/friendsSince/index.tsx index 8ad9dc7f4..eb59fff25 100644 --- a/src/plugins/friendsSince/index.tsx +++ b/src/plugins/friendsSince/index.tsx @@ -52,6 +52,8 @@ export default definePlugin({ getFriendSince(userId: string) { try { + if (!RelationshipStore.isFriend(userId)) return null; + return RelationshipStore.getSince(userId); } catch (err) { new Logger("FriendsSince").error(err); @@ -60,6 +62,8 @@ export default definePlugin({ }, friendsSince: ErrorBoundary.wrap(({ userId, textClassName }: { userId: string; textClassName?: string; }) => { + if (!RelationshipStore.isFriend(userId)) return null; + const friendsSince = RelationshipStore.getSince(userId); if (!friendsSince) return null; diff --git a/src/plugins/messageLatency/index.tsx b/src/plugins/messageLatency/index.tsx index d517c0e01..e4e5b8771 100644 --- a/src/plugins/messageLatency/index.tsx +++ b/src/plugins/messageLatency/index.tsx @@ -97,6 +97,9 @@ export default definePlugin({ // Message wasn't received through gateway if (!isNonNullish(nonce)) return null; + // Bots basically never send a nonce, and if someone does do it then it's usually not a snowflake + if (message.bot) return null; + let isDiscordKotlin = false; let delta = SnowflakeUtils.extractTimestamp(id) - SnowflakeUtils.extractTimestamp(nonce); // milliseconds if (!showMillis) { diff --git a/src/plugins/replaceGoogleSearch/index.tsx b/src/plugins/replaceGoogleSearch/index.tsx index dff593a3b..9882809f7 100644 --- a/src/plugins/replaceGoogleSearch/index.tsx +++ b/src/plugins/replaceGoogleSearch/index.tsx @@ -37,7 +37,7 @@ const settings = definePluginSettings({ }); function search(src: string, engine: string) { - open(engine + encodeURIComponent(src), "_blank"); + open(engine + encodeURIComponent(src.trim()), "_blank"); } function makeSearchItem(src: string) { diff --git a/src/webpack/common/types/stores.d.ts b/src/webpack/common/types/stores.d.ts index 059924f5a..083ec2694 100644 --- a/src/webpack/common/types/stores.d.ts +++ b/src/webpack/common/types/stores.d.ts @@ -63,7 +63,7 @@ export interface CustomEmoji { originalName?: string; require_colons: boolean; roles: string[]; - type: "GUILD_EMOJI"; + type: 1; } export interface UnicodeEmoji { @@ -75,7 +75,7 @@ export interface UnicodeEmoji { }; index: number; surrogates: string; - type: "UNICODE"; + type: 0; uniqueName: string; useSpriteSheet: boolean; get allNamesString(): string;