diff --git a/src/equicordplugins/saveFavoriteGIFs/index.tsx b/src/equicordplugins/saveFavoriteGIFs/index.tsx index 063895517..951f609ff 100644 --- a/src/equicordplugins/saveFavoriteGIFs/index.tsx +++ b/src/equicordplugins/saveFavoriteGIFs/index.tsx @@ -4,14 +4,15 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { ApplicationCommandType } from "@api/Commands"; +import { ApplicationCommandInputType } from "@api/Commands"; import { showNotification } from "@api/Notifications"; +import { isPluginEnabled } from "@api/PluginManager"; import { definePluginSettings } from "@api/Settings"; import equicordToolbox from "@equicordplugins/equicordToolbox"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { saveFile } from "@utils/web"; -import { UserSettingsActionCreators } from "@webpack/common"; +import { Menu, UserSettingsActionCreators } from "@webpack/common"; async function saveContentToFile(content: string, filename: string) { try { @@ -45,7 +46,7 @@ function getGifUrls(): string[] { async function saveAllGifs() { const filename = `favorite-gifs-${new Date().toISOString().split("T")[0]}.txt`; const gifUrls = getGifUrls(); - + if (gifUrls.length === 0) { showNotification({ title: "Save Favorite GIFs", body: "No favorite GIFs found..?" }); return; @@ -57,7 +58,7 @@ async function saveAllGifs() { async function saveWorkingGifs() { const gifUrls = getGifUrls(); - + if (gifUrls.length === 0) { showNotification({ title: "Save Favorite GIFs", body: "No favorite GIFs found?" }); return; @@ -66,12 +67,11 @@ async function saveWorkingGifs() { showNotification({ title: "Save Favorite GIFs", body: `Testing ${gifUrls.length} GIFs.. This may take a moment...`, - loading: true }); const workingUrls: string[] = []; - await Promise.all(gifUrls.map(async (url) => { + await Promise.all(gifUrls.map(async url => { try { const response = await fetch(url, { method: "HEAD" }); if (response.ok) workingUrls.push(url); @@ -90,9 +90,9 @@ async function saveWorkingGifs() { const filename = `working-gifs-${new Date().toISOString().split("T")[0]}.txt`; const content = workingUrls.join("\n"); - + await saveContentToFile(content, filename); - + showNotification({ title: "Save Favorite GIFs", body: `Filtered ${gifUrls.length - workingUrls.length} possibly broken GIFs. Saved ${workingUrls.length} working GIFs.`, @@ -121,24 +121,27 @@ export default definePlugin({ { name: "savegifs", description: "Save all favorite GIF urls to a text file", - type: ApplicationCommandType.Chat, - action: saveAllGifs + inputType: ApplicationCommandInputType.BUILT_IN, + execute: saveAllGifs }, { name: "saveworkinggifs", description: "Test all favorite GIFs and only save the ones that are still working", - type: ApplicationCommandType.Chat, - action: saveWorkingGifs + inputType: ApplicationCommandInputType.BUILT_IN, + execute: saveWorkingGifs } ], toolboxActions() { const { showToolboxButton } = settings.use(["showToolboxButton"]); if (!showToolboxButton) return null; - return { - "Save Favorite GIFs": () => { - saveAllGifs(); - } - }; + return ( +