From 0eaaa9c122336d8047b947ca6a0c03a11e3e063e Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 7 Sep 2025 11:47:24 -0400 Subject: [PATCH] Lint Fixes --- packages/discord-types/src/index.d.ts | 1 - .../discord-types/src/passiveupdatestate.d.ts | 2 +- .../src/stores/VoiceStateStore.d.ts | 4 ++++ packages/discord-types/src/voicestate.d.ts | 21 ----------------- src/equicordplugins/allCallTimers/index.tsx | 2 +- .../youtubeMusic/PlayerComponent.tsx | 4 ++-- .../musicControls/youtubeMusic/YtmStore.ts | 18 +++++++-------- src/equicordplugins/orbolayBridge/index.tsx | 23 ++++++++++++------- 8 files changed, 32 insertions(+), 43 deletions(-) delete mode 100644 packages/discord-types/src/voicestate.d.ts diff --git a/packages/discord-types/src/index.d.ts b/packages/discord-types/src/index.d.ts index 78c980c9f..d302e326f 100644 --- a/packages/discord-types/src/index.d.ts +++ b/packages/discord-types/src/index.d.ts @@ -7,5 +7,4 @@ export * from "./menu"; export * from "./stores"; export * from "./passiveupdatestate"; export * from "./utils"; -export * from "./voicestate"; export * as Webpack from "../webpack"; diff --git a/packages/discord-types/src/passiveupdatestate.d.ts b/packages/discord-types/src/passiveupdatestate.d.ts index 468dd9641..31bed9ffa 100644 --- a/packages/discord-types/src/passiveupdatestate.d.ts +++ b/packages/discord-types/src/passiveupdatestate.d.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { VoiceState } from "./voicestate"; +import { VoiceState } from "./stores"; export interface PassiveUpdateState { type: string; diff --git a/packages/discord-types/src/stores/VoiceStateStore.d.ts b/packages/discord-types/src/stores/VoiceStateStore.d.ts index 84540d996..0f9f9f799 100644 --- a/packages/discord-types/src/stores/VoiceStateStore.d.ts +++ b/packages/discord-types/src/stores/VoiceStateStore.d.ts @@ -14,12 +14,16 @@ export interface VoiceState extends DiscordRecord { selfDeaf: boolean; selfVideo: boolean; selfStream: boolean | undefined; + sessionId: string; suppress: boolean; requestToSpeakTimestamp: string | null | undefined; discoverable: boolean; isVoiceMuted(): boolean; isVoiceDeafened(): boolean; + + oldChannelId?: string; + guildId?: string; } export class VoiceStateStore extends FluxStore { diff --git a/packages/discord-types/src/voicestate.d.ts b/packages/discord-types/src/voicestate.d.ts deleted file mode 100644 index aa7ddcce2..000000000 --- a/packages/discord-types/src/voicestate.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -export interface VoiceState { - userId: string; - channelId?: string; - oldChannelId?: string; - guildId?: string; - deaf: boolean; - mute: boolean; - selfDeaf: boolean; - selfMute: boolean; - selfStream: boolean; - selfVideo: boolean; - sessionId: string; - suppress: boolean; - requestToSpeakTimestamp: string | null; -} diff --git a/src/equicordplugins/allCallTimers/index.tsx b/src/equicordplugins/allCallTimers/index.tsx index b4fb0e852..c1c1486f2 100644 --- a/src/equicordplugins/allCallTimers/index.tsx +++ b/src/equicordplugins/allCallTimers/index.tsx @@ -149,7 +149,7 @@ export default definePlugin({ let { oldChannelId } = state; if (isMe && channelId !== myLastChannelId) { oldChannelId = myLastChannelId; - myLastChannelId = channelId; + myLastChannelId = channelId ?? undefined; } if (channelId !== oldChannelId) { diff --git a/src/equicordplugins/musicControls/youtubeMusic/PlayerComponent.tsx b/src/equicordplugins/musicControls/youtubeMusic/PlayerComponent.tsx index 543509273..4529e7d32 100644 --- a/src/equicordplugins/musicControls/youtubeMusic/PlayerComponent.tsx +++ b/src/equicordplugins/musicControls/youtubeMusic/PlayerComponent.tsx @@ -19,13 +19,13 @@ import "./ytmStyles.css"; import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons"; +import { SeekBar } from "@equicordplugins/musicControls/spotify/SeekBar"; import { debounce } from "@shared/debounce"; import { openImageModal } from "@utils/discord"; import { classes, copyWithToast } from "@utils/misc"; import { ContextMenuApi, Flex, FluxDispatcher, Forms, Menu, React, useEffect, useState, useStateFromStores } from "@webpack/common"; -import { type Song, type Repeat, YoutubeMusicStore } from "./YtmStore"; -import { SeekBar } from "@equicordplugins/musicControls/spotify/SeekBar"; +import { type Repeat, type Song, YoutubeMusicStore } from "./YtmStore"; const cl = (className: string) => `vc-ytm-${className}`; diff --git a/src/equicordplugins/musicControls/youtubeMusic/YtmStore.ts b/src/equicordplugins/musicControls/youtubeMusic/YtmStore.ts index 39572267c..e3e9e908b 100644 --- a/src/equicordplugins/musicControls/youtubeMusic/YtmStore.ts +++ b/src/equicordplugins/musicControls/youtubeMusic/YtmStore.ts @@ -29,7 +29,7 @@ enum MediaType { OtherVideo = "OTHER_VIDEO", } -export type RepeatMode = 'NONE' | 'ONE' | 'ALL'; +export type RepeatMode = "NONE" | "ONE" | "ALL"; export interface Song { @@ -49,13 +49,13 @@ export interface Song { } enum DataTypes { - PlayerInfo = 'PLAYER_INFO', - VideoChanged = 'VIDEO_CHANGED', - PlayerStateChanged = 'PLAYER_STATE_CHANGED', - PositionChanged = 'POSITION_CHANGED', - VolumeChanged = 'VOLUME_CHANGED', - RepeatChanged = 'REPEAT_CHANGED', - ShuffleChanged = 'SHUFFLE_CHANGED', + PlayerInfo = "PLAYER_INFO", + VideoChanged = "VIDEO_CHANGED", + PlayerStateChanged = "PLAYER_STATE_CHANGED", + PositionChanged = "POSITION_CHANGED", + VolumeChanged = "VOLUME_CHANGED", + RepeatChanged = "REPEAT_CHANGED", + ShuffleChanged = "SHUFFLE_CHANGED", } type PlayerInfo = { @@ -200,7 +200,7 @@ export const YoutubeMusicStore = proxyLazyWebpack(() => { if (message.song) { store.song = message.song; store.isPlaying = !(message.song?.isPaused ?? false); - }; + } if (message.isPlaying != null && !message.song) store.isPlaying = message.isPlaying; if (message.shuffle != null) store.isShuffled = message.shuffle; if (message.position && message.position !== store.position) store.position = message.position ?? 0; diff --git a/src/equicordplugins/orbolayBridge/index.tsx b/src/equicordplugins/orbolayBridge/index.tsx index 59519f595..e94b6e95b 100644 --- a/src/equicordplugins/orbolayBridge/index.tsx +++ b/src/equicordplugins/orbolayBridge/index.tsx @@ -19,6 +19,7 @@ import { definePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; +import { VoiceState } from "@vencord/discord-types"; import { ChannelStore, FluxDispatcher, GuildMemberStore, Toasts, UserStore, VoiceStateStore } from "@webpack/common"; interface ChannelState { @@ -78,7 +79,7 @@ const settings = definePluginSettings({ }); let ws: WebSocket | null = null; -let currentChannel = null; +let currentChannel: string | null = null; async function waitForPopulate(fn) { while (true) { @@ -88,7 +89,7 @@ async function waitForPopulate(fn) { } } -function stateToPayload(guildId: string, state: ChannelState) { +function stateToPayload(guildId: string, state: VoiceState) { const user = UserStore.getUser(state.userId); const nickname = GuildMemberStore.getNick(guildId, state.userId); return { @@ -130,9 +131,9 @@ const incoming = payload => { case "STOP_STREAM": { const userId = UserStore.getCurrentUser().id; const voiceState = VoiceStateStore.getVoiceStateForUser(userId); + if (!voiceState?.channelId) return; const channel = ChannelStore.getChannel(voiceState.channelId); - - if (!userId || !voiceState || !channel) return; + if (!channel) return; FluxDispatcher.dispatch({ type: "STREAM_STOP", @@ -188,8 +189,14 @@ const createWebsocket = () => { ws?.send(JSON.stringify({ cmd: "REGISTER_CONFIG", ...config })); + if (!config.userId) return; const userVoiceState = VoiceStateStore.getVoiceStateForUser(config.userId); - const guildId = ChannelStore.getChannel(userVoiceState.channelId).guild_id; + if (!userVoiceState || !userVoiceState.channelId) return; + + const channel = ChannelStore.getChannel(userVoiceState.channelId); + if (!channel) return; + + const guildId = channel.guild_id; const channelState = VoiceStateStore.getVoiceStatesForChannel(userVoiceState.channelId); if (!guildId || !channelState) return; @@ -197,7 +204,7 @@ const createWebsocket = () => { ws?.send( JSON.stringify({ cmd: "CHANNEL_JOINED", - states: Object.values(channelState).map(s => stateToPayload(guildId, s as ChannelState)), + states: Object.values(channelState).map(s => stateToPayload(guildId, s)), }) ); @@ -236,7 +243,7 @@ export default definePlugin({ ws?.send( JSON.stringify({ cmd: "CHANNEL_JOINED", - states: Object.values(voiceStates).map(s => stateToPayload(guildId, s as ChannelState)), + states: Object.values(voiceStates).map(s => stateToPayload(guildId, s as VoiceState)), }) ); @@ -258,7 +265,7 @@ export default definePlugin({ ws?.send( JSON.stringify({ cmd: "VOICE_STATE_UPDATE", - state: stateToPayload(guildId, state as ChannelState), + state: stateToPayload(guildId, state), }) ); }