This commit is contained in:
thororen 2026-10-03 11:16:17 -04:00
parent cfec48401b
commit e68a69641c
No known key found for this signature in database
82 changed files with 403 additions and 785 deletions

View file

@ -19,7 +19,8 @@ import { HashLink } from "@components/settings/tabs/updater/Components";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { useAwaiter } from "@utils/react"; import { useAwaiter } from "@utils/react";
import { getRepo, UpdateLogger } from "@utils/updater"; import { getRepo, UpdateLogger } from "@utils/updater";
import { Alerts, React, Toasts } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { Alerts, React, showToast } from "@webpack/common";
import gitHash from "~git-hash"; import gitHash from "~git-hash";
@ -352,14 +353,9 @@ function ChangelogContent() {
const logged = await ensureLocalUpdateLogged(); const logged = await ensureLocalUpdateLogged();
if (!logged) { if (!logged) {
setChangelog([]); setChangelog([]);
Toasts.show({ showToast("Already up to date with repository", "message", {
message: "Already up to date with repository", position: ToastPosition.BOTTOM,
id: Toasts.genId(), });
type: Toasts.Type.MESSAGE,
options: {
position: Toasts.Position.BOTTOM,
},
});
} }
return; return;
} }
@ -384,27 +380,17 @@ function ChangelogContent() {
await loadChangelogHistory(); await loadChangelogHistory();
setRecentlyChecked(true); setRecentlyChecked(true);
Toasts.show({ showToast(`Found ${updates.value.length} commit${updates.value.length === 1 ? "" : "s"} from repository`, "success", {
message: `Found ${updates.value.length} commit${updates.value.length === 1 ? "" : "s"} from repository`, position: ToastPosition.BOTTOM,
id: Toasts.genId(), });
type: Toasts.Type.SUCCESS,
options: {
position: Toasts.Position.BOTTOM,
},
});
} else { } else {
const logged = await ensureLocalUpdateLogged(); const logged = await ensureLocalUpdateLogged();
setRecentlyChecked(true); setRecentlyChecked(true);
Toasts.show({ showToast(logged
message: logged
? "Logged commits from your latest update" ? "Logged commits from your latest update"
: "Repository is up to date with your local copy", : "Repository is up to date with your local copy", logged ? "success" : "message", {
id: Toasts.genId(), position: ToastPosition.BOTTOM,
type: logged ? Toasts.Type.SUCCESS : Toasts.Type.MESSAGE, });
options: {
position: Toasts.Position.BOTTOM,
},
});
if (!logged) { if (!logged) {
setChangelog([]); setChangelog([]);
} }
@ -422,14 +408,9 @@ function ChangelogContent() {
setError(errorMessage); setError(errorMessage);
// funny little error toast hopefully doesn't happen! // funny little error toast hopefully doesn't happen!
Toasts.show({ showToast("Could not fetch commits from repository", "failure", {
message: "Could not fetch commits from repository", position: ToastPosition.BOTTOM,
id: Toasts.genId(), });
type: Toasts.Type.FAILURE,
options: {
position: Toasts.Position.BOTTOM,
},
});
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
@ -520,14 +501,9 @@ function ChangelogContent() {
await clearChangelogHistory(); await clearChangelogHistory();
await loadChangelogHistory(); await loadChangelogHistory();
setShowHistory(false); setShowHistory(false);
Toasts.show({ showToast("All logs have been cleared", "success", {
message: "All logs have been cleared", position: ToastPosition.BOTTOM,
id: Toasts.genId(), });
type: Toasts.Type.SUCCESS,
options: {
position: Toasts.Position.BOTTOM,
},
});
}, },
}); });
}} }}
@ -659,14 +635,9 @@ function ChangelogContent() {
Array.from(expandedLogs).filter(id => id !== logId), Array.from(expandedLogs).filter(id => id !== logId),
), ),
); );
Toasts.show({ showToast("Log has been cleared", "success", {
message: "Log has been cleared", position: ToastPosition.BOTTOM,
id: Toasts.genId(), });
type: Toasts.Type.SUCCESS,
options: {
position: Toasts.Position.BOTTOM,
},
});
}, },
}); });
}} }}

View file

@ -34,8 +34,9 @@ import { Margins } from "@utils/margins";
import { classes, isObjectEmpty } from "@utils/misc"; import { classes, isObjectEmpty } from "@utils/misc";
import { OptionType, Plugin, PluginTag } from "@utils/types"; import { OptionType, Plugin, PluginTag } from "@utils/types";
import { RenderModalProps, User } from "@vencord/discord-types"; import { RenderModalProps, User } from "@vencord/discord-types";
import { ToastPosition } from "@vencord/discord-types/enums";
import { findComponentByCodeLazy, findCssClassesLazy } from "@webpack"; import { findComponentByCodeLazy, findCssClassesLazy } from "@webpack";
import { Clickable, FluxDispatcher, Modal, openModal, React, Text, Toasts, Tooltip, useEffect, useMemo, UserStore, UserSummaryItem, UserUtils, useState } from "@webpack/common"; import { Clickable, FluxDispatcher, Modal, openModal, React, showToast,Text, Tooltip, useEffect, useMemo, UserStore, UserSummaryItem, UserUtils, useState } from "@webpack/common";
import { Constructor } from "type-fest"; import { Constructor } from "type-fest";
import { PluginMeta } from "~plugins"; import { PluginMeta } from "~plugins";
@ -324,14 +325,9 @@ function resetSettings(plugin: Plugin, onRestartNeeded?: (pluginName: string) =>
onRestartNeeded?.(plugin.name); onRestartNeeded?.(plugin.name);
} }
Toasts.show({ showToast(`Settings for ${pluginName} have been reset.`, "success", {
message: `Settings for ${pluginName} have been reset.`, position: ToastPosition.TOP
id: Toasts.genId(), });
type: Toasts.Type.SUCCESS,
options: {
position: Toasts.Position.TOP
}
});
} }
export function openWarningModal(plugin?: Plugin | null, onRestartNeeded?: (pluginName: string) => void, isPlugin = true, enabledPlugins?: number | null, reset?: () => void) { export function openWarningModal(plugin?: Plugin | null, onRestartNeeded?: (pluginName: string) => void, isPlugin = true, enabledPlugins?: number | null, reset?: () => void) {

View file

@ -38,7 +38,8 @@ import { classes } from "@utils/misc";
import { PluginTarget } from "@utils/pluginTargets"; import { PluginTarget } from "@utils/pluginTargets";
import { useAwaiter, useCleanupEffect, useIntersection } from "@utils/react"; import { useAwaiter, useCleanupEffect, useIntersection } from "@utils/react";
import { PluginTag, PluginTags } from "@utils/types"; import { PluginTag, PluginTags } from "@utils/types";
import { Alerts, ConfirmModal, lodash, openModal, Parser, React, SearchableSelect, Select, TextInput, Toasts, Tooltip, useCallback, useMemo, useRef, useState } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { Alerts, ConfirmModal, lodash, openModal, Parser, React, SearchableSelect, Select, showToast,TextInput, Tooltip, useCallback, useMemo, useRef, useState } from "@webpack/common";
import { JSX } from "react"; import { JSX } from "react";
import Plugins, { ExcludedPlugins, PluginMeta } from "~plugins"; import Plugins, { ExcludedPlugins, PluginMeta } from "~plugins";
@ -52,14 +53,9 @@ export const cl = classNameFactory("vc-plugins-");
export const logger = new Logger("PluginSettings", "#a6d189"); export const logger = new Logger("PluginSettings", "#a6d189");
function showErrorToast(message: string) { function showErrorToast(message: string) {
Toasts.show({ showToast(message, "failure", {
message, position: ToastPosition.BOTTOM
type: Toasts.Type.FAILURE, });
id: Toasts.genId(),
options: {
position: Toasts.Position.BOTTOM
}
});
} }
function ReloadRequiredCard({ required, enabledPlugins, openWarningModal, resetCheckAndDo }) { function ReloadRequiredCard({ required, enabledPlugins, openWarningModal, resetCheckAndDo }) {

View file

@ -18,7 +18,7 @@ import { copyWithToast } from "@utils/discord";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import { getStylusWebStoreUrl } from "@utils/web"; import { getStylusWebStoreUrl } from "@utils/web";
import { React, Select, showToast, TextInput, Toasts, useEffect, useMemo, useRef, useState } from "@webpack/common"; import { React, Select, showToast, TextInput, useEffect, useMemo, useRef, useState } from "@webpack/common";
import { SyntheticEvent } from "react"; import { SyntheticEvent } from "react";
import { OnlineThemesSection } from "./OnlineThemes"; import { OnlineThemesSection } from "./OnlineThemes";
@ -263,9 +263,9 @@ function ThemesTab() {
setOnlineThemes(prev => setOnlineThemes(prev =>
prev?.map(t => t.link === link ? updatedTheme : t) ?? null prev?.map(t => t.link === link ? updatedTheme : t) ?? null
); );
showToast("Theme refreshed!", Toasts.Type.SUCCESS); showToast("Theme refreshed!", "success");
} catch { } catch {
showToast("Failed to refresh theme", Toasts.Type.FAILURE); showToast("Failed to refresh theme", "failure");
} }
} }
@ -288,7 +288,7 @@ function ThemesTab() {
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
} }
} catch { } catch {
showToast("Failed to download theme", Toasts.Type.FAILURE); showToast("Failed to download theme", "failure");
} }
} }

View file

@ -15,7 +15,7 @@ import { Margins } from "@utils/margins";
import { relaunch } from "@utils/native"; import { relaunch } from "@utils/native";
import { changes, checkForUpdates, update, updateError } from "@utils/updater"; import { changes, checkForUpdates, update, updateError } from "@utils/updater";
import { ToastPosition } from "@vencord/discord-types/enums"; import { ToastPosition } from "@vencord/discord-types/enums";
import { ConfirmModal, openModal, React, showToast, Toasts, useState } from "@webpack/common"; import { ConfirmModal, openModal, React, showToast, useState } from "@webpack/common";
import { runWithDispatch } from "./runWithDispatch"; import { runWithDispatch } from "./runWithDispatch";
@ -91,14 +91,9 @@ export function Updatable(props: CommonProps) {
} else { } else {
setUpdates([]); setUpdates([]);
Toasts.show({ showToast("No updates found!", "message", {
message: "No updates found!", position: ToastPosition.BOTTOM
id: Toasts.genId(), });
type: Toasts.Type.MESSAGE,
options: {
position: Toasts.Position.BOTTOM
}
});
} }
})} })}
> >

View file

@ -10,7 +10,7 @@ import { definePluginSettings } from "@api/Settings";
import { EquicordDevs } from "@utils/constants"; import { EquicordDevs } from "@utils/constants";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { ColorUtils, React, showToast, Toasts } from "@webpack/common"; import { ColorUtils, React, showToast } from "@webpack/common";
const cl = classNameFactory("vc-better-audio-player-"); const cl = classNameFactory("vc-better-audio-player-");
const CORS_PROXY = "https://cors.keiran0.workers.dev?url="; const CORS_PROXY = "https://cors.keiran0.workers.dev?url=";
@ -39,7 +39,7 @@ function validateColor(value: string, key: string, fallback: string) {
} }
} catch { /* invalid hex */ } } catch { /* invalid hex */ }
showToast(`Invalid color format for ${key}, use "R, G, B" or "#RRGGBB"`, Toasts.Type.FAILURE); showToast(`Invalid color format for ${key}, use "R, G, B" or "#RRGGBB"`, "failure");
settings.store[key] = fallback; settings.store[key] = fallback;
} }

View file

@ -13,7 +13,7 @@ import { Logger } from "@utils/Logger";
import { classes, pluralise } from "@utils/misc"; import { classes, pluralise } from "@utils/misc";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { chooseFile, saveFile } from "@utils/web"; import { chooseFile, saveFile } from "@utils/web";
import { Alerts, Button, React, showToast, Toasts, useCallback, useEffect, useRef, useState } from "@webpack/common"; import { Alerts, Button, React, showToast, useCallback, useEffect, useRef, useState } from "@webpack/common";
import { cl, croppedLabel, Shelf } from "./components/Shelf"; import { cl, croppedLabel, Shelf } from "./components/Shelf";
import { add, clear, CropState, currentApplied, Entry, exportAll, forget, forgetCrops, getFile, getThumbs, Group, importAll, Kind, previousApplied, readIndex, recordApplied, saveCrop, toDataUrl, togglePin, touch } from "./library"; import { add, clear, CropState, currentApplied, Entry, exportAll, forget, forgetCrops, getFile, getThumbs, Group, importAll, Kind, previousApplied, readIndex, recordApplied, saveCrop, toDataUrl, togglePin, touch } from "./library";
@ -86,7 +86,7 @@ const settings = definePluginSettings({
onConfirm: () => forgetCrops() onConfirm: () => forgetCrops()
.then(count => showToast( .then(count => showToast(
count ? `Forgot the framing on ${pluralise(count, "picture")}` : "Nothing was framed", count ? `Forgot the framing on ${pluralise(count, "picture")}` : "Nothing was framed",
Toasts.Type.SUCCESS "success"
)) ))
.catch(err => logger.error("could not forget the remembered crops", err)) .catch(err => logger.error("could not forget the remembered crops", err))
})} })}
@ -165,7 +165,7 @@ async function exportLibrary() {
else saveFile(new File([data], FILENAME, { type: "application/json" })); else saveFile(new File([data], FILENAME, { type: "application/json" }));
} catch (err) { } catch (err) {
logger.error("could not export the library", err); logger.error("could not export the library", err);
showToast("Could not export your pictures", Toasts.Type.FAILURE); showToast("Could not export your pictures", "failure");
} }
} }
@ -186,11 +186,11 @@ async function importLibrary() {
const added = await importAll(json, settings.store.librarySize); const added = await importAll(json, settings.store.librarySize);
showToast( showToast(
added ? `Added ${pluralise(added, "picture")}` : "Nothing new in that file", added ? `Added ${pluralise(added, "picture")}` : "Nothing new in that file",
Toasts.Type.SUCCESS "success"
); );
} catch (err) { } catch (err) {
logger.error("could not import the library", err); logger.error("could not import the library", err);
showToast("Could not read that file", Toasts.Type.FAILURE); showToast("Could not read that file", "failure");
} }
} }
@ -324,7 +324,7 @@ function PickerShelf({ kind, open, complete, maxSize }: {
const onPick = useCallback(async (entry: Entry) => { const onPick = useCallback(async (entry: Entry) => {
const blob = await getFile(entry.id); const blob = await getFile(entry.id);
if (!blob) return showToast("That picture is missing", Toasts.Type.FAILURE); if (!blob) return showToast("That picture is missing", "failure");
const file = new File([blob], entry.name, { type: blob.type }); const file = new File([blob], entry.name, { type: blob.type });
await touch(entry.id); await touch(entry.id);
@ -344,7 +344,7 @@ function PickerShelf({ kind, open, complete, maxSize }: {
}, [bump]); }, [bump]);
const accept = useCallback(async (file: File) => { const accept = useCallback(async (file: File) => {
if (maxSize && file.size > maxSize) return showToast("That picture is too big for Discord", Toasts.Type.FAILURE); if (maxSize && file.size > maxSize) return showToast("That picture is too big for Discord", "failure");
try { try {
const entry = await add(file, kind, "original", settings.store.librarySize); const entry = await add(file, kind, "original", settings.store.librarySize);
@ -352,7 +352,7 @@ function PickerShelf({ kind, open, complete, maxSize }: {
await hand(entry.id, file, settings.store.rememberCrop ? entry.crop ?? null : null); await hand(entry.id, file, settings.store.rememberCrop ? entry.crop ?? null : null);
} catch (err) { } catch (err) {
logger.error("could not take that picture", err); logger.error("could not take that picture", err);
showToast("Could not use that picture", Toasts.Type.FAILURE); showToast("Could not use that picture", "failure");
} }
}, [kind, hand, bump, maxSize]); }, [kind, hand, bump, maxSize]);
@ -432,7 +432,7 @@ function EditorShelf({ Original, ownProps }: { Original: React.ComponentType<Edi
await show(entry.id, file, settings.store.rememberCrop ? entry.crop ?? null : null); await show(entry.id, file, settings.store.rememberCrop ? entry.crop ?? null : null);
} catch (err) { } catch (err) {
logger.error("could not take that picture", err); logger.error("could not take that picture", err);
showToast("Could not use that picture", Toasts.Type.FAILURE); showToast("Could not use that picture", "failure");
} }
}, [kind, show, bump, setGroup]); }, [kind, show, bump, setGroup]);
@ -440,7 +440,7 @@ function EditorShelf({ Original, ownProps }: { Original: React.ComponentType<Edi
const onPick = useCallback(async (entry: Entry) => { const onPick = useCallback(async (entry: Entry) => {
const blob = await getFile(entry.id); const blob = await getFile(entry.id);
if (!blob) return showToast("That picture is missing", Toasts.Type.FAILURE); if (!blob) return showToast("That picture is missing", "failure");
await touch(entry.id); await touch(entry.id);
bump(); bump();
@ -464,7 +464,7 @@ function EditorShelf({ Original, ownProps }: { Original: React.ComponentType<Edi
}; };
const run = () => save().catch(err => { const run = () => save().catch(err => {
logger.error("could not keep the cropped copy", err); logger.error("could not keep the cropped copy", err);
showToast("Could not keep the cropped copy", Toasts.Type.FAILURE); showToast("Could not keep the cropped copy", "failure");
}); });
if (!settings.store.askBeforeSavingCropped) return void run(); if (!settings.store.askBeforeSavingCropped) return void run();

View file

@ -7,7 +7,7 @@
import { DataStore } from "@api/index"; import { DataStore } from "@api/index";
import { isPluginEnabled } from "@api/PluginManager"; import { isPluginEnabled } from "@api/PluginManager";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import { NavigationRouter, SelectedChannelStore, SelectedGuildStore, showToast, Toasts, useEffect, useRef, useState } from "@webpack/common"; import { NavigationRouter, SelectedChannelStore, SelectedGuildStore, showToast, useEffect, useRef, useState } from "@webpack/common";
import { JSX } from "react"; import { JSX } from "react";
import { logger, settings } from "./constants"; import { logger, settings } from "./constants";
@ -418,7 +418,7 @@ export async function openStartupTabs(props: BasicChannelTabsProps & { userId: s
savedTabs = persistedTabs?.[userId]; savedTabs = persistedTabs?.[userId];
} catch (error) { } catch (error) {
logger.error("Failed to load persisted tabs from DataStore", error); logger.error("Failed to load persisted tabs from DataStore", error);
showToast("Failed to load saved tabs", Toasts.Type.FAILURE); showToast("Failed to load saved tabs", "failure");
} }
} }
@ -430,14 +430,14 @@ export async function openStartupTabs(props: BasicChannelTabsProps & { userId: s
if (keepCurrentChannel) { if (keepCurrentChannel) {
hydratedUserId = undefined; hydratedUserId = undefined;
showToast("Not restoring tabs as KeepCurrentChannel is enabled", Toasts.Type.FAILURE); showToast("Not restoring tabs as KeepCurrentChannel is enabled", "failure");
return; return;
} }
switch (settings.store.onStartup) { switch (settings.store.onStartup) {
case "remember": { case "remember": {
if (!savedTabs?.openTabs.length) { if (!savedTabs?.openTabs.length) {
showToast("Failed to restore tabs", Toasts.Type.FAILURE); showToast("Failed to restore tabs", "failure");
break; break;
} }

View file

@ -9,7 +9,7 @@ import { Flex } from "@components/Flex";
import { Heading } from "@components/Heading"; import { Heading } from "@components/Heading";
import { Paragraph } from "@components/Paragraph"; import { Paragraph } from "@components/Paragraph";
import type { RenderModalProps } from "@vencord/discord-types"; import type { RenderModalProps } from "@vencord/discord-types";
import { Checkbox, FluxDispatcher, MessageActions, Modal, openModal, PendingReplyStore, showToast, Toasts, useEffect, useState } from "@webpack/common"; import { Checkbox, FluxDispatcher, MessageActions, Modal, openModal, PendingReplyStore, showToast, useEffect, useState } from "@webpack/common";
import { ApplicationField, BooleanField, DateTimeField, getDateTimeLocalValue, ParticipantField, TextField } from "./fields"; import { ApplicationField, BooleanField, DateTimeField, getDateTimeLocalValue, ParticipantField, TextField } from "./fields";
import { abortActiveClipUploads, type ClipMetadata, getClipCreatedAt, getClipTitleFromName, getDefaultClipTitle, getDefaultFileName, getErrorMessage, getParticipantIds, getString, isValidDate, pickClipFile, uploadClipFile } from "./upload"; import { abortActiveClipUploads, type ClipMetadata, getClipCreatedAt, getClipTitleFromName, getDefaultClipTitle, getDefaultFileName, getErrorMessage, getParticipantIds, getString, isValidDate, pickClipFile, uploadClipFile } from "./upload";
@ -52,7 +52,7 @@ function UploadClipFileModal({ modalProps, channelId, clip }: { modalProps: Rend
result = await pickClipFile(parseMetadata); result = await pickClipFile(parseMetadata);
if (!result) return; if (!result) return;
} catch (error) { } catch (error) {
showToast(getErrorMessage(error), Toasts.Type.FAILURE); showToast(getErrorMessage(error), "failure");
return; return;
} }

View file

@ -8,7 +8,7 @@ import { Logger } from "@utils/Logger";
import { isObject } from "@utils/misc"; import { isObject } from "@utils/misc";
import type { PluginNative } from "@utils/types"; import type { PluginNative } from "@utils/types";
import type { User } from "@vencord/discord-types"; import type { User } from "@vencord/discord-types";
import { Constants, MediaEngineStore, RestAPI, showToast, SnowflakeUtils, Toasts } from "@webpack/common"; import { Constants, MediaEngineStore, RestAPI, showToast, SnowflakeUtils } from "@webpack/common";
import { convertClipToMp4 } from "./ffmpeg"; import { convertClipToMp4 } from "./ffmpeg";
const logger = new Logger("ClipUpload"); const logger = new Logger("ClipUpload");
@ -329,7 +329,7 @@ function shouldRetryWithFFmpeg(error: unknown) {
export async function uploadClipFile(file: File, options: ClipUploadOptions) { export async function uploadClipFile(file: File, options: ClipUploadOptions) {
try { try {
showToast("Checking clip file.", Toasts.Type.MESSAGE); showToast("Checking clip file.", "message");
const uploadFile = await prepareClipFile(file, options.fileName); const uploadFile = await prepareClipFile(file, options.fileName);
@ -338,15 +338,15 @@ export async function uploadClipFile(file: File, options: ClipUploadOptions) {
} catch (error) { } catch (error) {
if (!shouldRetryWithFFmpeg(error)) throw error; if (!shouldRetryWithFFmpeg(error)) throw error;
showToast("Converting clip file.", Toasts.Type.MESSAGE); showToast("Converting clip file.", "message");
await sendClipUpload(await stampVideoFile(await convertClipToMp4(file, options.fileName), options.fileName), options); await sendClipUpload(await stampVideoFile(await convertClipToMp4(file, options.fileName), options.fileName), options);
} }
showToast("Clip uploaded.", Toasts.Type.SUCCESS); showToast("Clip uploaded.", "success");
return true; return true;
} catch (error) { } catch (error) {
logger.error(error); logger.error(error);
showToast(getErrorMessage(error), Toasts.Type.FAILURE); showToast(getErrorMessage(error), "failure");
return false; return false;
} }
} }

View file

@ -6,7 +6,7 @@
import { insertTextIntoChatInputBox } from "@utils/discord"; import { insertTextIntoChatInputBox } from "@utils/discord";
import { parseUrl } from "@utils/misc"; import { parseUrl } from "@utils/misc";
import { showToast, Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
import { registerCommands } from "../api/registry"; import { registerCommands } from "../api/registry";
import type { FormPageSpec, PageEntry, PaletteAction, PaletteCommand } from "../api/types"; import type { FormPageSpec, PageEntry, PaletteAction, PaletteCommand } from "../api/types";
@ -109,7 +109,7 @@ function commandForm(existing: CustomCommandData | null): PageEntry {
: [...store.get(), next]); : [...store.get(), next]);
registerCustomCommands(); registerCustomCommands();
showToast(existing ? "Command saved." : "Command created.", Toasts.Type.SUCCESS); showToast(existing ? "Command saved." : "Command created.", "success");
ctx.pop(); ctx.pop();
} }
}; };
@ -138,7 +138,7 @@ function toCommand(data: CustomCommandData): PaletteCommand {
run() { run() {
store.set(store.get().filter(entry => entry.id !== data.id)); store.set(store.get().filter(entry => entry.id !== data.id));
registerCustomCommands(); registerCustomCommands();
showToast("Command deleted.", Toasts.Type.SUCCESS); showToast("Command deleted.", "success");
} }
} }
]; ];

View file

@ -7,7 +7,7 @@
import { getUserSettingLazy } from "@api/UserSettings"; import { getUserSettingLazy } from "@api/UserSettings";
import type { Theme } from "@vencord/discord-types"; import type { Theme } from "@vencord/discord-types";
import { findByCodeLazy } from "@webpack"; import { findByCodeLazy } from "@webpack";
import { showToast, ThemeStore, Toasts, VoiceActions } from "@webpack/common"; import { showToast, ThemeStore, VoiceActions } from "@webpack/common";
import type { PaletteCommand } from "../api/types"; import type { PaletteCommand } from "../api/types";
import { CircleIcon, HeadphonesIcon, MicIcon, MoonIcon } from "../ui/icons"; import { CircleIcon, HeadphonesIcon, MicIcon, MoonIcon } from "../ui/icons";
@ -78,7 +78,7 @@ export const discordCommands: PaletteCommand[] = [
label: `Set ${status.label}`, label: `Set ${status.label}`,
run() { run() {
StatusSetting?.updateSetting(status.value); StatusSetting?.updateSetting(status.value);
showToast(`Status set to ${status.label}.`, Toasts.Type.SUCCESS); showToast(`Status set to ${status.label}.`, "success");
} }
}] }]
})) }))
@ -98,7 +98,7 @@ export const discordCommands: PaletteCommand[] = [
const currentIdx = THEMES.findIndex(theme => theme.value === ThemeStore.theme); const currentIdx = THEMES.findIndex(theme => theme.value === ThemeStore.theme);
const next = THEMES[(currentIdx + 1) % THEMES.length]; const next = THEMES[(currentIdx + 1) % THEMES.length];
updateDiscordTheme({ theme: next.value }); updateDiscordTheme({ theme: next.value });
showToast(`Theme set to ${next.label}.`, Toasts.Type.SUCCESS); showToast(`Theme set to ${next.label}.`, "success");
} }
}] }]
} }

View file

@ -5,7 +5,7 @@
*/ */
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { SettingsRouter, showToast, Toasts } from "@webpack/common"; import { SettingsRouter, showToast } from "@webpack/common";
export interface SettingsRoute { export interface SettingsRoute {
route: string; route: string;
@ -110,7 +110,7 @@ const logger = new Logger("CommandPalette");
export async function openSettingsPage(route: string, label?: string) { export async function openSettingsPage(route: string, label?: string) {
const candidates = resolveRouteCandidates(route); const candidates = resolveRouteCandidates(route);
if (candidates.length === 0) { if (candidates.length === 0) {
showToast("No settings page was provided.", Toasts.Type.FAILURE); showToast("No settings page was provided.", "failure");
return false; return false;
} }
@ -124,6 +124,6 @@ export async function openSettingsPage(route: string, label?: string) {
} }
} }
showToast(`Unable to open ${label ?? "that settings page"}.`, Toasts.Type.FAILURE); showToast(`Unable to open ${label ?? "that settings page"}.`, "failure");
return false; return false;
} }

View file

@ -8,7 +8,7 @@ import { isPluginEnabled, pluginRequiresRestart, plugins, startDependenciesRecur
import { Settings } from "@api/Settings"; import { Settings } from "@api/Settings";
import { openPluginModal } from "@components/settings/tabs/plugins/PluginModal"; import { openPluginModal } from "@components/settings/tabs/plugins/PluginModal";
import type { Plugin } from "@utils/types"; import type { Plugin } from "@utils/types";
import { showToast, Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
import type { PaletteCommand, PaletteListItem } from "../api/types"; import type { PaletteCommand, PaletteListItem } from "../api/types";
import { GearIcon, PlugIcon } from "../ui/icons"; import { GearIcon, PlugIcon } from "../ui/icons";
@ -20,37 +20,37 @@ function togglePlugin(plugin: Plugin) {
if (!wasEnabled) { if (!wasEnabled) {
const { restartNeeded, failures } = startDependenciesRecursive(plugin); const { restartNeeded, failures } = startDependenciesRecursive(plugin);
if (failures.length) { if (failures.length) {
showToast(`Failed to start dependencies: ${failures.join(", ")}`, Toasts.Type.FAILURE); showToast(`Failed to start dependencies: ${failures.join(", ")}`, "failure");
return; return;
} }
if (restartNeeded) { if (restartNeeded) {
pluginSettings.enabled = true; pluginSettings.enabled = true;
showToast(`${plugin.name} enabled. Restart to apply.`, Toasts.Type.MESSAGE); showToast(`${plugin.name} enabled. Restart to apply.`, "message");
return; return;
} }
} }
if (pluginRequiresRestart(plugin)) { if (pluginRequiresRestart(plugin)) {
pluginSettings.enabled = !wasEnabled; pluginSettings.enabled = !wasEnabled;
showToast(`${plugin.name} ${wasEnabled ? "disabled" : "enabled"}. Restart to apply.`, Toasts.Type.MESSAGE); showToast(`${plugin.name} ${wasEnabled ? "disabled" : "enabled"}. Restart to apply.`, "message");
return; return;
} }
if (wasEnabled && !plugin.started) { if (wasEnabled && !plugin.started) {
pluginSettings.enabled = false; pluginSettings.enabled = false;
showToast(`${plugin.name} disabled.`, Toasts.Type.SUCCESS); showToast(`${plugin.name} disabled.`, "success");
return; return;
} }
const result = wasEnabled ? stopPlugin(plugin) : startPlugin(plugin); const result = wasEnabled ? stopPlugin(plugin) : startPlugin(plugin);
if (!result) { if (!result) {
pluginSettings.enabled = false; pluginSettings.enabled = false;
showToast(`Error while ${wasEnabled ? "stopping" : "starting"} ${plugin.name}.`, Toasts.Type.FAILURE); showToast(`Error while ${wasEnabled ? "stopping" : "starting"} ${plugin.name}.`, "failure");
return; return;
} }
pluginSettings.enabled = !wasEnabled; pluginSettings.enabled = !wasEnabled;
showToast(`${plugin.name} ${wasEnabled ? "disabled" : "enabled"}.`, Toasts.Type.SUCCESS); showToast(`${plugin.name} ${wasEnabled ? "disabled" : "enabled"}.`, "success");
} }
function pluginItems(): PaletteListItem[] { function pluginItems(): PaletteListItem[] {

View file

@ -7,7 +7,7 @@
import { openPrivateChannel, sendMessage } from "@utils/discord"; import { openPrivateChannel, sendMessage } from "@utils/discord";
import { sleep } from "@utils/misc"; import { sleep } from "@utils/misc";
import { CloudUploadPlatform } from "@vencord/discord-types/enums"; import { CloudUploadPlatform } from "@vencord/discord-types/enums";
import { ChannelStore, CloudUploader, IconUtils, RelationshipStore, showToast, Toasts, UserStore } from "@webpack/common"; import { ChannelStore, CloudUploader, IconUtils, RelationshipStore, showToast, UserStore } from "@webpack/common";
import type { FormFieldOption, FormSubmitExtras, PaletteCommand } from "../api/types"; import type { FormFieldOption, FormSubmitExtras, PaletteCommand } from "../api/types";
import { fuzzyScore } from "../search/ranker"; import { fuzzyScore } from "../search/ranker";
@ -82,7 +82,7 @@ export const sendDmCommand: PaletteCommand = {
}); });
const user = UserStore.getUser(values.recipient); const user = UserStore.getUser(values.recipient);
showToast(`Message sent to ${user.globalName || user.username}.`, Toasts.Type.SUCCESS); showToast(`Message sent to ${user.globalName || user.username}.`, "success");
ctx.close(); ctx.close();
} }
} }

View file

@ -10,7 +10,7 @@ import { EquicordDevs } from "@utils/constants";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { User } from "@vencord/discord-types"; import { User } from "@vencord/discord-types";
import { Menu, SelectedGuildStore, Toasts, UserProfileStore } from "@webpack/common"; import { Menu, SelectedGuildStore, showToast,UserProfileStore } from "@webpack/common";
const logger = new Logger("CopyProfileColors"); const logger = new Logger("CopyProfileColors");
@ -38,11 +38,7 @@ function copyProfileColors(userId: string, guildId?: string) {
const colors = getProfileColors(userId, guildId); const colors = getProfileColors(userId, guildId);
if (!colors) { if (!colors) {
Toasts.show({ showToast("No profile colors found!", "failure");
type: Toasts.Type.FAILURE,
message: "No profile colors found!",
id: Toasts.genId()
});
return; return;
} }
@ -53,18 +49,10 @@ function copyProfileColors(userId: string, guildId?: string) {
try { try {
copyToClipboard(formattedColors); copyToClipboard(formattedColors);
Toasts.show({ showToast("Profile colors copied to clipboard!", "success");
type: Toasts.Type.SUCCESS,
message: "Profile colors copied to clipboard!",
id: Toasts.genId()
});
} catch (e) { } catch (e) {
logger.error("Failed to copy to clipboard:", e); logger.error("Failed to copy to clipboard:", e);
Toasts.show({ showToast("Error copying profile colors!", "failure");
type: Toasts.Type.FAILURE,
message: "Error copying profile colors!",
id: Toasts.genId()
});
} }
} }

View file

@ -8,8 +8,9 @@ import { copyToClipboard } from "@utils/clipboard";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { User } from "@vencord/discord-types"; import { User } from "@vencord/discord-types";
import { ToastPosition } from "@vencord/discord-types/enums";
import { findByCodeLazy } from "@webpack"; import { findByCodeLazy } from "@webpack";
import { Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
interface MakeContextMenuProps { interface MakeContextMenuProps {
user: User, user: User,
@ -44,24 +45,14 @@ export default definePlugin({
throw new Error("button_urls does not contain index"); throw new Error("button_urls does not contain index");
} }
copyToClipboard(button_urls[index]); copyToClipboard(button_urls[index]);
Toasts.show({ showToast("Copied URL", "success", {
id: Toasts.genId(), position: ToastPosition.TOP
message: "Copied URL", });
type: Toasts.Type.SUCCESS,
options: {
position: Toasts.Position.TOP
}
});
} catch (e) { } catch (e) {
console.error(e); console.error(e);
Toasts.show({ showToast("Error copying URL, check console for more info", "failure", {
id: Toasts.genId(), position: ToastPosition.TOP
message: "Error copying URL, check console for more info", });
type: Toasts.Type.FAILURE,
options: {
position: Toasts.Position.TOP
}
});
} }
}; };
} }

View file

@ -11,7 +11,7 @@ import { Logger } from "@utils/Logger";
import { pluralize } from "@utils/misc"; import { pluralize } from "@utils/misc";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { Message, MessageAttachment } from "@vencord/discord-types"; import { Message, MessageAttachment } from "@vencord/discord-types";
import { ChannelStore, showToast, Toasts } from "@webpack/common"; import { ChannelStore, showToast } from "@webpack/common";
const logger = new Logger("DownloadAllAttachments"); const logger = new Logger("DownloadAllAttachments");
@ -71,9 +71,9 @@ async function downloadAll(attachments: MessageAttachment[]) {
const succeeded = attachments.length - failed; const succeeded = attachments.length - failed;
if (failed === 0) if (failed === 0)
showToast(`Downloaded ${pluralize(succeeded, "attachment")}.`, Toasts.Type.SUCCESS); showToast(`Downloaded ${pluralize(succeeded, "attachment")}.`, "success");
else else
showToast(`Downloaded ${succeeded} of ${attachments.length} attachments. ${failed} failed.`, Toasts.Type.FAILURE); showToast(`Downloaded ${succeeded} of ${attachments.length} attachments. ${failed} failed.`, "failure");
} }
export default definePlugin({ export default definePlugin({

View file

@ -13,7 +13,7 @@ import { Logger } from "@utils/Logger";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import type { Channel } from "@vencord/discord-types"; import type { Channel } from "@vencord/discord-types";
import { ChannelType } from "@vencord/discord-types/enums"; import { ChannelType } from "@vencord/discord-types/enums";
import { ChannelStore, GuildStore, IconUtils, RelationshipStore, SelectedChannelStore, showToast, Toasts, UserStore } from "@webpack/common"; import { ChannelStore, GuildStore, IconUtils, RelationshipStore, SelectedChannelStore, showToast, UserStore } from "@webpack/common";
import { beginDrag as beginSessionDrag, clearDragState, getLastDropAt, hasActiveDrag, isGuildDragActive, isInputDragSource, isUserDragActive, markDrop, markInputDragSource, scheduleGuildCleanup, shouldIgnoreDrop, startDragWatchdog, stopDragState, touchDrag } from "./dragState"; import { beginDrag as beginSessionDrag, clearDragState, getLastDropAt, hasActiveDrag, isGuildDragActive, isInputDragSource, isUserDragActive, markDrop, markInputDragSource, scheduleGuildCleanup, shouldIgnoreDrop, startDragWatchdog, stopDragState, touchDrag } from "./dragState";
import { type GhostState, hideGhost as hideDragGhost, isGhostVisible, mountGhost as mountDragGhost, scheduleGhostPosition as scheduleDragGhostPosition, showGhost as showDragGhost, unmountGhost as unmountDragGhost } from "./ghost"; import { type GhostState, hideGhost as hideDragGhost, isGhostVisible, mountGhost as mountDragGhost, scheduleGhostPosition as scheduleDragGhostPosition, showGhost as showDragGhost, unmountGhost as unmountDragGhost } from "./ghost";
@ -293,7 +293,7 @@ export default definePlugin({
} catch (error) { } catch (error) {
clearDragState(); clearDragState();
logger.error("Failed handling drop", error); logger.error("Failed handling drop", error);
showToast("Dragify failed to handle drop.", Toasts.Type.FAILURE); showToast("Dragify failed to handle drop.", "failure");
} }
}, },

View file

@ -7,7 +7,7 @@
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import type { Channel } from "@vencord/discord-types"; import type { Channel } from "@vencord/discord-types";
import { ChannelType } from "@vencord/discord-types/enums"; import { ChannelType } from "@vencord/discord-types/enums";
import { ChannelStore, GuildChannelStore, GuildStore, PermissionsBits, PermissionStore, RestAPI, showToast, Toasts } from "@webpack/common"; import { ChannelStore, GuildChannelStore, GuildStore, PermissionsBits, PermissionStore, RestAPI, showToast } from "@webpack/common";
const logger = new Logger("Dragify"); const logger = new Logger("Dragify");
@ -135,7 +135,7 @@ function getInviteUrl(code: string) {
export async function createInvite(guildId: string, currentChannel: Channel, settings: InviteSettings): Promise<string | null> { export async function createInvite(guildId: string, currentChannel: Channel, settings: InviteSettings): Promise<string | null> {
const inviteChannel = resolveInviteChannel(guildId, currentChannel); const inviteChannel = resolveInviteChannel(guildId, currentChannel);
if (!inviteChannel) { if (!inviteChannel) {
showToast("No channel available for invites.", Toasts.Type.FAILURE); showToast("No channel available for invites.", "failure");
return null; return null;
} }
@ -147,7 +147,7 @@ export async function createInvite(guildId: string, currentChannel: Channel, set
reused.reason === "missing" reused.reason === "missing"
? "No reusable invite available." ? "No reusable invite available."
: "Unable to reuse invite.", : "Unable to reuse invite.",
Toasts.Type.FAILURE, "failure",
); );
return null; return null;
} }
@ -174,11 +174,11 @@ export async function createInvite(guildId: string, currentChannel: Channel, set
maxUses: maxUses === 0 ? null : maxUses, maxUses: maxUses === 0 ? null : maxUses,
uses: 0, uses: 0,
}); });
showToast("Invite created.", Toasts.Type.SUCCESS); showToast("Invite created.", "success");
return getInviteUrl(code); return getInviteUrl(code);
} catch (error) { } catch (error) {
logger.error("Failed to create invite", error); logger.error("Failed to create invite", error);
showToast("Unable to create invite.", Toasts.Type.FAILURE); showToast("Unable to create invite.", "failure");
return null; return null;
} }
} }

View file

@ -314,7 +314,7 @@ export default definePlugin({
match: /case \i\.\i\.WINDOWS:/, match: /case \i\.\i\.WINDOWS:/,
replace: 'case "WEB":' replace: 'case "WEB":'
}, },
predicate: () => Settings.winNativeTitleBar, predicate: () => Settings.nativeTitleBar,
}, },
{ {
find: '"refresh-title-bar-small"', find: '"refresh-title-bar-small"',
@ -328,7 +328,7 @@ export default definePlugin({
replace: "true" replace: "true"
} }
], ],
predicate: () => Settings.winNativeTitleBar, predicate: () => Settings.nativeTitleBar,
}, },
{ {
find: "DirectMessage: getSpringConfigs()", find: "DirectMessage: getSpringConfigs()",

View file

@ -9,7 +9,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { isEquicordGuild, isEquicordSupport } from "@utils/misc"; import { isEquicordGuild, isEquicordSupport } from "@utils/misc";
import { Message } from "@vencord/discord-types"; import { Message } from "@vencord/discord-types";
import { Button, showToast, Toasts } from "@webpack/common"; import { Button, showToast } from "@webpack/common";
import { JSX } from "react"; import { JSX } from "react";
import { toggleEnabled } from "./utils"; import { toggleEnabled } from "./utils";
@ -50,10 +50,10 @@ export const PluginButtons = ErrorBoundary.wrap(function PluginCards({ message }
onClick={async () => { onClick={async () => {
try { try {
const success = await toggleEnabled(matchedPlugin); const success = await toggleEnabled(matchedPlugin);
if (success) showToast(`${label}`, Toasts.Type.SUCCESS); if (success) showToast(`${label}`, "success");
} catch (e) { } catch (e) {
new Logger("EquicordHelper").error("Error while toggling:", e); new Logger("EquicordHelper").error("Error while toggling:", e);
showToast(`Failed to ${label.toLowerCase()}`, Toasts.Type.FAILURE); showToast(`Failed to ${label.toLowerCase()}`, "failure");
} }
}} }}
> >

View file

@ -7,17 +7,13 @@
import { showNotice } from "@api/Notices"; import { showNotice } from "@api/Notices";
import { plugins, startDependenciesRecursive, startPlugin, stopPlugin } from "@api/PluginManager"; import { plugins, startDependenciesRecursive, startPlugin, stopPlugin } from "@api/PluginManager";
import { Settings } from "@api/Settings"; import { Settings } from "@api/Settings";
import { Alerts, Toasts } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { Alerts, showToast } from "@webpack/common";
function showErrorToast(message: string) { function showErrorToast(message: string) {
Toasts.show({ showToast(message, "failure", {
message, position: ToastPosition.BOTTOM
type: Toasts.Type.FAILURE, });
id: Toasts.genId(),
options: {
position: Toasts.Position.BOTTOM
}
});
} }
function restartPrompt(): Promise<boolean> { function restartPrompt(): Promise<boolean> {

View file

@ -14,7 +14,7 @@ import { Devs } from "@utils/constants";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findComponentByCodeLazy } from "@webpack"; import { findComponentByCodeLazy } from "@webpack";
import { Constants, GuildStore, IconUtils, MediaEngineStore, Menu, RestAPI, SearchableSelect, SelectedChannelStore, TextInput, Toasts } from "@webpack/common"; import { Constants, GuildStore, IconUtils, MediaEngineStore, Menu, RestAPI, SearchableSelect, SelectedChannelStore, showToast,TextInput } from "@webpack/common";
const cl = classNameFactory("vc-exitsounds-"); const cl = classNameFactory("vc-exitsounds-");
@ -134,11 +134,7 @@ export default definePlugin({
} }
}); });
} catch { } catch {
Toasts.show({ showToast("Oops! Something went wrong.", "failure");
message: "Oops! Something went wrong.",
id: Toasts.genId(),
type: Toasts.Type.FAILURE
});
} }
} }
}); });

View file

@ -15,7 +15,8 @@ import { showItemInFolder } from "@utils/native";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { saveFile } from "@utils/web"; import { saveFile } from "@utils/web";
import { Message } from "@vencord/discord-types"; import { Message } from "@vencord/discord-types";
import { Menu, Toasts } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { Menu, showToast } from "@webpack/common";
import { ContactsList } from "./types"; import { ContactsList } from "./types";
@ -175,28 +176,18 @@ export default definePlugin({
copyContactToClipboard() { copyContactToClipboard() {
if (this.contactList) { if (this.contactList) {
copyToClipboard(JSON.stringify(this.contactList)); copyToClipboard(JSON.stringify(this.contactList));
Toasts.show({ showToast("Contacts copied to clipboard successfully.", "success", {
message: "Contacts copied to clipboard successfully.",
type: Toasts.Type.SUCCESS,
id: Toasts.genId(),
options: {
duration: 3000, duration: 3000,
position: Toasts.Position.BOTTOM position: ToastPosition.BOTTOM
} });
});
return; return;
} }
// reason why you need to click the all tab is because the data is extracted during // reason why you need to click the all tab is because the data is extracted during
// the request itself when you fetch all your friends. this is done to avoid sending a // the request itself when you fetch all your friends. this is done to avoid sending a
// manual request to discord, which may raise suspicion and might even get you terminated. // manual request to discord, which may raise suspicion and might even get you terminated.
Toasts.show({ showToast("Contact list is undefined. Click on the \"All\" tab before exporting.", "failure", {
message: "Contact list is undefined. Click on the \"All\" tab before exporting.",
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
options: {
duration: 3000, duration: 3000,
position: Toasts.Position.BOTTOM position: ToastPosition.BOTTOM
} });
});
} }
}); });

View file

@ -12,7 +12,7 @@ import { useForceUpdater } from "@utils/react";
import { PluginNative } from "@utils/types"; import { PluginNative } from "@utils/types";
import { Channel, MessageAttachment } from "@vencord/discord-types"; import { Channel, MessageAttachment } from "@vencord/discord-types";
import { findByCodeLazy, findByPropsLazy } from "@webpack"; import { findByCodeLazy, findByPropsLazy } from "@webpack";
import { Constants, createRoot, DraftType, FluxDispatcher, Humanize, MessageActions, PendingReplyStore, PermissionStore, ReactDOM, RestAPI, Toasts, UploadAttachmentStore, UploadHandler, UploadManager, useCallback, useEffect, useRef, UserSettingsActionCreators, UserSettingsProtoStore, useStateFromStores } from "@webpack/common"; import { Constants, createRoot, DraftType, FluxDispatcher, Humanize, MessageActions, PendingReplyStore, PermissionStore, ReactDOM, RestAPI, showToast,UploadAttachmentStore, UploadHandler, UploadManager, useCallback, useEffect, useRef, UserSettingsActionCreators, UserSettingsProtoStore, useStateFromStores } from "@webpack/common";
import { deflateSync, inflateSync } from "fflate"; import { deflateSync, inflateSync } from "fflate";
import { Key, ReactNode } from "react"; import { Key, ReactNode } from "react";
import { JsonValue } from "type-fest"; import { JsonValue } from "type-fest";
@ -189,13 +189,13 @@ async function fetchAttachment(attachment: MessageAttachment): Promise<File> {
export async function sendAttachment(attachment: MessageAttachment, channel: Channel) { export async function sendAttachment(attachment: MessageAttachment, channel: Channel) {
const { filename, title, description } = attachment; const { filename, title, description } = attachment;
const file = await fetchAttachment(attachment).catch(() => const file = await fetchAttachment(attachment).catch(() =>
Toasts.show({ message: `Couldn't fetch ${filename}`, id: Toasts.genId(), type: Toasts.Type.FAILURE }) showToast(`Couldn't fetch ${filename}`, "failure")
); );
if (!file) return; if (!file) return;
// Using promptToUpload instead of addFiles directly since it has file size checks with error popups // Using promptToUpload instead of addFiles directly since it has file size checks with error popups
await UploadHandler.promptToUpload([file], channel, DraftType.ChannelMessage).catch(() => await UploadHandler.promptToUpload([file], channel, DraftType.ChannelMessage).catch(() =>
Toasts.show({ message: `Couldn't upload ${filename}`, id: Toasts.genId(), type: Toasts.Type.FAILURE }) showToast(`Couldn't upload ${filename}`, "failure")
); );
const uploads = [...UploadAttachmentStore.getUploads(channel.id, DraftType.ChannelMessage)]; const uploads = [...UploadAttachmentStore.getUploads(channel.id, DraftType.ChannelMessage)];

View file

@ -14,7 +14,7 @@ import { classNameFactory } from "@utils/css";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { CloudUpload } from "@vencord/discord-types"; import { CloudUpload } from "@vencord/discord-types";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
import { DraftType, FluxDispatcher, Menu, PermissionsBits, PermissionStore, React, showToast, Toasts, UploadAttachmentStore, useEffect, UserStore, useState } from "@webpack/common"; import { DraftType, FluxDispatcher, Menu, PermissionsBits, PermissionStore, React, showToast, UploadAttachmentStore, useEffect, UserStore, useState } from "@webpack/common";
import { settings } from "./settings"; import { settings } from "./settings";
import { serviceLabels, ServiceType } from "./types"; import { serviceLabels, ServiceType } from "./types";
@ -233,12 +233,12 @@ async function handleUploadFileFromDraft(upload: CloudUpload) {
if (!file) return; if (!file) return;
if (!isFileTypeAllowed(file)) { if (!isFileTypeAllowed(file)) {
showToast("File type not allowed by current filter", Toasts.Type.FAILURE); showToast("File type not allowed by current filter", "failure");
return; return;
} }
if (!isConfigured()) { if (!isConfigured()) {
showToast("Please configure FileUpload settings first", Toasts.Type.FAILURE); showToast("Please configure FileUpload settings first", "failure");
return; return;
} }

View file

@ -11,7 +11,7 @@ import { Switch } from "@components/Switch";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import { useForceUpdater } from "@utils/react"; import { useForceUpdater } from "@utils/react";
import { OptionType } from "@utils/types"; import { OptionType } from "@utils/types";
import { React, Select, showToast, TextArea, TextInput, Toasts } from "@webpack/common"; import { React, Select, showToast, TextArea, TextInput } from "@webpack/common";
import { CORS_PROXY } from "./constants"; import { CORS_PROXY } from "./constants";
import { fallbackServiceOrder, serviceLabels, ServiceType } from "./types"; import { fallbackServiceOrder, serviceLabels, ServiceType } from "./types";
@ -520,10 +520,10 @@ export function SettingsComponent() {
const validateShareXConfig = () => { const validateShareXConfig = () => {
try { try {
parseShareXConfig(settings.store.sharexConfig || ""); parseShareXConfig(settings.store.sharexConfig || "");
showToast("ShareX config is valid", Toasts.Type.SUCCESS); showToast("ShareX config is valid", "success");
} catch (error) { } catch (error) {
const message = error instanceof Error ? error.message : "Invalid ShareX config"; const message = error instanceof Error ? error.message : "Invalid ShareX config";
showToast(message, Toasts.Type.FAILURE); showToast(message, "failure");
} }
}; };
@ -542,10 +542,10 @@ export function SettingsComponent() {
const parsed = parseShareXConfig(content); const parsed = parseShareXConfig(content);
settings.store.sharexConfig = JSON.stringify(parsed, null, 2); settings.store.sharexConfig = JSON.stringify(parsed, null, 2);
update(); update();
showToast("Imported ShareX config", Toasts.Type.SUCCESS); showToast("Imported ShareX config", "success");
} catch (error) { } catch (error) {
const message = error instanceof Error ? error.message : "Failed to import ShareX config"; const message = error instanceof Error ? error.message : "Failed to import ShareX config";
showToast(message, Toasts.Type.FAILURE); showToast(message, "failure");
} }
}; };
reader.readAsText(file); reader.readAsText(file);

View file

@ -12,7 +12,7 @@ import { insertTextIntoChatInputBox } from "@utils/discord";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { PluginNative } from "@utils/types"; import { PluginNative } from "@utils/types";
import { chooseFile } from "@utils/web"; import { chooseFile } from "@utils/web";
import { showToast, Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
import { convertApngToGif } from "./apngToGif"; import { convertApngToGif } from "./apngToGif";
import { getExtensionFromBytes, getExtensionFromMime, getMimeFromExtension, getUrlExtension } from "./getMediaUrl"; import { getExtensionFromBytes, getExtensionFromMime, getMimeFromExtension, getUrlExtension } from "./getMediaUrl";
@ -1304,19 +1304,19 @@ function getFilenameExtension(filename: string): string | undefined {
async function notifyUploadSuccess(finalUrl: string, forceSend?: boolean): Promise<void> { async function notifyUploadSuccess(finalUrl: string, forceSend?: boolean): Promise<void> {
if (settings.store.autoCopy) { if (settings.store.autoCopy) {
if (!finalUrl || !finalUrl.trim()) { if (!finalUrl || !finalUrl.trim()) {
showToast("Upload successful, but no URL was available to copy", Toasts.Type.MESSAGE); showToast("Upload successful, but no URL was available to copy", "message");
return; return;
} }
try { try {
await copyToClipboard(finalUrl); await copyToClipboard(finalUrl);
showToast("Upload successful, URL copied to clipboard", Toasts.Type.SUCCESS); showToast("Upload successful, URL copied to clipboard", "success");
} catch (error) { } catch (error) {
logger.warn("Upload succeeded but clipboard copy failed", error); logger.warn("Upload succeeded but clipboard copy failed", error);
showToast("Upload successful, but failed to copy URL", Toasts.Type.MESSAGE); showToast("Upload successful, but failed to copy URL", "message");
} }
} else { } else {
showToast("Upload successful", Toasts.Type.SUCCESS); showToast("Upload successful", "success");
} }
const autoSend = forceSend || Boolean((settings.store as { autoSend?: boolean; }).autoSend); const autoSend = forceSend || Boolean((settings.store as { autoSend?: boolean; }).autoSend);
@ -1366,7 +1366,7 @@ async function uploadWithFallbacks(fileBlob: Blob, filename: string, primary: Se
try { try {
const uploadedUrl = await uploadToService(service, fileBlob, filename); const uploadedUrl = await uploadToService(service, fileBlob, filename);
if (attempted.length) { if (attempted.length) {
showToast(`Upload succeeded with ${serviceLabels[service]} after fallback`, Toasts.Type.SUCCESS); showToast(`Upload succeeded with ${serviceLabels[service]} after fallback`, "success");
} }
setUploadState({ setUploadState({
@ -1433,7 +1433,7 @@ async function normalizeUploadBlob(blob: Blob, sourceUrl?: string): Promise<{ bl
blob = gifBlob; blob = gifBlob;
ext = "gif"; ext = "gif";
} else { } else {
showToast("APNG to GIF conversion failed, uploading as APNG", Toasts.Type.FAILURE); showToast("APNG to GIF conversion failed, uploading as APNG", "failure");
} }
} }
@ -1463,12 +1463,12 @@ async function uploadPreparedBlob(blob: Blob, sourceUrl?: string, forceSend?: bo
export async function uploadFile(url: string): Promise<void> { export async function uploadFile(url: string): Promise<void> {
if (isUploading) { if (isUploading) {
showToast("Upload already in progress", Toasts.Type.MESSAGE); showToast("Upload already in progress", "message");
return; return;
} }
if (!isConfigured()) { if (!isConfigured()) {
showToast("Please configure FileUpload settings first", Toasts.Type.FAILURE); showToast("Please configure FileUpload settings first", "failure");
return; return;
} }
@ -1527,10 +1527,10 @@ export async function uploadFile(url: string): Promise<void> {
} catch (error) { } catch (error) {
const message = error instanceof Error ? error.message : "Unknown error"; const message = error instanceof Error ? error.message : "Unknown error";
if (isUploadCancelledError(error)) { if (isUploadCancelledError(error)) {
showToast("Upload cancelled", Toasts.Type.MESSAGE); showToast("Upload cancelled", "message");
setUploadState({ phase: "cancelled", status: "Upload cancelled.", canCancel: false, percent: 0 }); setUploadState({ phase: "cancelled", status: "Upload cancelled.", canCancel: false, percent: 0 });
} else { } else {
showToast(`Upload failed: ${message}`, Toasts.Type.FAILURE); showToast(`Upload failed: ${message}`, "failure");
logger.error("Upload error", error); logger.error("Upload error", error);
setUploadState({ phase: "failed", status: `Upload failed: ${message}`, canCancel: false, percent: 0 }); setUploadState({ phase: "failed", status: `Upload failed: ${message}`, canCancel: false, percent: 0 });
} }
@ -1547,7 +1547,7 @@ export async function uploadPickedFile(): Promise<void> {
if (!file) return; if (!file) return;
if (!isFileTypeAllowed(file)) { if (!isFileTypeAllowed(file)) {
showToast("File type not allowed by current filter", Toasts.Type.FAILURE); showToast("File type not allowed by current filter", "failure");
return; return;
} }
@ -1556,12 +1556,12 @@ export async function uploadPickedFile(): Promise<void> {
export async function uploadProvidedFiles(files: readonly File[], forceSend?: boolean): Promise<void> { export async function uploadProvidedFiles(files: readonly File[], forceSend?: boolean): Promise<void> {
if (isUploading) { if (isUploading) {
showToast("Upload already in progress", Toasts.Type.MESSAGE); showToast("Upload already in progress", "message");
return; return;
} }
if (!isConfigured()) { if (!isConfigured()) {
showToast("Please configure FileUpload settings first", Toasts.Type.FAILURE); showToast("Please configure FileUpload settings first", "failure");
return; return;
} }
@ -1596,10 +1596,10 @@ export async function uploadProvidedFiles(files: readonly File[], forceSend?: bo
} catch (error) { } catch (error) {
const message = error instanceof Error ? error.message : "Unknown error"; const message = error instanceof Error ? error.message : "Unknown error";
if (isUploadCancelledError(error)) { if (isUploadCancelledError(error)) {
showToast("Upload cancelled", Toasts.Type.MESSAGE); showToast("Upload cancelled", "message");
setUploadState({ phase: "cancelled", status: "Upload cancelled.", canCancel: false, percent: 0 }); setUploadState({ phase: "cancelled", status: "Upload cancelled.", canCancel: false, percent: 0 });
} else { } else {
showToast(`Upload failed: ${message}`, Toasts.Type.FAILURE); showToast(`Upload failed: ${message}`, "failure");
logger.error("Manual upload error", error); logger.error("Manual upload error", error);
setUploadState({ phase: "failed", status: `Upload failed: ${message}`, canCancel: false, percent: 0 }); setUploadState({ phase: "failed", status: `Upload failed: ${message}`, canCancel: false, percent: 0 });
} }

View file

@ -22,7 +22,7 @@ import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { Message } from "@vencord/discord-types"; import { Message } from "@vencord/discord-types";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
import { ChannelStore, createRoot, MessageStore, Toasts } from "@webpack/common"; import { ChannelStore, createRoot, MessageStore, showToast } from "@webpack/common";
import { Root } from "react-dom/client"; import { Root } from "react-dom/client";
import ReplyNavigator from "./ReplyNavigator"; import ReplyNavigator from "./ReplyNavigator";
@ -115,18 +115,10 @@ export default definePlugin({
jumpType: "INSTANT" jumpType: "INSTANT"
}); });
if (replies.length > 1) { if (replies.length > 1) {
Toasts.show({ showToast("Use the bottom panel to navigate between replies.", "message");
id: Toasts.genId(),
message: "Use the bottom panel to navigate between replies.",
type: Toasts.Type.MESSAGE
});
const container = document.querySelector("[class*=channelBottomBarArea_]"); const container = document.querySelector("[class*=channelBottomBarArea_]");
if (!container) { if (!container) {
Toasts.show({ showToast("Couldn't find the container element.", "failure");
id: Toasts.genId(),
message: "Couldn't find the container element.",
type: Toasts.Type.FAILURE
});
return; return;
} }
@ -139,11 +131,7 @@ export default definePlugin({
root!.render(<ReplyNavigator replies={replies} />); root!.render(<ReplyNavigator replies={replies} />);
} }
} else { } else {
Toasts.show({ showToast("Couldn't find a reply.", "failure");
id: Toasts.genId(),
message: "Couldn't find a reply.",
type: Toasts.Type.FAILURE
});
} }
} }
}; };

View file

@ -7,7 +7,7 @@
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
import { FolderIcon, InfoIcon, LinkIcon, PencilIcon, PlusIcon, RemixIcon, TrashIcon } from "@components/Icons"; import { FolderIcon, InfoIcon, LinkIcon, PencilIcon, PlusIcon, RemixIcon, TrashIcon } from "@components/Icons";
import { copyToClipboard } from "@utils/clipboard"; import { copyToClipboard } from "@utils/clipboard";
import { Alerts, Button, FluxDispatcher, Menu, showToast, Toasts } from "@webpack/common"; import { Alerts, Button, FluxDispatcher, Menu, showToast } from "@webpack/common";
import { settings } from "../settings"; import { settings } from "../settings";
import { Gif } from "../types"; import { Gif } from "../types";
@ -71,7 +71,7 @@ export const addCollectionContextMenuPatch: NavContextMenuPatchCallback = (child
leadingAccessory={{ type: "icon", icon: LinkIcon }} leadingAccessory={{ type: "icon", icon: LinkIcon }}
action={() => { action={() => {
copyToClipboard(gif.url); copyToClipboard(gif.url);
showToast("Image link copied to clipboard", Toasts.Type.SUCCESS); showToast("Image link copied to clipboard", "success");
}} }}
/> />
); );
@ -131,7 +131,7 @@ export function RemoveItemContextMenuItems({ type, nameOrId }: { type: "collecti
const gif = getGifById(nameOrId); const gif = getGifById(nameOrId);
if (!gif) return; if (!gif) return;
copyToClipboard(gif.url); copyToClipboard(gif.url);
showToast("URL copied to clipboard", Toasts.Type.SUCCESS); showToast("URL copied to clipboard", "success");
}} }}
/> />
<Menu.MenuItem <Menu.MenuItem
@ -198,7 +198,7 @@ export function GifPickerContextMenu({ gif }: { gif: Gif; }) {
leadingAccessory={{ type: "icon", icon: LinkIcon }} leadingAccessory={{ type: "icon", icon: LinkIcon }}
action={() => { action={() => {
copyToClipboard(gif.url); copyToClipboard(gif.url);
showToast("Image link copied to clipboard", Toasts.Type.SUCCESS); showToast("Image link copied to clipboard", "success");
}} }}
/> />
)} )}
@ -220,7 +220,7 @@ export function getGifPickerContextMenuItems(src: string, url: string, height: n
leadingAccessory={{ type: "icon", icon: LinkIcon }} leadingAccessory={{ type: "icon", icon: LinkIcon }}
action={() => { action={() => {
copyToClipboard(url); copyToClipboard(url);
showToast("Image link copied to clipboard", Toasts.Type.SUCCESS); showToast("Image link copied to clipboard", "success");
}} }}
/> />
)} )}

View file

@ -5,7 +5,8 @@
*/ */
import { DataStore } from "@api/index"; import { DataStore } from "@api/index";
import { Toasts } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { showToast } from "@webpack/common";
import { settings } from "../settings"; import { settings } from "../settings";
import { Collection, Gif } from "../types"; import { Collection, Gif } from "../types";
@ -32,7 +33,7 @@ export async function createCollection(name: string, gifs: Gif[]): Promise<void>
const fullName = `${settings.store.collectionPrefix}${name}`; const fullName = `${settings.store.collectionPrefix}${name}`;
if (collections.some(c => c.name === fullName)) { if (collections.some(c => c.name === fullName)) {
Toasts.show({ message: "That collection already exists", type: Toasts.Type.FAILURE, id: Toasts.genId(), options: { duration: 3000, position: Toasts.Position.BOTTOM } }); showToast("That collection already exists", "failure", { duration: 3000, position: ToastPosition.BOTTOM });
return; return;
} }
@ -56,7 +57,7 @@ export async function addToCollection(name: string, gif: Gif): Promise<void> {
if (!collection) return void logger.warn("Collection not found"); if (!collection) return void logger.warn("Collection not found");
if (settings.store.preventDuplicates && collection.gifs.some(g => g.url === gif.url)) { if (settings.store.preventDuplicates && collection.gifs.some(g => g.url === gif.url)) {
Toasts.show({ message: "This GIF is already in the collection", type: Toasts.Type.FAILURE, id: Toasts.genId(), options: { duration: 3000, position: Toasts.Position.BOTTOM } }); showToast("This GIF is already in the collection", "failure", { duration: 3000, position: ToastPosition.BOTTOM });
return; return;
} }

View file

@ -6,7 +6,7 @@
import { DataStore } from "@api/index"; import { DataStore } from "@api/index";
import { chooseFile, saveFile } from "@utils/web"; import { chooseFile, saveFile } from "@utils/web";
import { Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
import { DATA_COLLECTION_NAME, getCollections, refreshCacheCollection } from "./collectionManager"; import { DATA_COLLECTION_NAME, getCollections, refreshCacheCollection } from "./collectionManager";
import { logger } from "./misc"; import { logger } from "./misc";
@ -70,14 +70,6 @@ export async function uploadGifCollections(showToast = true): Promise<void> {
} }
} }
const toastSuccess = () => Toasts.show({ const toastSuccess = () => showToast("Collections imported successfully.", "success");
type: Toasts.Type.SUCCESS,
message: "Collections imported successfully.",
id: Toasts.genId(),
});
const toastFailure = (err: unknown) => Toasts.show({ const toastFailure = (err: unknown) => showToast(`Failed to import collections: ${String(err)}`, "failure");
type: Toasts.Type.FAILURE,
message: `Failed to import collections: ${String(err)}`,
id: Toasts.genId(),
});

View file

@ -12,7 +12,7 @@ import { BadgeContextMenu } from "@plugins/_api/badges";
import { Devs, EquicordDevs } from "@utils/constants"; import { Devs, EquicordDevs } from "@utils/constants";
import { openInviteModal } from "@utils/discord"; import { openInviteModal } from "@utils/discord";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { ContextMenuApi, React, Toasts } from "@webpack/common"; import { ContextMenuApi, React, showToast } from "@webpack/common";
import { settings } from "./settings"; import { settings } from "./settings";
import { cl, GlobalBadges, INVITE_LINK, loadBadges } from "./utils"; import { cl, GlobalBadges, INVITE_LINK, loadBadges } from "./utils";
@ -47,11 +47,7 @@ export default definePlugin({
toolboxActions: { toolboxActions: {
async "Refetch Global Badges"() { async "Refetch Global Badges"() {
await loadBadges(); await loadBadges();
Toasts.show({ showToast("Successfully refetched global badges!", "success");
id: Toasts.genId(),
message: "Successfully refetched global badges!",
type: Toasts.Type.SUCCESS
});
} }
}, },
get GlobalBadges() { get GlobalBadges() {

View file

@ -11,7 +11,7 @@ import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { VoiceState } from "@vencord/discord-types"; import { VoiceState } from "@vencord/discord-types";
import { findByCodeLazy } from "@webpack"; import { findByCodeLazy } from "@webpack";
import { ApplicationStreamingSettingsStore, ChannelStore, MediaEngineStore, PermissionsBits, PermissionStore, SelectedChannelStore, showToast, Toasts, UserStore, VoiceActions, WindowStore } from "@webpack/common"; import { ApplicationStreamingSettingsStore, ChannelStore, MediaEngineStore, PermissionsBits, PermissionStore, SelectedChannelStore, showToast, UserStore, VoiceActions, WindowStore } from "@webpack/common";
import { getCurrentMedia, settings } from "./utils"; import { getCurrentMedia, settings } from "./utils";
@ -141,7 +141,7 @@ export default definePlugin({
toolboxActions: { toolboxActions: {
"Instant Screenshare"() { "Instant Screenshare"() {
settings.store.toolboxManagement = !settings.store.toolboxManagement; settings.store.toolboxManagement = !settings.store.toolboxManagement;
showToast(`Instant Screenshare ${settings.store.toolboxManagement ? "Enabled" : "Disabled"}`, Toasts.Type.SUCCESS); showToast(`Instant Screenshare ${settings.store.toolboxManagement ? "Enabled" : "Disabled"}`, "success");
} }
} }
}); });

View file

@ -8,7 +8,7 @@ import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { Channel, Message, User } from "@vencord/discord-types"; import { Channel, Message, User } from "@vencord/discord-types";
import { ChannelStore, Constants, Menu, NavigationRouter, RestAPI, SelectedChannelStore, SelectedGuildStore, Toasts } from "@webpack/common"; import { ChannelStore, Constants, Menu, NavigationRouter, RestAPI, SelectedChannelStore, SelectedGuildStore, showToast } from "@webpack/common";
function jumpToFirstMessage(channelId: string, guildId?: string | null) { function jumpToFirstMessage(channelId: string, guildId?: string | null) {
NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${channelId}/0`); NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${channelId}/0`);
@ -38,21 +38,13 @@ async function jumpToUserMessage(channelId: string, guildId: string, userId: str
const messageId = res.body?.messages?.[0]?.[0]?.id; const messageId = res.body?.messages?.[0]?.[0]?.id;
if (!messageId) { if (!messageId) {
Toasts.show({ showToast("No messages found from this user in this channel.", "failure");
type: Toasts.Type.FAILURE,
message: "No messages found from this user in this channel.",
id: Toasts.genId()
});
return; return;
} }
NavigationRouter.transitionTo(`/channels/${guildId}/${channelId}/${messageId}`); NavigationRouter.transitionTo(`/channels/${guildId}/${channelId}/${messageId}`);
} catch (e) { } catch (e) {
Toasts.show({ showToast("Failed to search for messages.", "failure");
type: Toasts.Type.FAILURE,
message: "Failed to search for messages.",
id: Toasts.genId()
});
} }
} }

View file

@ -10,7 +10,8 @@ import { gitHashShort } from "@shared/vencordUserAgent";
import { copyToClipboard } from "@utils/clipboard"; import { copyToClipboard } from "@utils/clipboard";
import { relaunch, showItemInFolder } from "@utils/native"; import { relaunch, showItemInFolder } from "@utils/native";
import { checkForUpdates, getRepo } from "@utils/updater"; import { checkForUpdates, getRepo } from "@utils/updater";
import { GuildStore, NavigationRouter, SettingsRouter, Toasts } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { GuildStore, NavigationRouter, SettingsRouter, showToast } from "@webpack/common";
import gitRemote from "~git-remote"; import gitRemote from "~git-remote";
import Plugins from "~plugins"; import Plugins from "~plugins";
@ -46,14 +47,9 @@ export const actions: ButtonAction[] = [
new URL(newUrl); // Throws if invalid new URL(newUrl); // Throws if invalid
VencordNative.native.openExternal(newUrl); VencordNative.native.openExternal(newUrl);
} catch { } catch {
Toasts.show({ showToast("Invalid URL", "failure", {
message: "Invalid URL", position: ToastPosition.BOTTOM
type: Toasts.Type.FAILURE, });
id: Toasts.genId(),
options: {
position: Toasts.Position.BOTTOM
}
});
} }
}, registrar: "Equicord" }, registrar: "Equicord"
}, },
@ -92,24 +88,14 @@ export const actions: ButtonAction[] = [
const text = await res.text(); const text = await res.text();
copyToClipboard(text); copyToClipboard(text);
Toasts.show({ showToast("Copied response to clipboard!", "success", {
message: "Copied response to clipboard!", position: ToastPosition.BOTTOM
type: Toasts.Type.SUCCESS, });
id: Toasts.genId(),
options: {
position: Toasts.Position.BOTTOM
}
});
} catch (e) { } catch (e) {
Toasts.show({ showToast("Issue fetching URL", "failure", {
message: "Issue fetching URL", position: ToastPosition.BOTTOM
type: Toasts.Type.FAILURE, });
id: Toasts.genId(),
options: {
position: Toasts.Position.BOTTOM
}
});
} }
}, registrar: "Equicord" }, registrar: "Equicord"
}, },
@ -118,14 +104,9 @@ export const actions: ButtonAction[] = [
id: "copyGitInfo", label: "Copy Git Info", callback: async () => { id: "copyGitInfo", label: "Copy Git Info", callback: async () => {
copyToClipboard(`gitHash: ${gitHashShort}\ngitRemote: ${gitRemote}`); copyToClipboard(`gitHash: ${gitHashShort}\ngitRemote: ${gitRemote}`);
Toasts.show({ showToast("Copied git info to clipboard!", "success", {
message: "Copied git info to clipboard!", position: ToastPosition.BOTTOM
type: Toasts.Type.SUCCESS, });
id: Toasts.genId(),
options: {
position: Toasts.Position.BOTTOM
}
});
}, registrar: "Equicord" }, registrar: "Equicord"
}, },
@ -144,14 +125,9 @@ export const actions: ButtonAction[] = [
} }
}), 10_000); }), 10_000);
} else { } else {
Toasts.show({ showToast("No updates available", "message", {
message: "No updates available", position: ToastPosition.BOTTOM
type: Toasts.Type.MESSAGE, });
id: Toasts.genId(),
options: {
position: Toasts.Position.BOTTOM
}
});
} }
}, registrar: "Equicord" }, registrar: "Equicord"
}, },
@ -181,14 +157,9 @@ function togglePlugin(plugin: ButtonAction, enabled: boolean) {
Settings.plugins[plugin.id].enabled = enabled; Settings.plugins[plugin.id].enabled = enabled;
Toasts.show({ showToast(`Successfully ${enabled ? "enabled" : "disabled"} ${plugin.id}`, "success", {
message: `Successfully ${enabled ? "enabled" : "disabled"} ${plugin.id}`, position: ToastPosition.BOTTOM
type: Toasts.Type.SUCCESS, });
id: Toasts.genId(),
options: {
position: Toasts.Position.BOTTOM
}
});
} }
export function registerAction(action: ButtonAction) { export function registerAction(action: ButtonAction) {

View file

@ -8,7 +8,7 @@ import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { EquicordDevs } from "@utils/constants"; import { EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { Channel } from "@vencord/discord-types"; import { Channel } from "@vencord/discord-types";
import { Menu, NavigationRouter, RestAPI, Toasts, UserStore } from "@webpack/common"; import { Menu, NavigationRouter, RestAPI, showToast,UserStore } from "@webpack/common";
async function findLastMessageFromUser(guildId: string, channelId: string, userId: string) { async function findLastMessageFromUser(guildId: string, channelId: string, userId: string) {
try { try {
@ -33,29 +33,17 @@ async function findLastMessageFromUser(guildId: string, channelId: string, userI
if (messageId) return messageId; if (messageId) return messageId;
} catch (error) { } catch (error) {
console.error("Error finding last message:", error); console.error("Error finding last message:", error);
Toasts.show({ showToast("Failed to find messages. Check console for details.", "failure");
type: Toasts.Type.FAILURE,
message: "Failed to find messages. Check console for details.",
id: Toasts.genId()
});
return null; return null;
} }
Toasts.show({ showToast("Couldn't find any recent messages from this user.", "failure");
type: Toasts.Type.FAILURE,
message: "Couldn't find any recent messages from this user.",
id: Toasts.genId()
});
return null; return null;
} }
async function jumpToLastActive(channel: Channel, targetUserId?: string) { async function jumpToLastActive(channel: Channel, targetUserId?: string) {
if (!channel) { if (!channel) {
Toasts.show({ showToast("Channel information not available.", "failure");
type: Toasts.Type.FAILURE,
message: "Channel information not available.",
id: Toasts.genId()
});
return; return;
} }
@ -69,11 +57,7 @@ async function jumpToLastActive(channel: Channel, targetUserId?: string) {
} }
} catch (error) { } catch (error) {
console.error("Error in jumpToLastActive:", error); console.error("Error in jumpToLastActive:", error);
Toasts.show({ showToast("Failed to jump to message. Check console for details.", "failure");
type: Toasts.Type.FAILURE,
message: "Failed to jump to message. Check console for details.",
id: Toasts.genId()
});
} }
} }

View file

@ -5,7 +5,7 @@
*/ */
import { Button } from "@components/Button"; import { Button } from "@components/Button";
import { Alerts, Toasts, useState } from "@webpack/common"; import { Alerts, showToast,useState } from "@webpack/common";
import { clearMessagesIDB } from "../db"; import { clearMessagesIDB } from "../db";
import { Flogger } from "../index"; import { Flogger } from "../index";
@ -33,18 +33,10 @@ export function ClearLogsButton({ label = "Clear Logs", onCleared }: ClearLogsBu
try { try {
await clearMessagesIDB(); await clearMessagesIDB();
onCleared?.(); onCleared?.();
Toasts.show({ showToast("Cleared Logs", "success");
id: Toasts.genId(),
message: "Cleared Logs",
type: Toasts.Type.SUCCESS
});
} catch (err) { } catch (err) {
Flogger.error("Failed to clear logs", err); Flogger.error("Failed to clear logs", err);
Toasts.show({ showToast("Failed to clear logs", "failure");
id: Toasts.genId(),
message: "Failed to clear logs",
type: Toasts.Type.FAILURE
});
} finally { } finally {
setLoading(false); setLoading(false);
} }

View file

@ -23,7 +23,7 @@ import { DEFAULT_IMAGE_CACHE_DIR } from "@equicordplugins/messageLoggerEnhanced/
import { copyWithToast } from "@utils/discord"; import { copyWithToast } from "@utils/discord";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import { findCssClassesLazy } from "@webpack"; import { findCssClassesLazy } from "@webpack";
import { Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
const inputClasses = findCssClassesLazy("input", "inputWrapper", "editable") as Record<string, string>; const inputClasses = findCssClassesLazy("input", "inputWrapper", "editable") as Record<string, string>;
@ -65,17 +65,9 @@ export function SelectFolderInput({ settingsKey, successMessage }: Props) {
const res = await Native.chooseDir(settingsKey); const res = await Native.chooseDir(settingsKey);
settings.store[settingsKey] = res; settings.store[settingsKey] = res;
return Toasts.show({ return showToast(successMessage, "success");
id: Toasts.genId(),
type: Toasts.Type.SUCCESS,
message: successMessage
});
} catch (err) { } catch (err) {
Toasts.show({ showToast("Failed to update directory", "failure");
id: Toasts.genId(),
type: Toasts.Type.FAILURE,
message: "Failed to update directory"
});
} }
} }

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
import { ChannelStore, Toasts } from "@webpack/common"; import { ChannelStore, showToast } from "@webpack/common";
import { DBSchema, IDBPDatabase, openDB } from "idb"; import { DBSchema, IDBPDatabase, openDB } from "idb";
import { LoggedMessageJSON } from "./types"; import { LoggedMessageJSON } from "./types";
@ -256,7 +256,7 @@ export async function deleteMessagesBulkIDB(message_ids: string[]) {
message_ids.forEach(id => cachedMessages.delete(id)); message_ids.forEach(id => cachedMessages.delete(id));
} }
export async function clearMessagesIDB(showToast = true) { export async function clearMessagesIDB(toast = true) {
cachedMessages.clear(); cachedMessages.clear();
const deleted = await new Promise<boolean>(resolve => { const deleted = await new Promise<boolean>(resolve => {
@ -271,13 +271,9 @@ export async function clearMessagesIDB(showToast = true) {
cachedMessages.clear(); cachedMessages.clear();
if (!showToast) return; if (!toast) return;
Toasts.show({ showToast("Cleared message log database and cache.", "message");
type: Toasts.Type.MESSAGE,
message: "Cleared message log database and cache.",
id: Toasts.genId()
});
} }
// faster than db.clear on large dbs // faster than db.clear on large dbs

View file

@ -41,8 +41,8 @@ let didClearLogsOnStartup = false;
const cacheThing = findByPropsLazy("commit", "getOrCreate"); const cacheThing = findByPropsLazy("commit", "getOrCreate");
export async function clearLogs(showToast = true) { export async function clearLogs(toast = true) {
await idb.clearMessagesIDB(showToast); await idb.clearMessagesIDB(toast);
cacheSentMessages.clear(); cacheSentMessages.clear();
} }

View file

@ -6,7 +6,7 @@
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
import { updateMessage } from "@api/MessageUpdater"; import { updateMessage } from "@api/MessageUpdater";
import { FluxDispatcher, Menu, MessageActions, React, SortedGuildStore, Toasts, UserStore } from "@webpack/common"; import { FluxDispatcher, Menu, MessageActions, React, showToast,SortedGuildStore, UserStore } from "@webpack/common";
import { openLogModal } from "../components/LogsModal"; import { openLogModal } from "../components/LogsModal";
import { deleteMessageIDB } from "../db"; import { deleteMessageIDB } from "../db";
@ -80,11 +80,7 @@ const removeMessageAction = async (props: any) => {
} }
} catch (e) { } catch (e) {
console.error("Failed to remove message", e); console.error("Failed to remove message", e);
Toasts.show({ showToast("Failed to remove message. Check console for details.", "failure");
type: Toasts.Type.FAILURE,
message: "Failed to remove message. Check console for details.",
id: Toasts.genId()
});
} }
}; };

View file

@ -18,7 +18,7 @@
import JSONParser from "@streamparser/json/jsonparser.js"; import JSONParser from "@streamparser/json/jsonparser.js";
import { chooseFile as chooseFileWeb } from "@utils/web"; import { chooseFile as chooseFileWeb } from "@utils/web";
import { Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
import { showSaveFilePicker } from "native-file-system-adapter"; import { showSaveFilePicker } from "native-file-system-adapter";
import { clearLogs,Native } from ".."; import { clearLogs,Native } from "..";
@ -60,27 +60,15 @@ export async function importLogs() {
} }
if (count === 0) { if (count === 0) {
Toasts.show({ showToast("No messages found in log file", "failure");
id: Toasts.genId(),
message: "No messages found in log file",
type: Toasts.Type.FAILURE
});
return; return;
} }
Toasts.show({ showToast(`Successfully imported ${count} logs`, "success");
id: Toasts.genId(),
message: `Successfully imported ${count} logs`,
type: Toasts.Type.SUCCESS
});
} catch (e) { } catch (e) {
console.error(e); console.error(e);
Toasts.show({ showToast("Error importing logs. Check the console for more information", "failure");
id: Toasts.genId(),
message: "Error importing logs. Check the console for more information",
type: Toasts.Type.FAILURE
});
} }
} }
@ -106,11 +94,7 @@ export async function exportLogs() {
await Native.writeNativeLogChunk(streamId, "\n ]\n}"); await Native.writeNativeLogChunk(streamId, "\n ]\n}");
await Native.finishNativeLogExport(streamId); await Native.finishNativeLogExport(streamId);
Toasts.show({ showToast("Successfully exported logs", "success");
id: Toasts.genId(),
message: "Successfully exported logs",
type: Toasts.Type.SUCCESS
});
return; return;
} }
@ -143,20 +127,12 @@ export async function exportLogs() {
await writer.write(encoder.encode("\n ]\n}")); await writer.write(encoder.encode("\n ]\n}"));
await writer.close(); await writer.close();
Toasts.show({ showToast(`Successfully exported ${count} logs`, "success");
id: Toasts.genId(),
message: `Successfully exported ${count} logs`,
type: Toasts.Type.SUCCESS
});
} }
} catch (e) { } catch (e) {
console.error(e); console.error(e);
Toasts.show({ showToast("Error exporting logs. Check the console for more information", "failure");
id: Toasts.genId(),
message: "Error exporting logs. Check the console for more information",
type: Toasts.Type.FAILURE
});
} }
} }

View file

@ -17,7 +17,7 @@ import { isV1, migrate } from "@equicordplugins/moreStickers/migrate-v1";
import { deleteStickerPack, getStickerPack, getStickerPackMetas, saveStickerPack } from "@equicordplugins/moreStickers/stickers"; import { deleteStickerPack, getStickerPack, getStickerPackMetas, saveStickerPack } from "@equicordplugins/moreStickers/stickers";
import { SettingsTabsKey, Sticker, StickerPack, StickerPackMeta } from "@equicordplugins/moreStickers/types"; import { SettingsTabsKey, Sticker, StickerPack, StickerPackMeta } from "@equicordplugins/moreStickers/types";
import { cl, clPicker, Mutex } from "@equicordplugins/moreStickers/utils"; import { cl, clPicker, Mutex } from "@equicordplugins/moreStickers/utils";
import { Button, React, TabBar, TextArea, Toasts } from "@webpack/common"; import { Button, React, showToast,TabBar, TextArea } from "@webpack/common";
import { JSX } from "react"; import { JSX } from "react";
const mutex = new Mutex(); const mutex = new Mutex();
@ -58,24 +58,14 @@ const StickerPackMetadata = ({ meta, hoveredStickerPackId, setHoveredStickerPack
onClick={async () => { onClick={async () => {
try { try {
await deleteStickerPack(meta.id); await deleteStickerPack(meta.id);
Toasts.show({ showToast("Sticker Pack deleted", "success", {
message: "Sticker Pack deleted",
type: Toasts.Type.SUCCESS,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
await refreshStickerPackMetas(); await refreshStickerPackMetas();
} catch (e: any) { } catch (e: any) {
Toasts.show({ showToast(e.message, "failure", {
message: e.message,
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
} }
}} }}
> >
@ -210,23 +200,13 @@ export const Packs = () => {
refreshStickerPackMetas(); refreshStickerPackMetas();
if (errorMessage) { if (errorMessage) {
Toasts.show({ showToast(errorMessage, "failure", {
message: errorMessage,
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
} else { } else {
Toasts.show({ showToast("Sticker Pack added", "success", {
message: "Sticker Pack added",
type: Toasts.Type.SUCCESS,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
} }
}} }}
@ -288,23 +268,13 @@ export const Packs = () => {
refreshStickerPackMetas(); refreshStickerPackMetas();
if (errorMessage) { if (errorMessage) {
Toasts.show({ showToast(errorMessage, "failure", {
message: errorMessage,
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
} else { } else {
Toasts.show({ showToast("Sticker Pack added", "success", {
message: "Sticker Pack added",
type: Toasts.Type.SUCCESS,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
} }
}} }}
>Insert from HTML</Button> >Insert from HTML</Button>
@ -340,24 +310,14 @@ export const Packs = () => {
await saveStickerPack(stickerPack); await saveStickerPack(stickerPack);
} }
Toasts.show({ showToast("Sticker Packs added", "success", {
message: "Sticker Packs added",
type: Toasts.Type.SUCCESS,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
} catch (e: any) { } catch (e: any) {
console.error(e); console.error(e);
Toasts.show({ showToast(e.message, "failure", {
message: e.message,
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
} }
}; };
input.click(); input.click();
@ -395,14 +355,9 @@ export const Packs = () => {
a.click(); a.click();
setTimeout(() => URL.revokeObjectURL(objectUrl), 1000); setTimeout(() => URL.revokeObjectURL(objectUrl), 1000);
Toasts.show({ showToast("Sticker Packs exported", "success", {
message: "Sticker Packs exported",
type: Toasts.Type.SUCCESS,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
}} }}
>Export Sticker Packs</Button> >Export Sticker Packs</Button>
<Button <Button

View file

@ -5,7 +5,7 @@
*/ */
import { DataStore } from "@api/index"; import { DataStore } from "@api/index";
import { Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
import { getRecentStickers, setRecentStickers } from "./components/misc"; import { getRecentStickers, setRecentStickers } from "./components/misc";
import { deleteStickerPack, getStickerPack, getStickerPackMetas, saveStickerPack } from "./stickers"; import { deleteStickerPack, getStickerPack, getStickerPackMetas, saveStickerPack } from "./stickers";
@ -74,27 +74,17 @@ export async function isV1() {
export async function migrate() { export async function migrate() {
const newPackMetas = await getStickerPackMetas(PACKS_KEY); const newPackMetas = await getStickerPackMetas(PACKS_KEY);
if (newPackMetas.length > 0) { if (newPackMetas.length > 0) {
Toasts.show({ showToast("New sticker packs already exist, migration not needed", "failure", {
message: "New sticker packs already exist, migration not needed",
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
return; return;
} }
let oldPackMetas = await getStickerPackMetas(PACKS_KEY_OLD); let oldPackMetas = await getStickerPackMetas(PACKS_KEY_OLD);
if (oldPackMetas.length === 0) { if (oldPackMetas.length === 0) {
Toasts.show({ showToast("Old sticker packs not found, nothing to migrate", "failure", {
message: "Old sticker packs not found, nothing to migrate",
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
return; return;
} }
@ -112,14 +102,9 @@ export async function migrate() {
} }
} catch (e) { } catch (e) {
console.error(e); console.error(e);
Toasts.show({ showToast(`Migration failed: ${oldStickerPackMeta.title} (${oldStickerPackMeta.id})`, "failure", {
message: `Migration failed: ${oldStickerPackMeta.title} (${oldStickerPackMeta.id})`,
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
} }
} }
@ -136,12 +121,7 @@ export async function migrate() {
} }
console.log("Migration complete"); console.log("Migration complete");
Toasts.show({ showToast("Sticker Pack Migration Complete", "success", {
message: "Sticker Pack Migration Complete",
type: Toasts.Type.SUCCESS,
id: Toasts.genId(),
options: {
duration: 1000 duration: 1000
} });
});
} }

View file

@ -8,7 +8,7 @@ import { getMimeFromExtension } from "@equicordplugins/fileUpload/utils/getMedia
import { FFmpeg } from "@ffmpeg/ffmpeg"; import { FFmpeg } from "@ffmpeg/ffmpeg";
import { insertTextIntoChatInputBox, MessageOptions } from "@utils/discord"; import { insertTextIntoChatInputBox, MessageOptions } from "@utils/discord";
import { CloudUploadPlatform } from "@vencord/discord-types/enums"; import { CloudUploadPlatform } from "@vencord/discord-types/enums";
import { ChannelStore, CloudUploader, Constants, DraftStore, FluxDispatcher, MessageActions, PendingReplyStore, RestAPI, showToast, SnowflakeUtils, Toasts, UploadHandler } from "@webpack/common"; import { ChannelStore, CloudUploader, Constants, DraftStore, FluxDispatcher, MessageActions, PendingReplyStore, RestAPI, showToast, SnowflakeUtils, UploadHandler } from "@webpack/common";
import { settings } from "."; import { settings } from ".";
import { FFmpegState, Sticker } from "./types"; import { FFmpegState, Sticker } from "./types";
@ -169,7 +169,7 @@ export async function sendSticker({ channelId, sticker, ctrlKey, shiftKey, ffmpe
}); });
}); });
upload.on("error", () => showToast("Failed to upload sticker", Toasts.Type.FAILURE)); upload.on("error", () => showToast("Failed to upload sticker", "failure"));
upload.upload(); upload.upload();
} }

View file

@ -11,7 +11,7 @@ import { HeadingSecondary } from "@components/Heading";
import { Paragraph } from "@components/Paragraph"; import { Paragraph } from "@components/Paragraph";
import { SettingsSection } from "@components/settings/tabs/plugins/components/Common"; import { SettingsSection } from "@components/settings/tabs/plugins/components/Common";
import { makeRange, OptionType } from "@utils/types"; import { makeRange, OptionType } from "@utils/types";
import { MaskedLink, Select, showToast, TextInput, Toasts } from "@webpack/common"; import { MaskedLink, Select, showToast, TextInput } from "@webpack/common";
import hoverOnlyStyle from "./hoverOnly.css?managed"; import hoverOnlyStyle from "./hoverOnly.css?managed";
import { clearLyricsCache, removeTranslations } from "./spotify/lyrics/api"; import { clearLyricsCache, removeTranslations } from "./spotify/lyrics/api";
@ -66,7 +66,7 @@ function LyricsProviderSettings() {
onChange={v => { onChange={v => {
settings.store.spotifyLyricsApiUrl = v; settings.store.spotifyLyricsApiUrl = v;
void clearLyricsCache(); void clearLyricsCache();
showToast("Lyrics cache purged", Toasts.Type.SUCCESS); showToast("Lyrics cache purged", "success");
}} }}
placeholder="https://spotify-lyrics-api-pi.vercel.app" placeholder="https://spotify-lyrics-api-pi.vercel.app"
maxLength={null} maxLength={null}
@ -113,7 +113,7 @@ export const settings = definePluginSettings({
default: "https://spotify-lyrics-api-pi.vercel.app", default: "https://spotify-lyrics-api-pi.vercel.app",
onChange: async () => { onChange: async () => {
await clearLyricsCache(); await clearLyricsCache();
showToast("Lyrics cache purged", Toasts.Type.SUCCESS); showToast("Lyrics cache purged", "success");
} }
}, },
lyricsProviderSettings: { lyricsProviderSettings: {
@ -126,7 +126,7 @@ export const settings = definePluginSettings({
options: languages, options: languages,
onChange: async () => { onChange: async () => {
await removeTranslations(); await removeTranslations();
showToast("Translations cleared", Toasts.Type.SUCCESS); showToast("Translations cleared", "success");
} }
}, },
lyricsConversion: { lyricsConversion: {
@ -162,7 +162,7 @@ export const settings = definePluginSettings({
color={ButtonCompat.Colors.RED} color={ButtonCompat.Colors.RED}
onClick={() => { onClick={() => {
clearLyricsCache(); clearLyricsCache();
showToast("Lyrics cache purged", Toasts.Type.SUCCESS); showToast("Lyrics cache purged", "success");
}} }}
> >
Purge Cache Purge Cache

View file

@ -7,7 +7,7 @@
import { definePluginSettings } from "@api/Settings"; import { definePluginSettings } from "@api/Settings";
import { EquicordDevs } from "@utils/constants"; import { EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { ChannelStore, FluxDispatcher, GuildMemberStore, StreamerModeStore, Toasts, UserStore, VoiceStateStore } from "@webpack/common"; import { ChannelStore, FluxDispatcher, GuildMemberStore, showToast,StreamerModeStore, UserStore, VoiceStateStore } from "@webpack/common";
interface ChannelState { interface ChannelState {
userId: string; userId: string;
@ -211,11 +211,7 @@ const createWebsocket = () => {
setTimeout(() => { setTimeout(() => {
if (ws?.readyState !== WebSocket.OPEN) { if (ws?.readyState !== WebSocket.OPEN) {
Toasts.show({ showToast("Orbolay websocket could not connect. Is it running?", "failure");
message: "Orbolay websocket could not connect. Is it running?",
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
});
ws = null; ws = null;
return; return;
} }
@ -235,11 +231,7 @@ const createWebsocket = () => {
ws = null; ws = null;
}; };
ws.onopen = async () => { ws.onopen = async () => {
Toasts.show({ showToast("Connected to Orbolay server", "success");
message: "Connected to Orbolay server",
type: Toasts.Type.SUCCESS,
id: Toasts.genId(),
});
const userId = await waitForPopulate(() => UserStore.getCurrentUser().id); const userId = await waitForPopulate(() => UserStore.getCurrentUser().id);
if (!userId) return; if (!userId) return;

View file

@ -6,7 +6,7 @@
import { isNonNullish } from "@utils/guards"; import { isNonNullish } from "@utils/guards";
import { ProfilePreset } from "@vencord/discord-types"; import { ProfilePreset } from "@vencord/discord-types";
import { showToast, Toasts, UserProfileSettingsStore } from "@webpack/common"; import { showToast, UserProfileSettingsStore } from "@webpack/common";
import { getCurrentProfile } from "./profile"; import { getCurrentProfile } from "./profile";
import { addPreset, movePresetInArray, presets, PresetSection, type ProfilePresetEx, removePreset, replaceAllPresets, savePresetsData, updatePreset } from "./storage"; import { addPreset, movePresetInArray, presets, PresetSection, type ProfilePresetEx, removePreset, replaceAllPresets, savePresetsData, updatePreset } from "./storage";
@ -133,7 +133,7 @@ export async function importPresets(
await savePresetsData(section); await savePresetsData(section);
forceUpdate(); forceUpdate();
} catch { } catch {
showToast("Failed to import presets. The file might be invalid.", Toasts.Type.FAILURE); showToast("Failed to import presets. The file might be invalid.", "failure");
} }
}; };
input.click(); input.click();

View file

@ -8,7 +8,7 @@ import type { PluginNative } from "@utils/types";
import type { Quest, User } from "@vencord/discord-types"; import type { Quest, User } from "@vencord/discord-types";
import { QuestTargetedContent, QuestTaskType } from "@vencord/discord-types/enums"; import { QuestTargetedContent, QuestTaskType } from "@vencord/discord-types/enums";
import { findByCodeLazy, findLazy } from "@webpack"; import { findByCodeLazy, findLazy } from "@webpack";
import { AuthorizedAppsStore, FluxDispatcher, QuestStore, RestAPI, showToast, Toasts, UserStore } from "@webpack/common"; import { AuthorizedAppsStore, FluxDispatcher, QuestStore, RestAPI, showToast, UserStore } from "@webpack/common";
import { getCurrentUserId, getQuestifySettings } from "../settings/access"; import { getCurrentUserId, getQuestifySettings } from "../settings/access";
import { autoCompleteQuestTaskTypes, isDesktopCompatible } from "../settings/def"; import { autoCompleteQuestTaskTypes, isDesktopCompatible } from "../settings/def";
@ -251,7 +251,7 @@ function showBrokenAutoCompleteToast(): void {
} }
didShowBrokenAutoCompleteToast = true; didShowBrokenAutoCompleteToast = true;
showToast("AutoComplete is broken. A fix will be implemented shortly.", Toasts.Type.FAILURE); showToast("AutoComplete is broken. A fix will be implemented shortly.", "failure");
} }
export function hasEnabledAutoCompleteQuestTypes(): boolean { export function hasEnabledAutoCompleteQuestTypes(): boolean {
@ -613,7 +613,7 @@ function blockQuestEnrollmentForRetryAfter(retryAfter: number | null): void {
function showQuestEnrollmentFailureToast(quest: Quest, result: Exclude<QuestEnrollmentResult, { type: "success"; }>): void { function showQuestEnrollmentFailureToast(quest: Quest, result: Exclude<QuestEnrollmentResult, { type: "success"; }>): void {
const rateLimitSuffix = result.type === "rate_limited" ? " due to rate limits" : ""; const rateLimitSuffix = result.type === "rate_limited" ? " due to rate limits" : "";
showToast(`Enrollment in ${normalizeQuestName(quest)} Quest failed${rateLimitSuffix}.`, Toasts.Type.FAILURE); showToast(`Enrollment in ${normalizeQuestName(quest)} Quest failed${rateLimitSuffix}.`, "failure");
} }
export async function enrollInQuestManually(quest: Quest): Promise<QuestManualEnrollResult> { export async function enrollInQuestManually(quest: Quest): Promise<QuestManualEnrollResult> {

View file

@ -10,7 +10,7 @@ import { Paragraph } from "@components/Paragraph";
import { debounce } from "@shared/debounce"; import { debounce } from "@shared/debounce";
import { Devs, IS_MAC } from "@utils/constants"; import { Devs, IS_MAC } from "@utils/constants";
import definePlugin, { OptionType, StartAt } from "@utils/types"; import definePlugin, { OptionType, StartAt } from "@utils/types";
import { showToast, Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
const { VencordNative } = window; const { VencordNative } = window;
@ -51,7 +51,7 @@ const refreshThemeList = async (silent = false) => {
const diff = themeList.length - oldCount; const diff = themeList.length - oldCount;
const action = diff > 0 ? "Added" : "Removed"; const action = diff > 0 ? "Added" : "Removed";
const count = Math.abs(diff); const count = Math.abs(diff);
showToast(`${action} ${count} theme${count > 1 ? "s" : ""}`, Toasts.Type.SUCCESS); showToast(`${action} ${count} theme${count > 1 ? "s" : ""}`, "success");
} }
}; };
@ -186,7 +186,7 @@ function toggleCurrentTheme(enable: boolean) {
async function reloadThemes() { async function reloadThemes() {
await refreshThemeList(true); await refreshThemeList(true);
showToast(`Reloaded ${themeList.length} themes`, Toasts.Type.SUCCESS); showToast(`Reloaded ${themeList.length} themes`, "success");
} }
async function watchForLocalThemeChanges() { async function watchForLocalThemeChanges() {
@ -204,7 +204,7 @@ async function watchForLocalThemeChanges() {
if (settings.store.showNotifications) { if (settings.store.showNotifications) {
const action = diff > 0 ? "Added" : "Removed"; const action = diff > 0 ? "Added" : "Removed";
const count = Math.abs(diff); const count = Math.abs(diff);
showToast(`${action} ${count} local theme${count > 1 ? "s" : ""}`, Toasts.Type.SUCCESS); showToast(`${action} ${count} local theme${count > 1 ? "s" : ""}`, "success");
} }
} }

View file

@ -15,9 +15,10 @@ import { debounce } from "@shared/debounce";
import { Devs, EquicordDevs, IS_MAC } from "@utils/constants"; import { Devs, EquicordDevs, IS_MAC } from "@utils/constants";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import definePlugin, { makeRange, OptionType } from "@utils/types"; import definePlugin, { makeRange, OptionType } from "@utils/types";
import type { Channel, VoiceState } from "@vencord/discord-types"; import type { Channel, ToastType, VoiceState } from "@vencord/discord-types";
import { ToastPosition } from "@vencord/discord-types/enums";
import { findByCodeLazy } from "@webpack"; import { findByCodeLazy } from "@webpack";
import { ChannelActions, ChannelRouter, ChannelStore, ContextMenuApi, FluxDispatcher, GuildStore, MediaEngineStore, Menu, PermissionsBits, PermissionStore, React, RelationshipStore, SelectedChannelStore, Toasts, useEffect, UserStore, useState, VoiceActions, VoiceStateStore } from "@webpack/common"; import { ChannelActions, ChannelRouter, ChannelStore, ContextMenuApi, FluxDispatcher, GuildStore, MediaEngineStore, Menu, PermissionsBits, PermissionStore, React, RelationshipStore, SelectedChannelStore, showToast as originalShowToast, useEffect, UserStore, useState, VoiceActions, VoiceStateStore } from "@webpack/common";
const startStream = findByCodeLazy('type:"STREAM_START"'); const startStream = findByCodeLazy('type:"STREAM_START"');
const getDesktopSources = findByCodeLazy("desktop sources"); const getDesktopSources = findByCodeLazy("desktop sources");
@ -372,13 +373,8 @@ const settings = definePluginSettings({
}, },
}); });
function showToast(message: string, type: (typeof Toasts.Type)[keyof typeof Toasts.Type]) { function showToast(message: string, type: ToastType) {
Toasts.show({ originalShowToast(message, type, { position: ToastPosition.BOTTOM });
message,
type,
id: Toasts.genId(),
options: { position: Toasts.Position.BOTTOM },
});
} }
function RandomVoiceIcon({ className }: { className?: string; }) { function RandomVoiceIcon({ className }: { className?: string; }) {
@ -594,13 +590,13 @@ function runAfterVoiceJoin(channelId: string, callbacks: PostJoinAction[]) {
async function joinRandomVoice() { async function joinRandomVoice() {
const channelId = pickRandomChannel(); const channelId = pickRandomChannel();
if (!channelId) { if (!channelId) {
showToast("Failed to find a voice channel.", Toasts.Type.MESSAGE); showToast("Failed to find a voice channel.", "message");
return; return;
} }
const channel = ChannelStore.getChannel(channelId); const channel = ChannelStore.getChannel(channelId);
if (!channel) { if (!channel) {
showToast("Voice channel is unavailable.", Toasts.Type.FAILURE); showToast("Voice channel is unavailable.", "failure");
return; return;
} }

View file

@ -11,7 +11,8 @@ import { definePluginSettings } from "@api/Settings";
import { EquicordDevs, IS_MAC } from "@utils/constants"; import { EquicordDevs, IS_MAC } from "@utils/constants";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import definePlugin, { makeRange, OptionType } from "@utils/types"; import definePlugin, { makeRange, OptionType } from "@utils/types";
import { Button, ChannelRouter, ChannelStore, closeModal, IconUtils, openModal,React, RelationshipStore, SelectedChannelStore, Toasts, UserStore } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { Button, ChannelRouter, ChannelStore, closeModal, IconUtils, openModal, React, RelationshipStore, SelectedChannelStore, showToast,UserStore } from "@webpack/common";
const STORAGE_KEY = "RDMSwitch_history"; const STORAGE_KEY = "RDMSwitch_history";
@ -76,7 +77,7 @@ const settings = definePluginSettings({
cycleSnapshot = []; cycleSnapshot = [];
cycleIndex = -1; cycleIndex = -1;
await DataStore.set(STORAGE_KEY, []); await DataStore.set(STORAGE_KEY, []);
Toasts.show({ id: Toasts.genId(), type: Toasts.Type.SUCCESS, message: "Cleared RDMS history" }); showToast("Cleared RDMS history", "success");
}}> }}>
"Clear RDMS History "Clear RDMS History
</Button> </Button>
@ -84,7 +85,6 @@ const settings = definePluginSettings({
} }
}); });
let activeToastId: string | null = null;
let overlayModalKey: string | null = null; let overlayModalKey: string | null = null;
let overlayRerender: (() => void) | null = null; let overlayRerender: (() => void) | null = null;
@ -164,7 +164,6 @@ function endCycleSession() {
cycleSnapshot = []; cycleSnapshot = [];
cycleIndex = -1; cycleIndex = -1;
activeToastId = null;
const visEnd = (settings as any).store?.visualStyle; const visEnd = (settings as any).store?.visualStyle;
if (visEnd === "overlay") unmountOverlay(); if (visEnd === "overlay") unmountOverlay();
@ -319,13 +318,7 @@ function showCycleToast() {
const id = cycleSnapshot[cycleIndex]; const id = cycleSnapshot[cycleIndex];
if (!id) return; if (!id) return;
const { name } = getDisplayForChannel(id); const { name } = getDisplayForChannel(id);
if (!activeToastId) activeToastId = Toasts.genId(); showToast(`Switching to: ${name}`, "message", { position: ToastPosition.BOTTOM, duration: settings.store.toastDurationMs });
Toasts.show({
id: activeToastId,
message: `Switching to: ${name}`,
type: Toasts.Type.MESSAGE,
options: { position: Toasts.Position.BOTTOM, duration: settings.store.toastDurationMs }
});
} }
export default definePlugin({ export default definePlugin({
@ -369,7 +362,6 @@ export default definePlugin({
suppressRdmsWhileCycling = false; suppressRdmsWhileCycling = false;
cycleSnapshot = []; cycleSnapshot = [];
cycleIndex = -1; cycleIndex = -1;
activeToastId = null;
const visEnd = (settings as any).store?.visualStyle; const visEnd = (settings as any).store?.visualStyle;
if (visEnd === "overlay") unmountOverlay(); if (visEnd === "overlay") unmountOverlay();

View file

@ -10,7 +10,7 @@ import { Heading } from "@components/Heading";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import { RenderModalProps } from "@vencord/discord-types"; import { RenderModalProps } from "@vencord/discord-types";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
import { ChannelStore, closeModal, DraftType, Modal, openModal, showToast, TextInput, Toasts, UploadManager, useState } from "@webpack/common"; import { ChannelStore, closeModal, DraftType, Modal, openModal, showToast, TextInput, UploadManager, useState } from "@webpack/common";
import { ScheduledAttachment } from "../types"; import { ScheduledAttachment } from "../types";
import { addScheduledMessage, getChannelDisplayInfo } from "../utils"; import { addScheduledMessage, getChannelDisplayInfo } from "../utils";
@ -61,7 +61,7 @@ function ScheduleTimeModalInner({ channelId, content, attachments, rootProps, cl
if (result.success) { if (result.success) {
ComponentDispatch.dispatchToLastSubscribed("CLEAR_TEXT"); ComponentDispatch.dispatchToLastSubscribed("CLEAR_TEXT");
UploadManager.clearAll(channelId, DraftType.ChannelMessage); UploadManager.clearAll(channelId, DraftType.ChannelMessage);
showToast("Message scheduled!", Toasts.Type.SUCCESS); showToast("Message scheduled!", "success");
close(); close();
} else { } else {
setError(result.error ?? "Failed to schedule message"); setError(result.error ?? "Failed to schedule message");

View file

@ -8,7 +8,7 @@ import { Button } from "@components/Button";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import { RenderModalProps } from "@vencord/discord-types"; import { RenderModalProps } from "@vencord/discord-types";
import { ChannelStore, closeModal, Modal, openModal, showToast, Toasts, useState } from "@webpack/common"; import { ChannelStore, closeModal, Modal, openModal, showToast, useState } from "@webpack/common";
import { clearAllScheduledMessages, getChannelDisplayInfo, getScheduledMessages, removeScheduledMessage } from "../utils"; import { clearAllScheduledMessages, getChannelDisplayInfo, getScheduledMessages, removeScheduledMessage } from "../utils";
import { CalendarIcon, TimerIcon } from "./Icons"; import { CalendarIcon, TimerIcon } from "./Icons";
@ -26,13 +26,13 @@ function ViewScheduledModalInner({ rootProps, close }: ViewScheduledModalProps)
const handleDelete = async (id: string) => { const handleDelete = async (id: string) => {
await removeScheduledMessage(id); await removeScheduledMessage(id);
setMessages(getScheduledMessages()); setMessages(getScheduledMessages());
showToast("Scheduled message removed", Toasts.Type.SUCCESS); showToast("Scheduled message removed", "success");
}; };
const handleClearAll = async () => { const handleClearAll = async () => {
await clearAllScheduledMessages(); await clearAllScheduledMessages();
setMessages([]); setMessages([]);
showToast("All scheduled messages cleared", Toasts.Type.SUCCESS); showToast("All scheduled messages cleared", "success");
}; };
const actions = [ const actions = [

View file

@ -8,7 +8,7 @@ import * as DataStore from "@api/DataStore";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { Message } from "@vencord/discord-types"; import { Message } from "@vencord/discord-types";
import { CloudUploadPlatform } from "@vencord/discord-types/enums"; import { CloudUploadPlatform } from "@vencord/discord-types/enums";
import { ChannelStore, CloudUploader, Constants, FluxDispatcher, GuildStore, IconUtils, MessageActions, MessageStore, RestAPI, showToast, SnowflakeUtils, Toasts, UserStore } from "@webpack/common"; import { ChannelStore, CloudUploader, Constants, FluxDispatcher, GuildStore, IconUtils, MessageActions, MessageStore, RestAPI, showToast, SnowflakeUtils, UserStore } from "@webpack/common";
import { settings } from "."; import { settings } from ".";
import { PhantomMessageData, ScheduledAttachment, ScheduledMessage, ScheduledReaction } from "./types"; import { PhantomMessageData, ScheduledAttachment, ScheduledMessage, ScheduledReaction } from "./types";
@ -374,11 +374,11 @@ async function sendScheduledMessage(msg: ScheduledMessage): Promise<boolean> {
} }
if (settings.store.showNotifications) { if (settings.store.showNotifications) {
showToast(`Scheduled message sent to ${getChannelDisplayInfo(msg.channelId).name}`, Toasts.Type.SUCCESS); showToast(`Scheduled message sent to ${getChannelDisplayInfo(msg.channelId).name}`, "success");
} }
return true; return true;
} catch { } catch {
if (settings.store.showNotifications) showToast("Failed to send scheduled message", Toasts.Type.FAILURE); if (settings.store.showNotifications) showToast("Failed to send scheduled message", "failure");
return false; return false;
} }
} }

View file

@ -12,8 +12,9 @@ import { Logger } from "@utils/Logger";
import { parseUrl } from "@utils/misc"; import { parseUrl } from "@utils/misc";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { Message } from "@vencord/discord-types"; import { Message } from "@vencord/discord-types";
import { ToastPosition } from "@vencord/discord-types/enums";
import { findByCodeLazy } from "@webpack"; import { findByCodeLazy } from "@webpack";
import { ChannelStore, Constants, Menu, MessageStore, React, RestAPI, showToast, Toasts } from "@webpack/common"; import { ChannelStore, Constants, Menu, MessageStore, React, RestAPI, showToast } from "@webpack/common";
const logger = new Logger("ShowMessageEmbeds"); const logger = new Logger("ShowMessageEmbeds");
@ -189,7 +190,7 @@ function removeEmbed(url: string, message: Message) {
} }
function showFailureToast(message: string) { function showFailureToast(message: string) {
showToast(message, Toasts.Type.FAILURE, { position: Toasts.Position.BOTTOM }); showToast(message, "failure", { position: ToastPosition.BOTTOM });
} }
export default definePlugin({ export default definePlugin({

View file

@ -5,7 +5,7 @@
*/ */
import type { UserData } from "@song-spotlight/api/structs"; import type { UserData } from "@song-spotlight/api/structs";
import { showToast, Toasts, UserStore } from "@webpack/common"; import { showToast, UserStore } from "@webpack/common";
import { useAuthorizationStore } from "./stores/AuthorizationStore"; import { useAuthorizationStore } from "./stores/AuthorizationStore";
import { useSongStore } from "./stores/SongStore"; import { useSongStore } from "./stores/SongStore";
@ -65,20 +65,20 @@ export async function authFetch(url: string | URL, options?: RequestInit, retrie
if (retry) return await authFetch(url, options, true); if (retry) return await authFetch(url, options, true);
else { else {
useAuthorizationStore.getState().deleteTokens(); useAuthorizationStore.getState().deleteTokens();
showToast("You have been signed out from Song Spotlight. Please sign in again.", Toasts.Type.FAILURE); showToast("You have been signed out from Song Spotlight. Please sign in again.", "failure");
} }
} else { } else {
showToast( showToast(
!text.includes("<body>") && res.status >= 400 && res.status <= 599 !text.includes("<body>") && res.status >= 400 && res.status <= 599
? `Song Spotlight: ${text}` ? `Song Spotlight: ${text}`
: `Song Spotlight fetch error at ${url.pathname}`, : `Song Spotlight fetch error at ${url.pathname}`,
Toasts.Type.FAILURE, "failure",
); );
} }
throw new Error(text); throw new Error(text);
} catch (error) { } catch (error) {
showToast(`Song Spotlight: ${error}`, Toasts.Type.FAILURE); showToast(`Song Spotlight: ${error}`, "failure");
throw error; throw error;
} }

View file

@ -5,7 +5,7 @@
*/ */
import { ApplicationIntegrationType } from "@vencord/discord-types/enums"; import { ApplicationIntegrationType } from "@vencord/discord-types/enums";
import { OAuth2AuthorizeModal, openModal,showToast, Toasts } from "@webpack/common"; import { OAuth2AuthorizeModal, openModal, showToast } from "@webpack/common";
import { apiConstants, authFetch, getData } from "./api"; import { apiConstants, authFetch, getData } from "./api";
import { useAuthorizationStore } from "./stores/AuthorizationStore"; import { useAuthorizationStore } from "./stores/AuthorizationStore";
@ -41,10 +41,10 @@ export function presentOAuth2Modal() {
useAuthorizationStore.getState().setToken(access, refresh); useAuthorizationStore.getState().setToken(access, refresh);
getData(); getData();
showToast("Successfully authorized!", Toasts.Type.SUCCESS); showToast("Successfully authorized!", "success");
} catch (error) { } catch (error) {
logger.error("Got an error during OAuth2", error); logger.error("Got an error during OAuth2", error);
if (typeof error === "string") showToast(error, Toasts.Type.FAILURE); if (typeof error === "string") showToast(error, "failure");
} }
}} }}
/> />

View file

@ -7,7 +7,7 @@
import { logger } from "@equicordplugins/songSpotlight.desktop/lib/utils"; import { logger } from "@equicordplugins/songSpotlight.desktop/lib/utils";
import settings from "@equicordplugins/songSpotlight.desktop/settings"; import settings from "@equicordplugins/songSpotlight.desktop/settings";
import { RenderInfoEntry, RenderInfoEntryAudio } from "@song-spotlight/api/handlers"; import { RenderInfoEntry, RenderInfoEntryAudio } from "@song-spotlight/api/handlers";
import { showToast, Toasts, useCallback, useEffect, useMemo, useRef } from "@webpack/common"; import { showToast, useCallback, useEffect, useMemo, useRef } from "@webpack/common";
import { RefObject } from "react"; import { RefObject } from "react";
interface AudioItemProps { interface AudioItemProps {
@ -103,7 +103,7 @@ export default function AudioPlayer({ audioRef, list, playing, setPlaying, setLo
node.currentTime = audio.previewStart ? audio.previewStart / 1000 : 0; node.currentTime = audio.previewStart ? audio.previewStart / 1000 : 0;
node.volume = BASE_VOLUME * (settings.store.previewVolume / 100); node.volume = BASE_VOLUME * (settings.store.previewVolume / 100);
node.play().catch(error => { node.play().catch(error => {
showToast("Failed to play song preview!", Toasts.Type.FAILURE); showToast("Failed to play song preview!", "failure");
logger.error("Failed to play audio", error); logger.error("Failed to play audio", error);
setPlaying(undefined); setPlaying(undefined);
}); });

View file

@ -21,7 +21,7 @@ import { sid } from "@song-spotlight/api/util";
import { readClipboard } from "@utils/clipboard"; import { readClipboard } from "@utils/clipboard";
import { copyWithToast } from "@utils/discord"; import { copyWithToast } from "@utils/discord";
import { RenderModalProps } from "@vencord/discord-types"; import { RenderModalProps } from "@vencord/discord-types";
import { Alerts, Modal,openModal, Parser, showToast, Toasts, useCallback, useEffect, useMemo, useRef, useState } from "@webpack/common"; import { Alerts, Modal, openModal, Parser, showToast, useCallback, useEffect, useMemo, useRef, useState } from "@webpack/common";
interface ImportButtonProps { interface ImportButtonProps {
overwrite: boolean; overwrite: boolean;
@ -39,24 +39,24 @@ function ImportButton({ overwrite, pending, setPending, onImport }: ImportButton
json = JSON.parse(await readClipboard()); json = JSON.parse(await readClipboard());
} catch { } catch {
setPending(false); setPending(false);
return showToast("No JSON in clipboard!", Toasts.Type.FAILURE); return showToast("No JSON in clipboard!", "failure");
} }
const { error, data } = UserDataSchema.max(apiConstants.songLimit).safeParse(json); const { error, data } = UserDataSchema.max(apiConstants.songLimit).safeParse(json);
if (error) { if (error) {
setPending(false); setPending(false);
return showToast("Invalid Song Spotlight data in clipboard!", Toasts.Type.FAILURE); return showToast("Invalid Song Spotlight data in clipboard!", "failure");
} }
const validated = await Promise.allSettled(data.map(song => Native.validateSong(song))); const validated = await Promise.allSettled(data.map(song => Native.validateSong(song)));
if (!validated.every(x => x.status === "fulfilled" && x.value)) { if (!validated.every(x => x.status === "fulfilled" && x.value)) {
setPending(false); setPending(false);
return showToast("One or more imported songs were invalid.", Toasts.Type.FAILURE); return showToast("One or more imported songs were invalid.", "failure");
} }
onImport(data); onImport(data);
setPending(false); setPending(false);
showToast("Imported songs from clipboard!", Toasts.Type.SUCCESS); showToast("Imported songs from clipboard!", "success");
}, [pending]); }, [pending]);
return ( return (
@ -153,7 +153,7 @@ export default function Settings({ templateData }: SettingsProps) {
setPending(true); setPending(true);
try { try {
await saveData(localData); await saveData(localData);
showToast("Successfully saved songs!", Toasts.Type.SUCCESS); showToast("Successfully saved songs!", "success");
} finally { } finally {
setPending(false); setPending(false);
} }
@ -173,7 +173,7 @@ export default function Settings({ templateData }: SettingsProps) {
variant="dangerPrimary" variant="dangerPrimary"
onClick={() => { onClick={() => {
deleteTokens(); deleteTokens();
showToast("Successfully signed out!", Toasts.Type.SUCCESS); showToast("Successfully signed out!", "success");
}} }}
disabled={pending} disabled={pending}
> >
@ -191,7 +191,7 @@ export default function Settings({ templateData }: SettingsProps) {
await deleteData(); await deleteData();
deleteTokens(); deleteTokens();
showToast("Successfully deleted songs!", Toasts.Type.SUCCESS); showToast("Successfully deleted songs!", "success");
} finally { } finally {
setPending(false); setPending(false);
} }

View file

@ -19,11 +19,11 @@ import { sid } from "@song-spotlight/api/util";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import { User } from "@vencord/discord-types"; import { User } from "@vencord/discord-types";
import { import {
openUserProfileModal,
SelectedChannelStore, SelectedChannelStore,
SelectedGuildStore, SelectedGuildStore,
useEffect, useEffect,
useMemo, useMemo,
UserProfileActions,
UserStore, UserStore,
useState, useState,
} from "@webpack/common"; } from "@webpack/common";
@ -70,10 +70,14 @@ export default function CollapsedProfileSongs({ data, user, isSideBar, isRedesig
if (!user) return; if (!user) return;
const guildId = SelectedGuildStore.getGuildId(); const guildId = SelectedGuildStore.getGuildId();
UserProfileActions.openUserProfileModal({ openUserProfileModal({
userId, userId,
guildId, guildId,
channelId: SelectedChannelStore.getChannelId(), channelId: SelectedChannelStore.getChannelId(),
sourceAnalyticsLocations: [
"username",
"user profile popout",
],
tabSection: "SONG_SPOTLIGHT", tabSection: "SONG_SPOTLIGHT",
}); });
}} }}

View file

@ -30,21 +30,7 @@ import { Song as SongType } from "@song-spotlight/api/structs";
import { isListLayout, sid } from "@song-spotlight/api/util"; import { isListLayout, sid } from "@song-spotlight/api/util";
import { copyWithToast } from "@utils/discord"; import { copyWithToast } from "@utils/discord";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import { import { Clickable, ContextMenuApi, FluxDispatcher, Menu, React, ScrollerThin, showToast, Tooltip, useCallback, useMemo, useRef, useState } from "@webpack/common";
Clickable,
ContextMenuApi,
FluxDispatcher,
Menu,
React,
ScrollerThin,
showToast,
Toasts,
Tooltip,
useCallback,
useMemo,
useRef,
useState
} from "@webpack/common";
interface SongEntryProps { interface SongEntryProps {
entry: RenderInfoEntryBased; entry: RenderInfoEntryBased;
@ -88,7 +74,7 @@ function SongEntry({ entry, number, isLoaded, isPlaying, big, onClick }: SongEnt
const song = await Native.parseLink(entry.link); const song = await Native.parseLink(entry.link);
if (!song) { if (!song) {
return showToast("Uh oh, this song doesn't exist!", Toasts.Type.FAILURE); return showToast("Uh oh, this song doesn't exist!", "failure");
} }
if (self.find(x => sid(x) === sid(song))) { if (self.find(x => sid(x) === sid(song))) {

View file

@ -12,7 +12,7 @@ import { Logger } from "@utils/Logger";
import { sleep } from "@utils/misc"; import { sleep } from "@utils/misc";
import definePlugin, { makeRange, OptionType } from "@utils/types"; import definePlugin, { makeRange, OptionType } from "@utils/types";
import type { Channel } from "@vencord/discord-types"; import type { Channel } from "@vencord/discord-types";
import { ChannelStore, ComponentDispatch, PermissionsBits, PermissionStore, Toasts, UserStore } from "@webpack/common"; import { ChannelStore, ComponentDispatch, PermissionsBits, PermissionStore, showToast,UserStore } from "@webpack/common";
import { splitMessage, type SplitMode } from "./splitMessage"; import { splitMessage, type SplitMode } from "./splitMessage";
@ -120,11 +120,7 @@ const listener: MessageSendListener = async (channelId, message) => {
const channel = ChannelStore.getChannel(channelId); const channel = ChannelStore.getChannel(channelId);
if (!canSplitInChannel(channel)) { if (!canSplitInChannel(channel)) {
Toasts.show({ showToast("Cannot split this message because of the channel's slowmode.", "failure");
message: "Cannot split this message because of the channel's slowmode.",
id: "vc-splitLargeMessages-blocked",
type: Toasts.Type.FAILURE,
});
return { cancel: true }; return { cancel: true };
} }
@ -134,11 +130,7 @@ const listener: MessageSendListener = async (channelId, message) => {
const sent = await sendChunks(channelId, chunks, getSendDelay(channel)); const sent = await sendChunks(channelId, chunks, getSendDelay(channel));
if (sent !== chunks.length) { if (sent !== chunks.length) {
restoreUnsentContent(channelId, chunks, sent); restoreUnsentContent(channelId, chunks, sent);
Toasts.show({ showToast(`Only ${sent}/${chunks.length} message parts were sent.`, "failure");
message: `Only ${sent}/${chunks.length} message parts were sent.`,
id: "vc-splitLargeMessages-failure",
type: Toasts.Type.FAILURE,
});
} }
return { cancel: true }; return { cancel: true };

View file

@ -26,7 +26,7 @@ import { proxyLazy } from "@utils/lazy";
import { useForceUpdater } from "@utils/react"; import { useForceUpdater } from "@utils/react";
import definePlugin, { OptionType, StartAt } from "@utils/types"; import definePlugin, { OptionType, StartAt } from "@utils/types";
import { extractAndLoadChunksLazy, findComponentByCodeLazy, findModuleId, wreq } from "@webpack"; import { extractAndLoadChunksLazy, findComponentByCodeLazy, findModuleId, wreq } from "@webpack";
import { Menu, openModalLazy, OverridePremiumTypeStore, Toasts } from "@webpack/common"; import { Menu, openModalLazy, OverridePremiumTypeStore, showToast } from "@webpack/common";
interface Emoji { interface Emoji {
animated: boolean; animated: boolean;
@ -189,11 +189,7 @@ export default definePlugin({
style: { marginLeft: "20px" }, style: { marginLeft: "20px" },
onClick: () => { onClick: () => {
settings.store.StatusPresets[status.text] = status; settings.store.StatusPresets[status.text] = status;
Toasts.show({ showToast("Successfully Saved Status", "success");
message: "Successfully Saved Status",
type: Toasts.Type.SUCCESS,
id: Toasts.genId()
});
} }
}; };
}, },

View file

@ -7,7 +7,7 @@
import * as DataStore from "@api/DataStore"; import * as DataStore from "@api/DataStore";
import { proxyLazy } from "@utils/lazy"; import { proxyLazy } from "@utils/lazy";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { OAuth2AuthorizeModal, openModal, showToast, Toasts, UserStore, zustandCreate, zustandPersist } from "@webpack/common"; import { OAuth2AuthorizeModal, openModal, showToast, UserStore, zustandCreate, zustandPersist } from "@webpack/common";
import { AUTHORIZE_URL, CLIENT_ID } from "../constants"; import { AUTHORIZE_URL, CLIENT_ID } from "../constants";
import { useStreaksStore } from "./StreaksStore"; import { useStreaksStore } from "./StreaksStore";
@ -78,7 +78,7 @@ export const useAuthorizationStore = proxyLazy(() => zustandCreate(
resolve(void 0); resolve(void 0);
} catch (e) { } catch (e) {
if (e instanceof Error) { if (e instanceof Error) {
showToast(`Failed to authorize: ${e.message}`, Toasts.Type.FAILURE); showToast(`Failed to authorize: ${e.message}`, "failure");
new Logger("Streaks").error("Failed to authorize", e); new Logger("Streaks").error("Failed to authorize", e);
reject(e); reject(e);
} }

View file

@ -15,7 +15,7 @@ import { openInviteModal } from "@utils/discord";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import type { PluginNative } from "@utils/types"; import type { PluginNative } from "@utils/types";
import { findComponentByCodeLazy } from "@webpack"; import { findComponentByCodeLazy } from "@webpack";
import { Button, Modal, openModal, Parser, React, showToast, Toasts } from "@webpack/common"; import { Button, Modal, openModal, Parser, React, showToast } from "@webpack/common";
import { logger } from "./ThemeTab"; import { logger } from "./ThemeTab";
@ -25,10 +25,10 @@ const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaul
async function downloadTheme(theme: Theme) { async function downloadTheme(theme: Theme) {
try { try {
await Native.downloadTheme(theme); await Native.downloadTheme(theme);
showToast(`Downloaded ${theme.name}!`, Toasts.Type.SUCCESS); showToast(`Downloaded ${theme.name}!`, "success");
} catch (err: unknown) { } catch (err: unknown) {
logger.error(err); logger.error(err);
showToast(`Failed to download ${theme.name}! (check console)`, Toasts.Type.FAILURE); showToast(`Failed to download ${theme.name}! (check console)`, "failure");
} }
} }
@ -166,7 +166,7 @@ export const ThemeInfoModal: React.FC<ThemeInfoModalProps> = ({ author, theme, .
onClick={async e => { onClick={async e => {
e.preventDefault(); e.preventDefault();
const useInvite = guild ? guild.invite_link?.split("discord.gg/")[1] : invite; const useInvite = guild ? guild.invite_link?.split("discord.gg/")[1] : invite;
useInvite != null && openInviteModal(useInvite).catch(() => showToast("Invalid or expired invite!", Toasts.Type.FAILURE)); useInvite != null && openInviteModal(useInvite).catch(() => showToast("Invalid or expired invite!", "failure"));
}} }}
> >
Join Discord Server Join Discord Server
@ -194,7 +194,7 @@ export const ThemeInfoModal: React.FC<ThemeInfoModalProps> = ({ author, theme, .
variant: "primary", variant: "primary",
onClick: () => { onClick: () => {
copyToClipboard(themeContent); copyToClipboard(themeContent);
showToast("Copied to Clipboard", Toasts.Type.SUCCESS); showToast("Copied to Clipboard", "success");
} }
} }
]} ]}

View file

@ -7,7 +7,8 @@
import * as DataStore from "@api/DataStore"; import * as DataStore from "@api/DataStore";
import { showNotification } from "@api/Notifications"; import { showNotification } from "@api/Notifications";
import { logger, themeRequest } from "@equicordplugins/themeLibrary/components/ThemeTab"; import { logger, themeRequest } from "@equicordplugins/themeLibrary/components/ThemeTab";
import { OAuth2AuthorizeModal, openModal,Toasts, UserStore } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { OAuth2AuthorizeModal, openModal, showToast,UserStore } from "@webpack/common";
export async function authorizeUser(triggerModal: boolean = true) { export async function authorizeUser(triggerModal: boolean = true) {
const isAuthorized = await getAuthorization(); const isAuthorized = await getAuthorization();
@ -64,15 +65,10 @@ export async function authorizeUser(triggerModal: boolean = true) {
export async function deauthorizeUser() { export async function deauthorizeUser() {
const uniqueToken = await DataStore.get<Record<string, string>>("ThemeLibrary_uniqueToken"); const uniqueToken = await DataStore.get<Record<string, string>>("ThemeLibrary_uniqueToken");
if (!uniqueToken) return Toasts.show({ if (!uniqueToken) return showToast("No uniqueToken present, try authorizing first!", "failure", {
message: "No uniqueToken present, try authorizing first!",
id: Toasts.genId(),
type: Toasts.Type.FAILURE,
options: {
duration: 2e3, duration: 2e3,
position: Toasts.Position.BOTTOM position: ToastPosition.BOTTOM
} });
});
const res = await themeRequest("/user/revoke", { const res = await themeRequest("/user/revoke", {
method: "DELETE", method: "DELETE",

View file

@ -12,7 +12,8 @@ import { Paragraph } from "@components/Paragraph";
import { copyToClipboard } from "@utils/clipboard"; import { copyToClipboard } from "@utils/clipboard";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import { OptionType } from "@utils/types"; import { OptionType } from "@utils/types";
import { Button, Toasts } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { Button, showToast } from "@webpack/common";
import { authorizeUser, deauthorizeUser } from "./auth"; import { authorizeUser, deauthorizeUser } from "./auth";
@ -32,27 +33,17 @@ export const settings = definePluginSettings({
const handleClick = async () => { const handleClick = async () => {
const token = await DataStore.get("ThemeLibrary_uniqueToken"); const token = await DataStore.get("ThemeLibrary_uniqueToken");
if (!token) return Toasts.show({ if (!token) return showToast("No token to copy, try authorizing first!", "failure", {
message: "No token to copy, try authorizing first!",
id: Toasts.genId(),
type: Toasts.Type.FAILURE,
options: {
duration: 2.5e3, duration: 2.5e3,
position: Toasts.Position.BOTTOM position: ToastPosition.BOTTOM
} });
});
copyToClipboard(token); copyToClipboard(token);
Toasts.show({ showToast("Copied to Clipboard!", "success", {
message: "Copied to Clipboard!",
id: Toasts.genId(),
type: Toasts.Type.SUCCESS,
options: {
duration: 2.5e3, duration: 2.5e3,
position: Toasts.Position.BOTTOM position: ToastPosition.BOTTOM
} });
});
}; };
return ( return (

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
import { OAuth2AuthorizeModal, openModal, showToast, Toasts } from "@webpack/common"; import { OAuth2AuthorizeModal, openModal, showToast } from "@webpack/common";
import { settings } from "."; import { settings } from ".";
@ -22,7 +22,7 @@ function getRedirectUri(): string {
function handleApiError(error: any, defaultMessage: string): void { function handleApiError(error: any, defaultMessage: string): void {
console.error(defaultMessage, error); console.error(defaultMessage, error);
const message = error?.message || defaultMessage; const message = error?.message || defaultMessage;
showToast(message, Toasts.Type.FAILURE); showToast(message, "failure");
} }
async function safeJsonParse(response: Response): Promise<any> { async function safeJsonParse(response: Response): Promise<any> {
@ -111,7 +111,7 @@ async function setTimezoneInternal(timezone: string): Promise<boolean> {
return false; return false;
} }
showToast("Timezone updated successfully!", Toasts.Type.SUCCESS); showToast("Timezone updated successfully!", "success");
return true; return true;
} catch (e) { } catch (e) {
handleApiError(e, "Failed to set timezone"); handleApiError(e, "Failed to set timezone");
@ -149,7 +149,7 @@ async function deleteTimezoneInternal(): Promise<boolean> {
return false; return false;
} }
showToast("Timezone deleted successfully!", Toasts.Type.SUCCESS); showToast("Timezone deleted successfully!", "success");
return true; return true;
} catch (e) { } catch (e) {
handleApiError(e, "Failed to delete timezone"); handleApiError(e, "Failed to delete timezone");
@ -180,7 +180,7 @@ export function authModal(callback?: () => void) {
handleApiError(json, "Authorization failed"); handleApiError(json, "Authorization failed");
return; return;
} }
showToast("Authorization successful!", Toasts.Type.SUCCESS); showToast("Authorization successful!", "success");
callback?.(); callback?.();
} catch (e) { } catch (e) {
handleApiError(e, "Unexpected error during authorization"); handleApiError(e, "Unexpected error during authorization");

View file

@ -13,8 +13,9 @@ import ErrorBoundary from "@components/ErrorBoundary";
import { Devs, EquicordDevs } from "@utils/constants"; import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { Message, User } from "@vencord/discord-types"; import { Message, User } from "@vencord/discord-types";
import { ToastPosition } from "@vencord/discord-types/enums";
import { findByPropsLazy, findCssClassesLazy } from "@webpack"; import { findByPropsLazy, findCssClassesLazy } from "@webpack";
import { Button, ChannelStore, Menu, openModal, showToast, Toasts, Tooltip, useEffect, UserStore, useState } from "@webpack/common"; import { Button, ChannelStore, Menu, openModal, showToast, Tooltip, useEffect, UserStore, useState } from "@webpack/common";
import { deleteTimezone, getTimezone, loadDatabaseTimezones, setUserDatabaseTimezone } from "./database"; import { deleteTimezone, getTimezone, loadDatabaseTimezones, setUserDatabaseTimezone } from "./database";
import { SetTimezoneModal } from "./TimezoneModal"; import { SetTimezoneModal } from "./TimezoneModal";
@ -127,7 +128,7 @@ export const settings = definePluginSettings({
await deleteTimezone(); await deleteTimezone();
} catch (error) { } catch (error) {
console.error("Error resetting database timezone:", error); console.error("Error resetting database timezone:", error);
showToast("Failed to reset database timezone", Toasts.Type.FAILURE); showToast("Failed to reset database timezone", "failure");
} }
}} }}
> >
@ -312,14 +313,14 @@ export default definePlugin({
const good = await loadDatabaseTimezones(); const good = await loadDatabaseTimezones();
if (good) { if (good) {
showToast("Timezones refreshed successfully!", Toasts.Type.SUCCESS); showToast("Timezones refreshed successfully!", "success");
} else { } else {
showToast("Timezones Failed to refresh!", Toasts.Type.FAILURE); showToast("Timezones Failed to refresh!", "failure");
} }
} }
catch (error) { catch (error) {
console.error("Failed to refresh timezone:", error); console.error("Failed to refresh timezone:", error);
showToast("Failed to refresh timezones.", Toasts.Type.FAILURE); showToast("Failed to refresh timezones.", "failure");
} }
} }
}, },
@ -333,7 +334,7 @@ export default definePlugin({
if (!settings.store.askedTimezone) { if (!settings.store.askedTimezone) {
showToast( showToast(
"", "",
Toasts.Type.MESSAGE, "message",
{ {
duration: 10000, duration: 10000,
component: ( component: (
@ -346,7 +347,7 @@ export default definePlugin({
Want to save your timezone to the database? Click here to set it. Want to save your timezone to the database? Click here to set it.
</Button> </Button>
), ),
position: Toasts.Position.BOTTOM position: ToastPosition.BOTTOM
} }
); );
settings.store.askedTimezone = true; settings.store.askedTimezone = true;

View file

@ -8,7 +8,7 @@ import { sendBotMessage } from "@api/Commands";
import { insertTextIntoChatInputBox, sendMessage } from "@utils/discord"; import { insertTextIntoChatInputBox, sendMessage } from "@utils/discord";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { Message } from "@vencord/discord-types"; import { Message } from "@vencord/discord-types";
import { MessageStore, showToast, Toasts, UserStore } from "@webpack/common"; import { MessageStore, showToast, UserStore } from "@webpack/common";
import { settings } from "./settings"; import { settings } from "./settings";
@ -225,7 +225,7 @@ function getSystemPrompt() {
export async function getResponse(payload: ApiMessage[]): Promise<string> { export async function getResponse(payload: ApiMessage[]): Promise<string> {
if (!settings.store.apiKey || !settings.store.endpoint || !settings.store.model) { if (!settings.store.apiKey || !settings.store.endpoint || !settings.store.model) {
showToast("TriviaAI: API settings are incomplete.", Toasts.Type.FAILURE); showToast("TriviaAI: API settings are incomplete.", "failure");
return ""; return "";
} }
@ -258,7 +258,7 @@ export async function getResponse(payload: ApiMessage[]): Promise<string> {
if (!req.ok || data.error) { if (!req.ok || data.error) {
const errorMsg = data.error?.message ?? rawBody ?? `Status ${req.status}`; const errorMsg = data.error?.message ?? rawBody ?? `Status ${req.status}`;
logger.error(`API Error: ${errorMsg}`); logger.error(`API Error: ${errorMsg}`);
showToast(errorMsg, Toasts.Type.FAILURE); showToast(errorMsg, "failure");
return ""; return "";
} }
@ -271,7 +271,7 @@ export async function getResponse(payload: ApiMessage[]): Promise<string> {
return response; return response;
} catch (e) { } catch (e) {
logger.error("Error getting response from AI model", e); logger.error("Error getting response from AI model", e);
showToast("Error getting response from AI model", Toasts.Type.FAILURE); showToast("Error getting response from AI model", "failure");
return ""; return "";
} }
} }

View file

@ -9,7 +9,7 @@ import { Heading } from "@components/Heading";
import { Margins } from "@components/margins"; import { Margins } from "@components/margins";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import { RenderModalProps } from "@vencord/discord-types"; import { RenderModalProps } from "@vencord/discord-types";
import { IconUtils, Modal, React, TextInput, Toasts, UserStore, useState } from "@webpack/common"; import { IconUtils, Modal, React, showToast,TextInput, UserStore, useState } from "@webpack/common";
import { data, KEY_DATASTORE } from "."; import { data, KEY_DATASTORE } from ".";
@ -47,11 +47,7 @@ export function SetAvatarModal({ userId, modalProps }: { userId: string; modalPr
if (!file.type.startsWith("image/")) return; if (!file.type.startsWith("image/")) return;
if (file.type === "image/gif" || file.type === "image/webp") { if (file.type === "image/gif" || file.type === "image/webp") {
Toasts.show({ showToast("GIFs/WebP must be added via URL. Upload your GIF/WebP to a image hosting service and paste the link.", "failure");
message: "GIFs/WebP must be added via URL. Upload your GIF/WebP to a image hosting service and paste the link.",
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
});
return; return;
} }

View file

@ -20,7 +20,7 @@ import {
} from "@components/settings/tabs/BaseTab"; } from "@components/settings/tabs/BaseTab";
import { classes, isObjectEmpty } from "@utils/misc"; import { classes, isObjectEmpty } from "@utils/misc";
import { relaunch } from "@utils/native"; import { relaunch } from "@utils/native";
import { Alerts, closeAllModals,NavigationRouter, Toasts, useEffect, useState } from "@webpack/common"; import { Alerts, closeAllModals, NavigationRouter, showToast,useEffect, useState } from "@webpack/common";
import userpluginInstaller, { Native } from ".."; import userpluginInstaller, { Native } from "..";
import { import {
@ -236,11 +236,7 @@ function UserPluginsTab() {
setEnabled={t => { setEnabled={t => {
Vencord.Settings.plugins[pl.name].enabled = t; Vencord.Settings.plugins[pl.name].enabled = t;
if (pluginRequiresRestart(pl)) { if (pluginRequiresRestart(pl)) {
Toasts.show({ showToast("Restart to apply changes!", "message");
id: Toasts.genId(),
message: "Restart to apply changes!",
type: Toasts.Type.MESSAGE
});
} else { } else {
(t ? startPlugin : stopPlugin)(pl); (t ? startPlugin : stopPlugin)(pl);
} }

View file

@ -12,8 +12,9 @@ import { definePluginSettings } from "@api/Settings";
import { EquicordDevs } from "@utils/constants"; import { EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { chooseFile, saveFile } from "@utils/web"; import { chooseFile, saveFile } from "@utils/web";
import { CustomEmoji, UnicodeEmoji } from "@vencord/discord-types"; import { CustomEmoji, ToastType, UnicodeEmoji } from "@vencord/discord-types";
import { Alerts, Button, EmojiStore, GuildStore, IconUtils, Menu, Toasts, useEffect, useState } from "@webpack/common"; import { ToastPosition } from "@vencord/discord-types/enums";
import { Alerts, Button, EmojiStore, GuildStore, IconUtils, Menu, showToast as originalShowToast, useEffect, useState } from "@webpack/common";
import { JSX } from "react"; import { JSX } from "react";
import { ContextMenuEmoji, SavedEmoji, Target } from "./types"; import { ContextMenuEmoji, SavedEmoji, Target } from "./types";
@ -73,14 +74,9 @@ function buildSaveData(item: ContextMenuEmoji): SavedEmoji {
return saveData; return saveData;
} }
function showToast(message: string, type = Toasts.Type.SUCCESS) { function showToast(message: string, type: ToastType = "success") {
if (settings.store.disableToasts) return; if (settings.store.disableToasts) return;
Toasts.show({ originalShowToast(message, type, { duration: 3000, position: ToastPosition.BOTTOM });
message,
type,
id: Toasts.genId(),
options: { duration: 3000, position: Toasts.Position.BOTTOM }
});
} }
function addBulkToAllowedList(items: ContextMenuEmoji[]) { function addBulkToAllowedList(items: ContextMenuEmoji[]) {
@ -104,7 +100,7 @@ function removeBulkFromAllowedList(items: ContextMenuEmoji[]) {
function addToAllowedList(item: ContextMenuEmoji) { function addToAllowedList(item: ContextMenuEmoji) {
return withWriteLock(async () => { return withWriteLock(async () => {
if (itemAlreadyInList(item)) { if (itemAlreadyInList(item)) {
showToast(`"${item.name}" is already in the list`, Toasts.Type.FAILURE); showToast(`"${item.name}" is already in the list`, "failure");
return; return;
} }
@ -116,7 +112,7 @@ function addToAllowedList(item: ContextMenuEmoji) {
function removeFromAllowedList(item: ContextMenuEmoji) { function removeFromAllowedList(item: ContextMenuEmoji) {
return withWriteLock(async () => { return withWriteLock(async () => {
if (!itemAlreadyInList(item)) { if (!itemAlreadyInList(item)) {
showToast(`"${item.name}" is not in the list`, Toasts.Type.FAILURE); showToast(`"${item.name}" is not in the list`, "failure");
return; return;
} }
@ -323,10 +319,10 @@ const importEmojis = (data: string) => withWriteLock(async () => {
await setAllowedList(parsed.emojis); await setAllowedList(parsed.emojis);
showToast("Successfully imported emojis"); showToast("Successfully imported emojis");
} else { } else {
showToast("Invalid JSON data", Toasts.Type.FAILURE); showToast("Invalid JSON data", "failure");
} }
} catch (err) { } catch (err) {
showToast(`Failed to import emojis: ${err}`, Toasts.Type.FAILURE); showToast(`Failed to import emojis: ${err}`, "failure");
} }
}); });

View file

@ -41,7 +41,7 @@ import definePlugin from "@utils/types";
import { checkForUpdates, isOutdated, update } from "@utils/updater"; import { checkForUpdates, isOutdated, update } from "@utils/updater";
import { RenderModalProps } from "@vencord/discord-types"; import { RenderModalProps } from "@vencord/discord-types";
import { CloudUploadPlatform } from "@vencord/discord-types/enums"; import { CloudUploadPlatform } from "@vencord/discord-types/enums";
import { Alerts, ChannelStore, CloudUploader, ConfirmModal, Constants, GuildMemberStore, openModal, Parser, PermissionsBits, PermissionStore, RelationshipStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Text, Toasts, UserStore } from "@webpack/common"; import { Alerts, ChannelStore, CloudUploader, ConfirmModal, Constants, GuildMemberStore, openModal, Parser, PermissionsBits, PermissionStore, RelationshipStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Text, UserStore } from "@webpack/common";
import { JSX } from "react"; import { JSX } from "react";
import plugins, { PluginMeta } from "~plugins"; import plugins, { PluginMeta } from "~plugins";
@ -480,10 +480,10 @@ export default definePlugin({
} else if (pluginList && typeof pluginList === "object" && pluginList.uploadFile) { } else if (pluginList && typeof pluginList === "object" && pluginList.uploadFile) {
try { try {
await uploadPluginListFile(props.channel.id, pluginList.fileContent, pluginList.filename); await uploadPluginListFile(props.channel.id, pluginList.fileContent, pluginList.filename);
showToast("Plugin list uploaded successfully!", Toasts.Type.SUCCESS); showToast("Plugin list uploaded successfully!", "success");
} catch (e) { } catch (e) {
new Logger("SupportHelper").error("Failed to upload plugin list:", e); new Logger("SupportHelper").error("Failed to upload plugin list:", e);
showToast("Failed to upload plugin list", Toasts.Type.FAILURE); showToast("Failed to upload plugin list", "failure");
} }
} }
}} }}

View file

@ -15,7 +15,7 @@ import { debounce } from "@shared/debounce";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import { useAwaiter } from "@utils/react"; import { useAwaiter } from "@utils/react";
import { ActivityType } from "@vencord/discord-types/enums"; import { ActivityType } from "@vencord/discord-types/enums";
import { Button, Select, showToast, Text, TextInput, Toasts, useState } from "@webpack/common"; import { Button, Select, showToast, Text, TextInput, useState } from "@webpack/common";
import CustomRPCPlugin, { RpcConfig, setRpc, settings, TimestampMode } from "."; import CustomRPCPlugin, { RpcConfig, setRpc, settings, TimestampMode } from ".";
@ -183,7 +183,7 @@ function PresetSettings({ onLoad }: { onLoad(): void; }) {
await DataStore.set(PRESETS_KEY, nextPresets); await DataStore.set(PRESETS_KEY, nextPresets);
setChangedPresets(nextPresets); setChangedPresets(nextPresets);
setSelectedPreset(name); setSelectedPreset(name);
showToast(`Saved preset ${name}.`, Toasts.Type.SUCCESS); showToast(`Saved preset ${name}.`, "success");
} }
function loadPreset() { function loadPreset() {
@ -193,7 +193,7 @@ function PresetSettings({ onLoad }: { onLoad(): void; }) {
Object.assign(settings.store, preset.config); Object.assign(settings.store, preset.config);
onLoad(); onLoad();
updateRPC(); updateRPC();
showToast(`Loaded preset ${preset.name}.`, Toasts.Type.SUCCESS); showToast(`Loaded preset ${preset.name}.`, "success");
} }
async function deletePreset() { async function deletePreset() {
@ -203,7 +203,7 @@ function PresetSettings({ onLoad }: { onLoad(): void; }) {
await DataStore.set(PRESETS_KEY, nextPresets); await DataStore.set(PRESETS_KEY, nextPresets);
setChangedPresets(nextPresets); setChangedPresets(nextPresets);
setSelectedPreset(""); setSelectedPreset("");
showToast(`Deleted preset ${selectedPreset}.`, Toasts.Type.SUCCESS); showToast(`Deleted preset ${selectedPreset}.`, "success");
} }
return ( return (

View file

@ -11,8 +11,9 @@ import { loadLazyChunks } from "@debug/loadLazyChunks";
import { reporterData } from "@debug/reporterData"; import { reporterData } from "@debug/reporterData";
import { getIntlMessageFromHash } from "@utils/discord"; import { getIntlMessageFromHash } from "@utils/discord";
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches"; import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
import { ToastPosition } from "@vencord/discord-types/enums";
import { filters, findAll, search, wreq } from "@webpack"; import { filters, findAll, search, wreq } from "@webpack";
import { React, Toasts, useState } from "@webpack/common"; import { React, showToast,useState } from "@webpack/common";
import { CLIENT_VERSION, logger, PORT, settings } from "."; import { CLIENT_VERSION, logger, PORT, settings } from ".";
import { Recieve } from "./types"; import { Recieve } from "./types";
@ -65,14 +66,9 @@ export function initWs(isManual = false) {
try { try {
if (settings.store.notifyOnAutoConnect || isManual) { if (settings.store.notifyOnAutoConnect || isManual) {
Toasts.show({ showToast("Connected to WebSocket", "success", {
message: "Connected to WebSocket", position: ToastPosition.TOP
id: Toasts.genId(), });
type: Toasts.Type.SUCCESS,
options: {
position: Toasts.Position.TOP
}
});
} }
} }
catch (e) { catch (e) {
@ -87,14 +83,9 @@ export function initWs(isManual = false) {
logger.error("Dev Companion Error:", e); logger.error("Dev Companion Error:", e);
Toasts.show({ showToast("Dev Companion Error", "failure", {
message: "Dev Companion Error", position: ToastPosition.TOP
id: Toasts.genId(), });
type: Toasts.Type.FAILURE,
options: {
position: Toasts.Position.TOP
}
});
}); });
ws.addEventListener("close", e => { ws.addEventListener("close", e => {
@ -102,14 +93,9 @@ export function initWs(isManual = false) {
logger.info("Dev Companion Disconnected:", e.code, e.reason); logger.info("Dev Companion Disconnected:", e.code, e.reason);
Toasts.show({ showToast("Dev Companion Disconnected", "failure", {
message: "Dev Companion Disconnected", position: ToastPosition.TOP
id: Toasts.genId(), });
type: Toasts.Type.FAILURE,
options: {
position: Toasts.Position.TOP
}
});
}); });
ws.addEventListener("message", e => { ws.addEventListener("message", e => {

View file

@ -8,9 +8,10 @@ import { showNotice } from "@api/Notices";
import { plugins, startDependenciesRecursive, startPlugin, stopPlugin } from "@api/PluginManager"; import { plugins, startDependenciesRecursive, startPlugin, stopPlugin } from "@api/PluginManager";
import { Settings } from "@api/Settings"; import { Settings } from "@api/Settings";
import { canonicalizeMatch } from "@utils/patches"; import { canonicalizeMatch } from "@utils/patches";
import { ToastPosition } from "@vencord/discord-types/enums";
import { Module } from "@vencord/discord-types/webpack"; import { Module } from "@vencord/discord-types/webpack";
import { CodeFilter, FilterFn, stringMatches, wreq } from "@webpack"; import { CodeFilter, FilterFn, stringMatches, wreq } from "@webpack";
import { Toasts } from "@webpack/common"; import { showToast } from "@webpack/common";
import { WebpackPatcher } from "../../Vencord"; import { WebpackPatcher } from "../../Vencord";
import { logger, settings as companionSettings } from "."; import { logger, settings as companionSettings } from ".";
@ -107,14 +108,9 @@ export function mkRegexFind(idOrSearch: string): RegExp[] {
} }
// the next two functions are copied from components/pluginSettings // the next two functions are copied from components/pluginSettings
function showErrorToast(message: string) { function showErrorToast(message: string) {
Toasts.show({ showToast(message, "failure", {
message, position: ToastPosition.BOTTOM
type: Toasts.Type.FAILURE, });
id: Toasts.genId(),
options: {
position: Toasts.Position.BOTTOM
}
});
} }
export function toggleEnabled(name: string, beforeReload: (error?: string) => void) { export function toggleEnabled(name: string, beforeReload: (error?: string) => void) {
@ -128,15 +124,10 @@ export function toggleEnabled(name: string, beforeReload: (error?: string) => vo
beforeReload(); beforeReload();
window.location.reload(); window.location.reload();
} }
Toasts.show({ showToast("Reload Needed", "message", {
id: Toasts.genId(),
message: "Reload Needed",
type: Toasts.Type.MESSAGE,
options: {
duration: 5000, duration: 5000,
position: Toasts.Position.TOP position: ToastPosition.TOP
} });
});
} }
} }
const plugin = plugins[name]; const plugin = plugins[name];

View file

@ -19,7 +19,7 @@ import { Logger } from "@utils/Logger";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { Emoji, Message } from "@vencord/discord-types"; import { Emoji, Message } from "@vencord/discord-types";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
import { EmojiStore, Menu, openModal,TextInput, Toasts, useEffect, useState } from "@webpack/common"; import { EmojiStore, Menu, openModal, showToast,TextInput, useEffect, useState } from "@webpack/common";
import { ClearAliasesConfirmModal } from "./components/modals/ClearAliasesConfirmModal"; import { ClearAliasesConfirmModal } from "./components/modals/ClearAliasesConfirmModal";
import { SetAliasModal } from "./components/modals/SetAliasModal"; import { SetAliasModal } from "./components/modals/SetAliasModal";
@ -700,18 +700,10 @@ async function removeAlias(alias: string) {
try { try {
await persistAliases(nextMap); await persistAliases(nextMap);
Toasts.show({ showToast(`Removed alias :${alias}:`, "success");
id: Toasts.genId(),
message: `Removed alias :${alias}:`,
type: Toasts.Type.SUCCESS
});
} catch (error) { } catch (error) {
logger.error("Failed to remove emoji alias.", error); logger.error("Failed to remove emoji alias.", error);
Toasts.show({ showToast("Failed to remove alias.", "failure");
id: Toasts.genId(),
message: "Failed to remove alias.",
type: Toasts.Type.FAILURE
});
} }
} }
@ -720,18 +712,10 @@ async function clearAliases() {
try { try {
await persistAliases({}); await persistAliases({});
Toasts.show({ showToast("Deleted all emoji aliases.", "success");
id: Toasts.genId(),
message: "Deleted all emoji aliases.",
type: Toasts.Type.SUCCESS
});
} catch (error) { } catch (error) {
logger.error("Failed to clear emoji aliases.", error); logger.error("Failed to clear emoji aliases.", error);
Toasts.show({ showToast("Failed to delete aliases.", "failure");
id: Toasts.genId(),
message: "Failed to delete aliases.",
type: Toasts.Type.FAILURE
});
} }
} }
@ -750,11 +734,7 @@ function openSetAliasModal(ref: StoredEmojiRef) {
onSave={async input => { onSave={async input => {
const result = await saveAlias(input, ref); const result = await saveAlias(input, ref);
if (!result.ok) return result; if (!result.ok) return result;
Toasts.show({ showToast(`Alias set for ${getEmojiDisplayName(ref)}.`, "success");
id: Toasts.genId(),
message: `Alias set for ${getEmojiDisplayName(ref)}.`,
type: Toasts.Type.SUCCESS
});
return result; return result;
}} }}
/> />

View file

@ -13,7 +13,7 @@ import { Logger } from "@utils/Logger";
import definePlugin, { makeRange, OptionType } from "@utils/types"; import definePlugin, { makeRange, OptionType } from "@utils/types";
import type { Channel, Message } from "@vencord/discord-types"; import type { Channel, Message } from "@vencord/discord-types";
import { ApplicationIntegrationType, MessageFlags } from "@vencord/discord-types/enums"; import { ApplicationIntegrationType, MessageFlags } from "@vencord/discord-types/enums";
import { AuthenticationStore, Constants, EditMessageStore, FluxDispatcher, MessageActions, MessageTypeSets, PermissionsBits, PermissionStore, PinActions, RestAPI, Toasts, WindowStore } from "@webpack/common"; import { AuthenticationStore, Constants, EditMessageStore, FluxDispatcher, MessageActions, MessageTypeSets, PermissionsBits, PermissionStore, PinActions, RestAPI, showToast,WindowStore } from "@webpack/common";
import { AdditionalReactEmojisSetting, MAX_ADDITIONAL_REACT_EMOJIS, ReactEmojiSetting } from "./ReactEmojiSetting"; import { AdditionalReactEmojisSetting, MAX_ADDITIONAL_REACT_EMOJIS, ReactEmojiSetting } from "./ReactEmojiSetting";
@ -256,14 +256,9 @@ export const settings = definePluginSettings({
}); });
function showWarning(message: string) { function showWarning(message: string) {
Toasts.show({ showToast(message, "failure", {
message,
type: Toasts.Type.FAILURE,
id: Toasts.genId(),
options: {
duration: 3000 duration: 3000
} });
});
} }
function clearClickTimeouts() { function clearClickTimeouts() {