diff --git a/src/equicordplugins/randomVoice/index.tsx b/src/equicordplugins/randomVoice/index.tsx index 72ecae7e..96ea92f9 100644 --- a/src/equicordplugins/randomVoice/index.tsx +++ b/src/equicordplugins/randomVoice/index.tsx @@ -11,8 +11,8 @@ import { makeRange } from "@components/PluginSettings/components"; import { debounce } from "@shared/debounce"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy, findByCode, findByProps } from "@webpack"; -import { ChannelStore, ContextMenuApi, GuildStore, IconUtils, Menu, ChannelRouter, PermissionStore, React, SelectedChannelStore, PermissionsBits, Toasts, UserStore } from "@webpack/common"; +import { findByCode, findByProps, findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; +import { ChannelRouter, ChannelStore, ContextMenuApi, GuildStore, Menu, PermissionsBits, PermissionStore, React, SelectedChannelStore, Toasts, UserStore } from "@webpack/common"; import style from "./styles.css?managed"; @@ -86,10 +86,10 @@ const settings = definePluginSettings({ description: "Automatically turns on camera", default: false, }, - autoStream: { - type: OptionType.BOOLEAN, + autoStream: { + type: OptionType.BOOLEAN, description: "Automatically turns on stream", - default: false, + default: false, }, selfMute: { type: OptionType.BOOLEAN, @@ -101,10 +101,10 @@ const settings = definePluginSettings({ description: "Automatically deafems your mic when joining voice-channel.", default: false, }, - leaveEmpty: { + leaveEmpty: { type: OptionType.BOOLEAN, description: "Finds a random-call, when the voice chat is empty.", - default: false, + default: false, }, avoidStages: { type: OptionType.BOOLEAN, @@ -177,21 +177,21 @@ export default definePlugin({ } ], flux: { - VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[] }) { + VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) { const currentUserId = UserStore.getCurrentUser().id; const myChannelId = VoiceStateStore.getVoiceStateForUser(currentUserId)?.channelId; if (!myChannelId || !settings.store.leaveEmpty) return; - + const voiceStatesMap = VoiceStateStore.getVoiceStates() as Record; const othersInChannel = Object.values(voiceStatesMap).filter(vs => vs.channelId === myChannelId && vs.userId !== currentUserId ); - + if (othersInChannel.length === 0) { - randomVoice() + randomVoice(); } }, - }, + }, start() { enableStyle(style); }, @@ -261,7 +261,7 @@ function ContextMenu() { aria-label="Voice state modifier" > - + settings.store.showPanel, find: "this.renderEmbeddedActivity()", replacement: { - match: /(?<=children.{0,50})"div"(?=.{0,500}this\.renderEmbeddedActivity\(\))/, + match: /(?<=render\(\).{0,500}children.{0,50})"div"(?=.{0,500}this\.renderEmbeddedActivity\(\))/, replace: "$self.WrapperComponent" } } @@ -118,7 +117,7 @@ export default definePlugin({ return ( <>
{props.children}
-
+
{getIntlMessage("SPECTATORS", { numViewers: userIds.length })} diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx index f167287f..3efe60e0 100644 --- a/src/plugins/showMeYourName/index.tsx +++ b/src/plugins/showMeYourName/index.tsx @@ -45,9 +45,26 @@ const settings = definePluginSettings({ type: OptionType.BOOLEAN, default: false, description: "Use friend names in place of usernames (overrides Display Names option if applicable)" - } + }, + memberList: { + type: OptionType.BOOLEAN, + default: true, + description: "Show usernames in member list", + }, + voiceChannelList: { + type: OptionType.BOOLEAN, + default: true, + description: "Show usernames in voice channel list", + }, }); +function getUsername(user: any): string { + const friendName = RelationshipStore.getNickname(user.id); + if (settings.store.preferFriend && friendName) return friendName; + if (settings.store.displayNames) return user.globalName || user.username; + return user.username; +} + export default definePlugin({ name: "ShowMeYourName", description: "Display usernames next to nicks, or no nicks at all", @@ -61,18 +78,31 @@ export default definePlugin({ replace: "$self.renderUsername(arguments[0])" } }, + { + find: "._areActivitiesExperimentallyHidden=(", + replacement: { + match: /(?<=user:(\i),currentUser:\i,nick:)\i/, + replace: "$self.getUsername($1)" + }, + predicate: () => settings.store.memberList + }, + { + find: ".usernameSpeaking]", + predicate: () => settings.store.voiceChannelList, + replacement: [ + { + match: /(?<=children:\[null!=\i\?)\i(?=:\i\.\i\.getName\((\i)\))/, + replace: "$self.getUsername($1)" + }, + ] + }, ], settings, - + getUsername, renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => { try { const user = userOverride ?? message.author; - const friendName = RelationshipStore.getNickname(user.id); - let { username } = user; - if (settings.store.displayNames) - username = (user as any).globalName || username; - if (settings.store.preferFriend) - username = friendName ?? username; + const username = getUsername(user); const { nick } = author; const prefix = withMentionPrefix ? "@" : "";