/*
* Vencord, a modification for Discord's desktop app
* Copyright (c) 2022 Sofia Lima
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import { Link } from "../components/Link";
import { Devs } from "../utils/constants";
import { lazyWebpack } from "../utils/misc";
import definePlugin, { OptionType } from "../utils/types";
import { Settings, Webpack } from "../Vencord";
import { FluxDispatcher, Forms } from "../webpack/common";
interface ActivityAssets {
large_image?: string
large_text?: string
small_image?: string
small_text?: string
}
interface Activity {
state: string
details?: string
timestamps?: {
start?: Number
}
assets?: ActivityAssets
buttons?: Array
name: string
application_id: string
metadata?: {
button_urls?: Array
}
type: Number
flags: Number
}
interface TrackData {
name: string
album: string
artist: string
url: string
imageUrl?: string
}
// only relevant enum values
enum ActivityType {
PLAYING = 0,
LISTENING = 2,
}
enum ActivityFlag {
INSTANCE = 1 << 0,
}
const applicationId = "1043533871037284423";
const presenceStore = lazyWebpack(Webpack.filters.byProps("getLocalPresence"));
const assetManager = Webpack.mapMangledModuleLazy(
"getAssetImage: size must === [number, number] for Twitch",
{
getAsset: Webpack.filters.byCode("apply("),
}
);
async function getApplicationAsset(key: string): Promise {
return (await assetManager.getAsset(applicationId, [key, undefined]))[0];
}
function setActivity(activity?: Activity) {
FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", activity: activity });
}
export default definePlugin({
name: "LastFMRichPresence",
description: "Little plugin for Last.fm rich presence",
authors: [Devs.dzshn],
settingsAboutComponent: () => (
<>
How to get an API key
An API key is required to fetch your current track. To get one, you can
visit this page and
fill in the following information: