diff --git a/README.md b/README.md index 2c4bd78..fb3996c 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,62 @@ Make your experience better with spotify links. Like Playing directly or adding in queue. (Also opening directly in app) -Direct Download Link: [dev.tharki.Distify.asar](https://github.com/YofukashiNo/Distify/releases/latest/download/dev.tharki.Distify.asar) +Direct Download Link: +[![dev.yofukashino.Distify.asar](https://img.shields.io/github/downloads/YofukashiNo/MessageLinkEmbeds/total.svg?style=social&label=Direct%20Download)](https://github.com/YofukashiNo/Distify/releases/latest/download/dev.yofukashino.Distify.asar) Install Link: +[![Safe](https://img.shields.io/github/downloads/YofukashiNo/MessageLinkEmbeds/total.svg?style=social&label=Install%20in%20Replugged&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB2aWV3Qm94PSIwIDAgMjQ1NzkgMjQ1NzkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnNYbGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sU3BhY2U9InByZXNlcnZlIiB4bWxuczpzZXJpZj0iaHR0cDovL3d3dy5zZXJpZi5jb20vIiBjbGFzcz0iX3BsdWdfM2J3NmNfMjIiIHN0eWxlPSJmaWxsLXJ1bGU6IGV2ZW5vZGQ7IGNsaXAtcnVsZTogZXZlbm9kZDsgc3Ryb2tlLWxpbmVqb2luOiByb3VuZDsiPjxnPjxjbGlwUGF0aCBpZD0iX2NsaXAxIj48cGF0aCBkPSJNMjIyMjAuMywyMjQ3NC44YzM5LjI1LDQ0LjU3MSA3MS40NjcsOTQuODcxIDk1LjU0MiwxNDkuMTYzYzE2NC4wOTYsMzY4LjQyNSAxNjIuNDI5LDc5Ni42MDggLTE3Ljk0MiwxMTcwLjFjLTQzLjE0MSw4OS4zMzMgLTk1LjA4NywxNzIuNiAtMTU0LjUwOCwyNDguOTcxYy0yODEuNzMzLDM2My41NjcgLTc2OS43NjcsNDk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=github) +![distify](https://i.imgur.com/i7r0j9L.png) -[![Install in Replugged](https://img.shields.io/badge/-Install%20in%20Replugged-blue?style=for-the-badge&logo=none)](https://replugged.dev/install?identifier=YofukashiNo/Distify&source=github) +--- -![image](https://i.imgur.com/i7r0j9L.png) +# FAQ +### How to install a plugin? +
+Automatic +- Simply click on install link and thats all <3 +
+
+Manual -> For Contributing: [Make a pr thats all.] +- Click on Direct Download Link and save the file +- Open Replugged Plugin Settings +- Click on "Open Plugins Folder" button +- Paste downloaded file in folder that opened +
+### How Do I contribute? +- Just make a pull request + +### How Do I support without pull request? +- You Can Donate on my [ko-fi](https://ko-fi.com/yofukashino) or UPI at `yofukashi.no.singh@fam` + +[![Buy Me a Coffee at ko-fi.com](https://storage.ko-fi.com/cdn/kofi3.png?v=3)](https://ko-fi.com/yofukashino) + +### Where can I find other plugins by you? + +You can find them [here](https://github.com/YofukashiNo/RepluggedPlugins) + +### This plugin isn't listed in the all plugin list? + +PRs are appreciated or just make an issue on the [repo](https://github.com/YofukashiNo/RepluggedPlugins) + + +### Where can I find the support? + +~~You can make post in support channel of replugged server and ping me.~~ + +OR + +There is support server for all the plugins. You can join it here: + +[![Support Server](https://discordapp.com/api/guilds/919649417005506600/widget.png?style=banner3)](https://discord.gg/SgKSKyh9gY) + + + +# Who is the author of these plugins? + +[![Discord Presence](https://lanyard.cnrad.dev/api/1121961711080050780?hideDiscrim=true&idleMessage=Leave%20the%20kid%20alone...)](https://discordapp.com/users/1121961711080050780) diff --git a/manifest.json b/manifest.json index 0634cf9..df6b87d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,16 +1,16 @@ { - "id": "dev.tharki.Distify", + "id": "dev.yofukashino.Distify", "name": "Distify", "description": "Make your experience better with spotify links.", "author": { - "name": "Ahlawat", + "name": "Nanakusa", "discordID": "1121961711080050780", "github": "YofukashiNo" }, "version": "1.0.3", "updater": { "type": "store", - "id": "dev.tharki.Distify" + "id": "dev.yofukashino.Distify" }, "license": "MIT", "type": "replugged-plugin", diff --git a/src/Components/MenuItems.tsx b/src/Components/MenuItems.tsx index 3b148a8..4dbcbf2 100644 --- a/src/Components/MenuItems.tsx +++ b/src/Components/MenuItems.tsx @@ -3,7 +3,6 @@ import { ContextMenu } from "replugged/components"; import { PluginLogger } from "../index"; import Utils from "../lib/utils"; import Icons from "./Icons"; -import Types from "../types"; export const noAccounts = (): React.ReactElement => { return ( @@ -17,10 +16,7 @@ export const noAccounts = (): React.ReactElement => { ); }; -export const addToQueue = ( - SpotifyLinks: string[][], - SpotifyAccount: Types.SpotifyAccounts, -): React.ReactElement => { +export const addToQueue = (SpotifyLinks: string[][]): React.ReactElement => { if (SpotifyLinks.length === 1) { const [, type, id, name] = SpotifyLinks[0]; return ( @@ -32,7 +28,7 @@ export const addToQueue = ( icon={() => } action={async () => { try { - await Utils.queue(type, id, SpotifyAccount.accessToken); + await Utils.queue(type, id); ToastUtils.toast("Successfully Queued on Spotify", ToastUtils.Kind.SUCCESS, { duration: 5000, }); @@ -54,8 +50,7 @@ export const addToQueue = ( icon={() => } action={async () => { try { - for (const [, type, id] of SpotifyLinks) - await Utils.queue(type, id, SpotifyAccount.accessToken); + for (const [, type, id] of SpotifyLinks) await Utils.queue(type, id); ToastUtils.toast("Successfully Queued on Spotify", ToastUtils.Kind.SUCCESS, { duration: 5000, }); @@ -75,7 +70,7 @@ export const addToQueue = ( icon={() => } action={async () => { try { - await Utils.queue(type, id, SpotifyAccount.accessToken); + await Utils.queue(type, id); ToastUtils.toast("Successfully Queued on Spotify", ToastUtils.Kind.SUCCESS, { duration: 5000, }); @@ -93,10 +88,7 @@ export const addToQueue = ( ); }; -export const play = ( - SpotifyLinks: string[][], - SpotifyAccount: Types.SpotifyAccounts, -): React.ReactElement => { +export const play = (SpotifyLinks: string[][]): React.ReactElement => { if (SpotifyLinks.length === 1) { const [, type, id, name] = SpotifyLinks[0]; return ( @@ -108,7 +100,7 @@ export const play = ( icon={() => } action={async () => { try { - await Utils.play(type, id, SpotifyAccount.accessToken); + await Utils.play(type, id); ToastUtils.toast("Successfully Played on Spotify", ToastUtils.Kind.SUCCESS, { duration: 5000, }); @@ -130,8 +122,7 @@ export const play = ( icon={() => } action={async () => { try { - for (const [, type, id] of SpotifyLinks) - await Utils.play(type, id, SpotifyAccount.accessToken); + for (const [, type, id] of SpotifyLinks) await Utils.play(type, id); ToastUtils.toast("Successfully Played on Spotify", ToastUtils.Kind.SUCCESS, { duration: 5000, }); @@ -151,7 +142,7 @@ export const play = ( icon={() => } action={async () => { try { - await Utils.play(type, id, SpotifyAccount.accessToken); + await Utils.play(type, id); ToastUtils.toast("Successfully Played on Spotify", ToastUtils.Kind.SUCCESS, { duration: 5000, }); diff --git a/src/lib/requiredModules.ts b/src/lib/requiredModules.ts index 7a1c4b1..1be20ba 100644 --- a/src/lib/requiredModules.ts +++ b/src/lib/requiredModules.ts @@ -5,3 +5,5 @@ export const ConnectedAccountsStore = webpack.getByStoreName("ConnectedAccountsStore"); export const ElementParser = webpack.getByProps("sanitizeUrl", "sanitizeText"); + +export const SpotifyStore = webpack.getByStoreName("SpotifyStore"); diff --git a/src/lib/utils.tsx b/src/lib/utils.tsx index c0a915a..3c2b448 100644 --- a/src/lib/utils.tsx +++ b/src/lib/utils.tsx @@ -2,10 +2,44 @@ import { contextMenu as ContextMenuUtils, React } from "replugged/common"; import { ContextMenu } from "replugged/components"; import { PluginLogger } from "../index"; import { BASE_URL, BASE_URL_PLAYER } from "./consts"; -import { ConnectedAccountsStore } from "./requiredModules"; +import { ConnectedAccountsStore, SpotifyStore } from "./requiredModules"; import MenuItems from "../Components/MenuItems"; import Types from "../types"; export const customCacheSpotifyMeta = new Map(); +export const ensureSpotifyPlayer = (): Promise<{ + socket?: Types.SpotifySocket; + device?: Types.SpotifyDevice; +}> => { + const activePlayer = SpotifyStore.getActiveSocketAndDevice(); + if (activePlayer) return Promise.resolve(activePlayer); + const playableDevices = SpotifyStore.getPlayableComputerDevices(); + if (playableDevices.length > 0) { + const [{ socket, device }] = playableDevices; + return Promise.resolve({ + socket, + device, + }); + } + return new Promise((res) => { + const timer = { timeout: null }; + const changeListerner = () => { + const playableDevices = SpotifyStore.getPlayableComputerDevices(); + const [{ socket, device }] = playableDevices; + clearTimeout(timer?.timeout); + SpotifyStore.removeChangeListener(changeListerner); + res({ + socket, + device, + }); + }; + SpotifyStore.addChangeListener(changeListerner); + timer.timeout = setTimeout(() => { + SpotifyStore.removeChangeListener(changeListerner); + res({}); + }, 2500); + open("spotify:"); + }); +}; export const error = async (res): Promise => { switch (res.status) { case 401: @@ -21,13 +55,14 @@ export const error = async (res): Promise => { return new Error("Unknown Error, Check the console and report the dev"); } }; -export const play = async (type: string, id: string, accessToken: string): Promise => { - if (!accessToken) { +export const play = async (type: string, id: string): Promise => { + const { socket, device } = await ensureSpotifyPlayer(); + if (!socket?.accessToken) { PluginLogger.error("Please link your Spotify to Discord in Settings > Connections"); return; } - const SpotifyResponse = await fetch(`${BASE_URL_PLAYER}/play`, { + const SpotifyResponse = await fetch(`${BASE_URL_PLAYER}/play?device_id=${device.id}`, { method: "PUT", body: JSON.stringify( type === "track" @@ -36,7 +71,7 @@ export const play = async (type: string, id: string, accessToken: string): Promi ), headers: { "Content-Type": "application/json", - Authorization: `Bearer ${accessToken}`, + Authorization: `Bearer ${socket?.accessToken}`, }, }); if (SpotifyResponse.ok) { @@ -45,19 +80,21 @@ export const play = async (type: string, id: string, accessToken: string): Promi throw await error(SpotifyResponse); }; -export const queue = async (type: string, id: string, accessToken: string): Promise => { - if (!accessToken) { +export const queue = async (type: string, id: string): Promise => { + const { socket, device } = await ensureSpotifyPlayer(); + if (!socket?.accessToken) { PluginLogger.error("Please link your Spotify to Discord in Settings > Connections"); return; } - const SpotifyResponse = await fetch( - `${BASE_URL_PLAYER}/queue?uri=${encodeURIComponent(`spotify:${type}:${id}`)}`, + `${BASE_URL_PLAYER}/queue?uri=${encodeURIComponent(`spotify:${type}:${id}`)}&device_id=${ + device.id + }`, { method: "POST", headers: { "Content-Type": "application/json", - Authorization: `Bearer ${accessToken}`, + Authorization: `Bearer ${socket?.accessToken}`, }, }, ); @@ -104,7 +141,6 @@ export const mapMenuItems = ( }) .then((res) => res.json()) .catch(() => ({ name: "Error Fetching Name" })); - console.log(SpotifyResponse); if (SpotifyResponse?.name) customCacheSpotifyMeta.set(id, [_, type, id, SpotifyResponse?.name]); return [_, type, id, SpotifyResponse?.name ?? "Error Fetching Name"]; @@ -131,24 +167,10 @@ export const mapMenuItems = ( if ((type as { data: boolean }).data) { return SpotifyMeta; } - if (SpotifyAccounts.length === 1) { - return [ - type.play && MenuItems.play(SpotifyMeta, SpotifyAccounts[0]), - type.queue && MenuItems.addToQueue(SpotifyMeta, SpotifyAccounts[0]), - ]; - } - return SpotifyAccounts.map((SpotifyAccount) => { - return ( - - {...[ - type.play && MenuItems.play(SpotifyMeta, SpotifyAccount), - type.queue && MenuItems.addToQueue(SpotifyMeta, SpotifyAccount), - ]} - - ); - }); + return [ + type.play && MenuItems.play(SpotifyMeta), + type.queue && MenuItems.addToQueue(SpotifyMeta), + ]; } catch { return []; } @@ -179,13 +201,12 @@ export const manipulateMenu = ( message: Types.Message, menu: { children: React.ReactElement[] }, ): React.ReactElement | void => { - console.log(menu); const MenuGroup = menu?.children?.find?.((c) => c?.props?.id === "distify") ?? ( ); MenuGroup.props.id = "distify"; if (!menu?.children?.some?.((c) => c?.props?.id === "distify")) - menu?.children.splice(1, 0, MenuGroup); + menu?.children.splice(-1, 0, MenuGroup); const SpotifyLinks = Array.from( message.content.matchAll(/open.spotify.com\/(album|track|playlist)\/([^?]+)/g) as string[][] & IterableIterator, @@ -198,22 +219,8 @@ export const manipulateMenu = ( data: true, }) as string[][]; if (SpotifyLinks.length <= 0) return; - if (SpotifyMeta && SpotifyAccounts.length === 1) { - MenuGroup.props.children = [ - MenuItems.play(SpotifyMeta, SpotifyAccounts[0]), - MenuItems.addToQueue(SpotifyMeta, SpotifyAccounts[0]), - ]; - } else if (SpotifyMeta) { - MenuGroup.props.children = SpotifyAccounts.map((SpotifyAccount) => ( - - {...[ - MenuItems.play(SpotifyMeta, SpotifyAccount), - MenuItems.addToQueue(SpotifyMeta, SpotifyAccount), - ]} - - )); + if (SpotifyMeta) { + MenuGroup.props.children = [MenuItems.play(SpotifyMeta), MenuItems.addToQueue(SpotifyMeta)]; } }; diff --git a/src/patches/Popover.tsx b/src/patches/Popover.tsx index 76f188f..1fc561d 100644 --- a/src/patches/Popover.tsx +++ b/src/patches/Popover.tsx @@ -26,10 +26,10 @@ export default (): void => { }); } else { try { - const [, type, id] = SpotifyLinks.pop(); - await Utils.play(type, id, SpotifyAccounts[0].accessToken); - for (const [, type, id] of SpotifyLinks) - await Utils.queue(type, id, SpotifyAccounts[0].accessToken); + const [play, ...queue] = SpotifyLinks; + const [, type, id] = play; + await Utils.play(type, id); + for (const [, type, id] of queue ?? []) await Utils.queue(type, id); ToastUtils.toast("Successfully Played on Spotify", ToastUtils.Kind.SUCCESS, { duration: 5000, }); @@ -42,8 +42,7 @@ export default (): void => { } }, onContextMenu: (e) => { - if (SpotifyAccounts.length > 1) - Utils.openContextMenu(e, SpotifyLinks, SpotifyAccounts, { play: true, queue: false }); + Utils.openContextMenu(e, SpotifyLinks, SpotifyAccounts, { play: true, queue: false }); }, }; }); @@ -68,8 +67,7 @@ export default (): void => { }); } else { try { - for (const [, type, id] of SpotifyLinks) - await Utils.queue(type, id, SpotifyAccounts[0].accessToken); + for (const [, type, id] of SpotifyLinks) await Utils.queue(type, id); ToastUtils.toast("Successfully Queued on Spotify", ToastUtils.Kind.SUCCESS, { duration: 5000, }); @@ -82,8 +80,7 @@ export default (): void => { } }, onContextMenu: (e) => { - if (SpotifyAccounts.length > 1) - Utils.openContextMenu(e, SpotifyLinks, SpotifyAccounts, { play: false, queue: true }); + Utils.openContextMenu(e, SpotifyLinks, SpotifyAccounts, { play: false, queue: true }); }, }; }); diff --git a/src/types.ts b/src/types.ts index 380fae5..172b767 100644 --- a/src/types.ts +++ b/src/types.ts @@ -38,7 +38,49 @@ export namespace Types { isJoining: DefaultTypes.AnyFunction; isSuggestedAccountType: DefaultTypes.AnyFunction; } - + export interface SpotifyStore extends Store { + canPlay: DefaultTypes.AnyFunction; + getActiveSocketAndDevice: () => { socket: SpotifySocket; device: SpotifyDevice }; + getActivity: DefaultTypes.AnyFunction; + getLastPlayedTrackId: DefaultTypes.AnyFunction; + getPlayableComputerDevices: () => Array<{ socket: SpotifySocket; device: SpotifyDevice }>; + getPlayerState: DefaultTypes.AnyFunction; + getSyncingWith: DefaultTypes.AnyFunction; + getTrack: DefaultTypes.AnyFunction; + hasConnectedAccount: DefaultTypes.AnyFunction; + initialize: DefaultTypes.AnyFunction; + shouldShowActivity: DefaultTypes.AnyFunction; + wasAutoPaused: DefaultTypes.AnyFunction; + } + export interface SpotifySocket { + accessToken: string; + accountId: string; + connectionId: string; + handleDeviceStateChange: DefaultTypes.AnyFunction; + isPremium: boolean; + pingInterval: { _ref: number }; + socket: WebSocket; + _requestedConnect: boolean; + _requestedDisconnect: boolean; + connect: DefaultTypes.AnyFunction; + connected: boolean; + disconnect: DefaultTypes.AnyFunction; + handleClose: DefaultTypes.AnyFunction; + handleEvent: DefaultTypes.AnyFunction; + handleMessage: DefaultTypes.AnyFunction; + handleOpen: DefaultTypes.AnyFunction; + ping: DefaultTypes.AnyFunction; + } + export interface SpotifyDevice { + id: string; + is_active: boolean; + is_private_session: boolean; + is_restricted: boolean; + name: string; + supports_volume: boolean; + type: string; + volume_percent: number; + } export interface ElementParser { ReactMarkdown: DefaultTypes.AnyFunction; anyScopeRegex: DefaultTypes.AnyFunction;