mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-09 14:43:03 -04:00
Fix SoundboardLogger
This commit is contained in:
parent
9201d94404
commit
e348c258dc
3 changed files with 56 additions and 4 deletions
|
@ -9,15 +9,23 @@ import { Flex } from "@components/Flex";
|
|||
import { Margins } from "@utils/margins";
|
||||
import { classes, copyWithToast } from "@utils/misc";
|
||||
import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import { LazyComponent } from "@utils/react";
|
||||
import { filters, find } from "@webpack";
|
||||
import { Button, Clickable, Forms, Text, Tooltip, useEffect, UserUtils, useState } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
|
||||
import settings from "../settings";
|
||||
import { clearLoggedSounds, getLoggedSounds } from "../store";
|
||||
import { addListener, AvatarStyles, cl, downloadAudio, getEmojiUrl, playSound, removeListener, SoundLogEntry, UserSummaryItem } from "../utils";
|
||||
import { LogIcon } from "./Icons";
|
||||
import { openMoreUsersModal } from "./MoreUsersModal";
|
||||
import { openUserModal } from "./UserModal";
|
||||
|
||||
const HeaderBarIcon = LazyComponent(() => {
|
||||
const filter = filters.byCode(".HEADER_BAR_BADGE");
|
||||
return find(m => m.Icon && filter(m.Icon)).Icon;
|
||||
});
|
||||
|
||||
export async function openSoundBoardLog(): Promise<void> {
|
||||
|
||||
const data = await getLoggedSounds();
|
||||
|
@ -29,6 +37,17 @@ export async function openSoundBoardLog(): Promise<void> {
|
|||
|
||||
}
|
||||
|
||||
export function OpenSBLogsButton() {
|
||||
return (
|
||||
<HeaderBarIcon
|
||||
className="chatBarLogIcon"
|
||||
onClick={() => openSoundBoardLog()}
|
||||
tooltip={"Open SoundBoard Log"}
|
||||
icon={LogIcon}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default function SoundBoardLog({ data, closeModal }) {
|
||||
const [sounds, setSounds] = useState(data);
|
||||
const [users, setUsers] = useState<User[]>([]);
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
|
||||
import { addChatBarButton, removeChatBarButton } from "@api/ChatButtons";
|
||||
import { disableStyle, enableStyle } from "@api/Styles";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { FluxDispatcher } from "@webpack/common";
|
||||
|
||||
import { ChatBarIcon } from "./components/Icons";
|
||||
import { OpenSBLogsButton } from "./components/SoundBoardLog";
|
||||
import settings from "./settings";
|
||||
import { updateLoggedSounds } from "./store";
|
||||
import styles from "./styles.css?managed";
|
||||
|
@ -19,9 +21,34 @@ import { getListeners } from "./utils";
|
|||
export default definePlugin({
|
||||
name: "SoundBoardLogger",
|
||||
authors: [Devs.Moxxie, EquicordDevs.Fres, Devs.echo, EquicordDevs.thororen],
|
||||
dependencies: ["ChatInputButtonAPI"],
|
||||
settings,
|
||||
description: "Logs all soundboards that are played in a voice chat and allows you to download them",
|
||||
dependencies: ["ChatInputButtonAPI"],
|
||||
patches: [
|
||||
{
|
||||
predicate: () => settings.store.IconLocation === "toolbar",
|
||||
find: "toolbar:function",
|
||||
replacement: {
|
||||
match: /(function \i\(\i\){)(.{1,200}toolbar.{1,100}mobileToolbar)/,
|
||||
replace: "$1$self.addSBIconToToolBar(arguments[0]);$2"
|
||||
}
|
||||
}
|
||||
],
|
||||
settings,
|
||||
addSBIconToToolBar(e: { toolbar: React.ReactNode[] | React.ReactNode; }) {
|
||||
if (Array.isArray(e.toolbar))
|
||||
return e.toolbar.push(
|
||||
<ErrorBoundary noop={true}>
|
||||
<OpenSBLogsButton />
|
||||
</ErrorBoundary>
|
||||
);
|
||||
|
||||
e.toolbar = [
|
||||
<ErrorBoundary noop={true}>
|
||||
<OpenSBLogsButton />
|
||||
</ErrorBoundary>,
|
||||
e.toolbar,
|
||||
];
|
||||
},
|
||||
start() {
|
||||
enableStyle(styles);
|
||||
FluxDispatcher.subscribe("VOICE_CHANNEL_EFFECT_SEND", async sound => {
|
||||
|
@ -29,10 +56,10 @@ export default definePlugin({
|
|||
await updateLoggedSounds(sound);
|
||||
getListeners().forEach(cb => cb());
|
||||
});
|
||||
addChatBarButton("vc-soundlog-button", ChatBarIcon);
|
||||
if (settings.store.IconLocation === "chat") addChatBarButton("vc-soundlog-button", ChatBarIcon);
|
||||
},
|
||||
stop() {
|
||||
disableStyle(styles);
|
||||
removeChatBarButton("vc-soundlog-button");
|
||||
if (settings.store.IconLocation === "chat") removeChatBarButton("vc-soundlog-button");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -85,6 +85,12 @@ const settings = definePluginSettings({
|
|||
default: 0.5,
|
||||
markers: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
|
||||
},
|
||||
showLogsButton: {
|
||||
default: true,
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Toggle to whenever show the toolbox or not",
|
||||
restartNeeded: true,
|
||||
},
|
||||
});
|
||||
|
||||
export default settings;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue