2022-10-18 22:04:55 +00:00
|
|
|
import * as _spitroast from "spitroast";
|
2022-10-22 17:59:01 +00:00
|
|
|
import _React from "react";
|
2023-01-14 16:24:14 +00:00
|
|
|
import _RN from "react-native";
|
2022-10-18 22:04:55 +00:00
|
|
|
|
|
|
|
type MetroModules = { [id: number]: any };
|
|
|
|
|
|
|
|
// Helper types for API functions
|
|
|
|
type PropIntellisense<P extends string | symbol> = Record<P, any> & Record<PropertyKey, any>;
|
|
|
|
type PropsFinder = <T extends string | symbol>(...props: T[]) => PropIntellisense<T>;
|
|
|
|
type PropsFinderAll = <T extends string | symbol>(...props: T[]) => PropIntellisense<T>[];
|
|
|
|
|
|
|
|
type LoggerFunction = (...messages: any[]) => void;
|
|
|
|
interface Logger {
|
2022-10-22 17:59:01 +00:00
|
|
|
log: LoggerFunction;
|
|
|
|
info: LoggerFunction;
|
|
|
|
warn: LoggerFunction;
|
|
|
|
error: LoggerFunction;
|
|
|
|
time: LoggerFunction;
|
|
|
|
trace: LoggerFunction;
|
|
|
|
verbose: LoggerFunction;
|
2022-10-18 22:04:55 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 22:21:58 +00:00
|
|
|
type SearchFilter = (tree: any) => boolean;
|
|
|
|
interface FindInTreeOptions {
|
|
|
|
walkable?: string[];
|
|
|
|
ignore?: string[];
|
|
|
|
maxDepth?: number;
|
|
|
|
}
|
|
|
|
|
2022-10-22 22:26:06 +00:00
|
|
|
interface Asset {
|
|
|
|
name: string;
|
|
|
|
id: number;
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:39:28 +00:00
|
|
|
interface PluginAuthor {
|
|
|
|
name: string;
|
|
|
|
id: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See https://github.com/vendetta-mod/polymanifest
|
2023-01-03 00:18:19 +00:00
|
|
|
interface PluginManifest {
|
|
|
|
name: string;
|
|
|
|
description: string;
|
2023-01-04 22:39:28 +00:00
|
|
|
authors: PluginAuthor[];
|
|
|
|
main: string;
|
|
|
|
hash: string;
|
|
|
|
// Vendor-specific field, contains our own data
|
2023-01-16 08:11:46 +00:00
|
|
|
vendetta?: {
|
|
|
|
icon?: string;
|
2023-01-04 22:39:28 +00:00
|
|
|
};
|
2023-01-03 00:18:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface Plugin {
|
|
|
|
id: string;
|
|
|
|
manifest: PluginManifest;
|
|
|
|
enabled: boolean;
|
2023-01-07 23:05:14 +00:00
|
|
|
update: boolean;
|
2023-01-03 00:18:19 +00:00
|
|
|
js: string;
|
|
|
|
}
|
|
|
|
|
2023-01-10 08:05:56 +00:00
|
|
|
interface Settings {
|
|
|
|
debuggerUrl: string;
|
|
|
|
developerSettings: boolean;
|
|
|
|
}
|
|
|
|
|
2023-01-30 00:40:56 +00:00
|
|
|
interface ApplicationCommand {
|
2023-01-25 08:28:48 +00:00
|
|
|
description: string;
|
|
|
|
name: string;
|
|
|
|
options: ApplicationCommandOption[];
|
|
|
|
execute: (args: any[], ctx: CommandContext) => CommandResult | void | Promise<CommandResult> | Promise<void>;
|
|
|
|
id?: string;
|
|
|
|
applicationId: string;
|
|
|
|
displayName: string;
|
|
|
|
displayDescription: string;
|
|
|
|
inputType: ApplicationCommandInputType;
|
|
|
|
type: ApplicationCommandType;
|
|
|
|
}
|
|
|
|
|
2023-01-30 00:40:56 +00:00
|
|
|
declare enum ApplicationCommandInputType {
|
2023-01-25 08:28:48 +00:00
|
|
|
BUILT_IN,
|
|
|
|
BUILT_IN_TEXT,
|
|
|
|
BUILT_IN_INTEGRATION,
|
|
|
|
BOT,
|
|
|
|
PLACEHOLDER,
|
|
|
|
}
|
|
|
|
|
2023-01-30 00:40:56 +00:00
|
|
|
interface ApplicationCommandOption {
|
2023-01-25 08:28:48 +00:00
|
|
|
name: string;
|
|
|
|
description: string;
|
|
|
|
required?: boolean;
|
|
|
|
type: ApplicationCommandOptionType;
|
|
|
|
displayName: string;
|
|
|
|
displayDescription: string;
|
|
|
|
}
|
|
|
|
|
2023-01-30 00:40:56 +00:00
|
|
|
declare enum ApplicationCommandOptionType {
|
2023-01-25 08:28:48 +00:00
|
|
|
SUB_COMMAND = 1,
|
|
|
|
SUB_COMMAND_GROUP,
|
|
|
|
STRING,
|
|
|
|
INTEGER,
|
|
|
|
BOOLEAN,
|
|
|
|
USER,
|
|
|
|
CHANNEL,
|
|
|
|
ROLE,
|
|
|
|
MENTIONABLE,
|
|
|
|
NUMBER,
|
|
|
|
ATTACHMENT,
|
|
|
|
}
|
|
|
|
|
2023-01-30 00:40:56 +00:00
|
|
|
declare enum ApplicationCommandType {
|
2023-01-25 08:28:48 +00:00
|
|
|
CHAT = 1,
|
|
|
|
USER,
|
|
|
|
MESSAGE,
|
|
|
|
}
|
|
|
|
|
2023-01-30 00:40:56 +00:00
|
|
|
interface CommandContext {
|
2023-01-25 08:28:48 +00:00
|
|
|
channel: any;
|
|
|
|
guild: any;
|
|
|
|
}
|
|
|
|
|
2023-01-30 00:40:56 +00:00
|
|
|
interface CommandResult {
|
2023-01-25 08:28:48 +00:00
|
|
|
content: string;
|
|
|
|
tts?: boolean;
|
|
|
|
}
|
|
|
|
|
2023-01-14 16:24:14 +00:00
|
|
|
interface RNConstants extends _RN.PlatformConstants {
|
2023-01-14 16:05:08 +00:00
|
|
|
// Android
|
|
|
|
Version: number;
|
|
|
|
Release: string;
|
|
|
|
Serial: string;
|
|
|
|
Fingerprint: string;
|
|
|
|
Model: string;
|
|
|
|
Brand: string;
|
|
|
|
Manufacturer: string;
|
|
|
|
ServerHost?: string;
|
|
|
|
|
|
|
|
// iOS
|
|
|
|
forceTouchAvailable: boolean;
|
|
|
|
interfaceIdiom: string;
|
|
|
|
osVersion: string;
|
|
|
|
systemName: string;
|
|
|
|
}
|
|
|
|
|
2023-01-16 23:52:20 +00:00
|
|
|
/**
|
|
|
|
* A key-value storage based upon `SharedPreferences` on Android.
|
|
|
|
*
|
|
|
|
* These types are based on Android though everything should be the same between
|
|
|
|
* platforms.
|
|
|
|
*/
|
|
|
|
interface MMKVManager {
|
|
|
|
/**
|
|
|
|
* Get the value for the given `key`, or null
|
|
|
|
* @param key The key to fetch
|
|
|
|
*/
|
|
|
|
getItem: (key: string) => Promise<string | null>;
|
|
|
|
/**
|
|
|
|
* Deletes the value for the given `key`
|
|
|
|
* @param key The key to delete
|
|
|
|
*/
|
|
|
|
removeItem: (key: string) => void;
|
|
|
|
/**
|
|
|
|
* Sets the value of `key` to `value`
|
|
|
|
*/
|
|
|
|
setItem: (key: string, value: string) => void;
|
|
|
|
/**
|
|
|
|
* Goes through every item in storage and returns it, excluding the
|
|
|
|
* keys specified in `exclude`.
|
|
|
|
* @param exclude A list of items to exclude from result
|
|
|
|
*/
|
|
|
|
refresh: (exclude: string[]) => Promise<Record<string, string>>;
|
|
|
|
/**
|
|
|
|
* You will be murdered if you use this function.
|
|
|
|
* Clears ALL of Discord's settings.
|
|
|
|
*/
|
|
|
|
clear: () => void;
|
|
|
|
}
|
|
|
|
|
2023-01-03 00:18:19 +00:00
|
|
|
type Indexable<Type> = { [index: string]: Type }
|
|
|
|
|
2023-01-30 14:15:44 +00:00
|
|
|
type EmitterEvent = "SET" | "GET" | "DEL";
|
2023-01-29 21:05:47 +00:00
|
|
|
|
|
|
|
interface EmitterListenerData {
|
|
|
|
path: string[];
|
|
|
|
value?: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
type EmitterListener = (
|
|
|
|
event: EmitterEvent,
|
|
|
|
data: EmitterListenerData | any
|
|
|
|
) => any;
|
|
|
|
|
|
|
|
type EmitterListeners = Indexable<Set<EmitterListener>>;
|
|
|
|
|
|
|
|
interface Emitter {
|
|
|
|
listeners: EmitterListeners;
|
|
|
|
on: (event: EmitterEvent, listener: EmitterListener) => void;
|
|
|
|
off: (event: EmitterEvent, listener: EmitterListener) => void;
|
|
|
|
once: (event: EmitterEvent, listener: EmitterListener) => void;
|
|
|
|
emit: (event: EmitterEvent, data: EmitterListenerData) => void;
|
|
|
|
}
|
|
|
|
|
2022-10-18 22:04:55 +00:00
|
|
|
interface VendettaObject {
|
|
|
|
patcher: {
|
|
|
|
after: typeof _spitroast.after;
|
|
|
|
before: typeof _spitroast.before;
|
|
|
|
instead: typeof _spitroast.instead;
|
|
|
|
unpatchAll: typeof _spitroast.unpatchAll;
|
2022-10-22 17:59:01 +00:00
|
|
|
};
|
2022-10-18 22:04:55 +00:00
|
|
|
metro: {
|
|
|
|
findByProps: PropsFinder;
|
|
|
|
findByPropsAll: PropsFinderAll;
|
2023-01-30 21:03:16 +00:00
|
|
|
findByDisplayName: (name: string, defaultExp?: boolean) => any;
|
|
|
|
findByDisplayNameAll: (name: string, defaultExp?: boolean) => any[];
|
2022-10-22 17:59:01 +00:00
|
|
|
common: {
|
2022-10-28 17:50:40 +00:00
|
|
|
constants: PropIntellisense<"API_HOST">;
|
|
|
|
channels: PropIntellisense<"getVoiceChannelId">;
|
|
|
|
i18n: PropIntellisense<"Messages">;
|
|
|
|
url: PropIntellisense<"openURL">;
|
|
|
|
toasts: PropIntellisense<"open" | "close">;
|
2022-10-22 17:59:01 +00:00
|
|
|
React: typeof _React;
|
|
|
|
ReactNative: typeof _RN;
|
|
|
|
};
|
|
|
|
};
|
2022-10-28 17:50:40 +00:00
|
|
|
constants: {
|
|
|
|
DISCORD_SERVER: string;
|
|
|
|
GITHUB: string;
|
|
|
|
};
|
|
|
|
utils: {
|
|
|
|
copyText: (content: string) => void;
|
|
|
|
findInReactTree: (tree: { [key: string]: any }, filter: SearchFilter) => void;
|
|
|
|
findInTree: (tree: { [key: string]: any }, filter: SearchFilter, options: FindInTreeOptions) => any;
|
|
|
|
};
|
|
|
|
debug: {
|
|
|
|
connectToDebugger: (url: string) => void;
|
|
|
|
}
|
2022-10-22 22:26:06 +00:00
|
|
|
ui: {
|
2022-10-28 17:50:40 +00:00
|
|
|
components: {
|
2023-01-05 23:07:58 +00:00
|
|
|
Forms: PropIntellisense<"Form" | "FormSection">;
|
|
|
|
General: PropIntellisense<"Button" | "Text" | "View">;
|
2022-10-28 17:50:40 +00:00
|
|
|
}
|
|
|
|
toasts: {
|
|
|
|
showToast: (content: string, asset: number) => void;
|
|
|
|
};
|
2022-10-22 22:26:06 +00:00
|
|
|
assets: {
|
2023-01-07 23:06:36 +00:00
|
|
|
all: Indexable<Asset>;
|
2022-10-22 22:26:06 +00:00
|
|
|
find: (filter: (a: any) => void) => Asset | null | undefined;
|
|
|
|
getAssetByName: (name: string) => Asset;
|
2022-10-22 23:05:04 +00:00
|
|
|
getAssetByID: (id: number) => Asset;
|
2022-10-22 22:26:06 +00:00
|
|
|
getAssetIDByName: (name: string) => number;
|
2022-10-28 17:50:40 +00:00
|
|
|
};
|
2022-10-22 22:26:06 +00:00
|
|
|
};
|
2023-01-08 23:24:00 +00:00
|
|
|
plugins: {
|
|
|
|
plugins: Indexable<Plugin>;
|
2023-01-30 00:40:56 +00:00
|
|
|
fetchPlugin: (id: string, enabled: boolean) => void;
|
2023-01-08 23:27:10 +00:00
|
|
|
evalPlugin: (plugin: Plugin) => void;
|
2023-01-08 23:24:00 +00:00
|
|
|
stopPlugin: (id: string) => void;
|
|
|
|
removePlugin: (id: string) => void;
|
|
|
|
getSettings: (id: string) => JSX.Element;
|
2023-01-25 08:28:48 +00:00
|
|
|
};
|
|
|
|
commands: {
|
|
|
|
registerCommand: (command: ApplicationCommand) => () => void;
|
|
|
|
};
|
2023-01-29 21:05:47 +00:00
|
|
|
storage: {
|
2023-01-30 15:33:33 +00:00
|
|
|
createProxy: <T>(target: T) => { proxy: T, emitter: Emitter };
|
|
|
|
useProxy: <T>(storage: T) => T;
|
|
|
|
createStorage: <T>(storeName: string) => Promise<Awaited<T>>;
|
|
|
|
wrapSync: <T extends Promise<any>>(store: T) => Awaited<T>;
|
|
|
|
awaitSyncWrapper: (store: any) => Promise<void>;
|
2023-01-29 21:05:47 +00:00
|
|
|
};
|
2023-01-10 22:05:40 +00:00
|
|
|
settings: Settings;
|
2022-10-18 22:04:55 +00:00
|
|
|
logger: Logger;
|
2023-01-10 23:30:46 +00:00
|
|
|
version: string;
|
2022-10-18 22:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
declare global {
|
2023-01-03 00:18:19 +00:00
|
|
|
type React = typeof _React;
|
2022-10-18 22:04:55 +00:00
|
|
|
interface Window {
|
|
|
|
[key: PropertyKey]: any;
|
|
|
|
modules: MetroModules;
|
|
|
|
vendetta: VendettaObject;
|
2023-01-03 00:18:19 +00:00
|
|
|
React: typeof _React;
|
2022-10-18 22:04:55 +00:00
|
|
|
}
|
2022-10-22 17:59:01 +00:00
|
|
|
}
|