From f29662c5b315a3579e14bcfb062d96bf047b7d39 Mon Sep 17 00:00:00 2001 From: vishnyanetchereshnya <151846235+vishnyanetchereshnya@users.noreply.github.com> Date: Mon, 27 Jan 2025 06:12:26 +0300 Subject: [PATCH 1/3] feat(ViewRaw): add View Role option (#3083) Co-authored-by: v --- src/plugins/betterRoleContext/index.tsx | 30 ++++++++++++------------- src/plugins/viewRaw/index.tsx | 27 ++++++++++++++++++---- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/plugins/betterRoleContext/index.tsx b/src/plugins/betterRoleContext/index.tsx index 1029c07e..afef6390 100644 --- a/src/plugins/betterRoleContext/index.tsx +++ b/src/plugins/betterRoleContext/index.tsx @@ -83,7 +83,7 @@ export default definePlugin({ if (!role) return; if (role.colorString) { - children.push( + children.unshift( { + await GuildSettingsActions.open(guild.id, "ROLES"); + GuildSettingsActions.selectRole(id); + }} + icon={PencilIcon} + /> + ); + } + if (role.icon) { children.push( { - await GuildSettingsActions.open(guild.id, "ROLES"); - GuildSettingsActions.selectRole(id); - }} - icon={PencilIcon} - /> - ); - } } } }); diff --git a/src/plugins/viewRaw/index.tsx b/src/plugins/viewRaw/index.tsx index b45919a2..ddcbd3b4 100644 --- a/src/plugins/viewRaw/index.tsx +++ b/src/plugins/viewRaw/index.tsx @@ -22,12 +22,12 @@ import { CodeBlock } from "@components/CodeBlock"; import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Devs } from "@utils/constants"; -import { getIntlMessage } from "@utils/discord"; +import { getCurrentGuild, getIntlMessage } from "@utils/discord"; import { Margins } from "@utils/margins"; import { copyWithToast } from "@utils/misc"; import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, ChannelStore, Forms, Menu, Text } from "@webpack/common"; +import { Button, ChannelStore, Forms, GuildStore, Menu, Text } from "@webpack/common"; import { Message } from "discord-types/general"; @@ -118,7 +118,7 @@ const settings = definePluginSettings({ } }); -function MakeContextCallback(name: "Guild" | "User" | "Channel"): NavContextMenuPatchCallback { +function MakeContextCallback(name: "Guild" | "Role" | "User" | "Channel"): NavContextMenuPatchCallback { return (children, props) => { const value = props[name.toLowerCase()]; if (!value) return; @@ -144,6 +144,23 @@ function MakeContextCallback(name: "Guild" | "User" | "Channel"): NavContextMenu }; } +const devContextCallback: NavContextMenuPatchCallback = (children, { id }: { id: string; }) => { + const guild = getCurrentGuild(); + if (!guild) return; + + const role = GuildStore.getRole(guild.id, id); + if (!role) return; + + children.push( + openViewRawModal(JSON.stringify(role, null, 4), "Role")} + icon={CopyIcon} + /> + ); +}; + export default definePlugin({ name: "ViewRaw", description: "Copy and view the raw content/data of any message, channel or guild", @@ -152,10 +169,12 @@ export default definePlugin({ contextMenus: { "guild-context": MakeContextCallback("Guild"), + "guild-settings-role-context": MakeContextCallback("Role"), "channel-context": MakeContextCallback("Channel"), "thread-context": MakeContextCallback("Channel"), "gdm-context": MakeContextCallback("Channel"), - "user-context": MakeContextCallback("User") + "user-context": MakeContextCallback("User"), + "dev-context": devContextCallback }, renderMessagePopoverButton(msg) { From fc304f56a25fea991f1452e45f23ff9a652a8ed6 Mon Sep 17 00:00:00 2001 From: 54ac Date: Thu, 12 Sep 2024 01:31:40 +0200 Subject: [PATCH 2/3] LastFMRichPresence: Add option to hide presence when any other activity is detected --- src/plugins/lastfm/index.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/plugins/lastfm/index.tsx b/src/plugins/lastfm/index.tsx index 02fd694f..23a0edce 100644 --- a/src/plugins/lastfm/index.tsx +++ b/src/plugins/lastfm/index.tsx @@ -124,6 +124,11 @@ const settings = definePluginSettings({ type: OptionType.BOOLEAN, default: true, }, + hideWithActivity: { + description: "Hide Last.fm presence if any other activity is detected", + type: OptionType.BOOLEAN, + default: false, + }, statusName: { description: "custom status text", type: OptionType.STRING, @@ -274,7 +279,13 @@ export default definePlugin({ }, async getActivity(): Promise { - if (settings.store.hideWithSpotify) { + if (settings.store.hideWithActivity) { + for (const activity of presenceStore.getActivities()) { + if (activity.application_id !== applicationId) { + return null; + } + } + } else if (settings.store.hideWithSpotify) { for (const activity of presenceStore.getActivities()) { if (activity.type === ActivityType.LISTENING && activity.application_id !== applicationId) { // there is already music status because of Spotify or richerCider (probably more) From 91d9c789a22aa4eef304fbc614a5eefe77309978 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Mon, 27 Jan 2025 04:18:46 +0100 Subject: [PATCH 3/3] simplify code --- src/plugins/lastfm/index.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/lastfm/index.tsx b/src/plugins/lastfm/index.tsx index 23a0edce..392bd90f 100644 --- a/src/plugins/lastfm/index.tsx +++ b/src/plugins/lastfm/index.tsx @@ -86,7 +86,7 @@ const placeholderId = "2a96cbd8b46e442fc41c2b86b821562f"; const logger = new Logger("LastFMRichPresence"); -const presenceStore = findByPropsLazy("getLocalPresence"); +const PresenceStore = findByPropsLazy("getLocalPresence"); async function getApplicationAsset(key: string): Promise { return (await ApplicationAssetUtils.fetchAssetIds(applicationId, [key]))[0]; @@ -280,13 +280,13 @@ export default definePlugin({ async getActivity(): Promise { if (settings.store.hideWithActivity) { - for (const activity of presenceStore.getActivities()) { - if (activity.application_id !== applicationId) { - return null; - } + if (PresenceStore.getActivities().some(a => a.application_id !== applicationId)) { + return null; } - } else if (settings.store.hideWithSpotify) { - for (const activity of presenceStore.getActivities()) { + } + + if (settings.store.hideWithSpotify) { + for (const activity of PresenceStore.getActivities()) { if (activity.type === ActivityType.LISTENING && activity.application_id !== applicationId) { // there is already music status because of Spotify or richerCider (probably more) return null;