54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
/*
|
|
* Vencord, a Discord client mod
|
|
* Copyright (c) 2024 Vendicated and contributors
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*/
|
|
|
|
import { Alerts, Button, ChannelStore } from "@webpack/common";
|
|
|
|
import { CLONE_LINK_REGEX, Native, plugins } from ".";
|
|
|
|
const WHITELISTED_SHARE_CHANNELS = ["1256395889354997771", "1032200195582197831", "1301947896601509900", "1322935137591365683"];
|
|
|
|
export default function UserpluginInstallButton({ props }: any) {
|
|
const { message } = props;
|
|
if (!WHITELISTED_SHARE_CHANNELS.includes(ChannelStore.getChannel(message.channel_id).parent_id) && !WHITELISTED_SHARE_CHANNELS.includes(message.channel_id))
|
|
return;
|
|
const gitLink = (props.message.content as string).match(CLONE_LINK_REGEX);
|
|
if (!gitLink) return;
|
|
const installed = plugins.includes(gitLink[1]);
|
|
return <>
|
|
<div style={{ display: "flex" }}>
|
|
<Button style={{
|
|
marginTop: "5px"
|
|
}}
|
|
onClick={async () => {
|
|
try {
|
|
await Native.initPluginInstall(gitLink[0], gitLink[1], gitLink[2], gitLink[3]);
|
|
|
|
}
|
|
catch (e) {
|
|
if (e.toString().includes("silentStop")) return;
|
|
Alerts.show({
|
|
title: "Install error",
|
|
body: e.toString()
|
|
});
|
|
}
|
|
}}>
|
|
{installed ? "Reinstall" : "Install"} plugin
|
|
</Button>
|
|
{
|
|
installed && <Button style={{
|
|
marginTop: "5px",
|
|
marginLeft: "10px"
|
|
}}
|
|
color={Button.Colors.RED}
|
|
onClick={() => {
|
|
|
|
}}>
|
|
Uninstall plugin
|
|
</Button>
|
|
}
|
|
</div>
|
|
</>;
|
|
}
|