-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbdapi.d.ts
307 lines (279 loc) · 10.9 KB
/
bdapi.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
interface Plugin {
getName(): string;
getAuthor(): string;
getDescription(): string;
getVersion(): string;
start(): Function;
stop(): Function;
}
interface Theme {
added: number;
author: string;
css: string;
version: string;
description: string;
filename: string;
format: string;
modified: number;
size: number;
}
interface PatcherCallback {
(thisObject: ThisType<Patcher>, methodArguments: Parameters<()=>any>, returnValue: any): void
}
interface ModuleFilter {
(module: any): boolean
}
interface PatcherOptions {
displayName?: string;
type: "before"|"after"|"instead";
forcePatch: boolean;
}
interface Patcher {
/**
* Patches a function with his this scope, arguments and returnValue.
* @param caller Caller parameter for loggin and unpatch functions. Required.
* @param module Any module you want to patch
* @param moduleName The name of the module you want to patch
* @param Callback Function what get executed before/after/instead when that function runs.
* @param options Options for the patcher eg. the type.
* @returns Function to cancel the patch
*/
patch(caller: string, module: object|Function, moduleName: string, callback: PatcherCallback, options: PatcherOptions): Function;
/**
* Alias for the `Patcher.patch` function. Automatically adds the `{type: "before"}` to the patcher function.
* @param caller Caller parameter
* @param caller Caller parameter for loggin and unpatch functions. Required.
* @param module Any module you want to patch
* @param moduleName The name of the module you want to patch
* @param Callback Function what get executed before/after/instead when that function runs.
* @param options Options for the patcher eg. the type.
* @returns Function to cancel the patch
*/
before(caller: string, module: object|Function, moduleName: string, callback: PatcherCallback, options?: PatcherOptions): Function
/**
* Alias for the `Patcher.patch` function. Automatically adds the `{type: "after"}` to the patcher function.
* @param caller Caller parameter
* @param caller Caller parameter for loggin and unpatch functions. Required.
* @param module Any module you want to patch
* @param moduleName The name of the module you want to patch
* @param Callback Function what get executed before/after/instead when that function runs.
* @param options Options for the patcher eg. the type.
* @returns Function to cancel the patch
*/
after(caller: string, module: object|Function, moduleName: string, callback: PatcherCallback, options?: PatcherOptions): Function;
/**
* Alias for the `Patcher.patch` function. Automatically adds the `{type: "instead"}` to the patcher function.
* @param caller Caller parameter
* @param caller Caller parameter for loggin and unpatch functions. Required.
* @param module Any module you want to patch
* @param moduleName The name of the module you want to patch
* @param Callback Function what get executed before/after/instead when that function runs.
* @param options Options for the patcher eg. the type.
* @returns Function to cancel the patch
*/
after(caller: string, module: object|Function, moduleName: string, callback: PatcherCallback, options?: PatcherOptions): Function;
}
interface Themes {
/**
* Gets the meta of the theme you requsted.
* @param themeName The name of the theme ou want. for example: ZeresPluginLibrary
*/
get(themeName: string): Theme;
/**
* Returns al list with all themes that are loaded.
*/
getAll(): Theme[];
/**
* Disables the theme that was found with the name you given.
* @param themeName The name of the theme you want to disable. for example: ClearVersion
*/
disable(themeName: string): void;
/**
* Enables the theme that was found with the name you given.
* @param themeName The name of the theme you want to disable. for example: ClearVersion
*/
enable(themeName: string): void;
/**
* Checks of the requested theme is enabled.
* @param themeName The name of the theme you want to enable.
*/
isEnanled(themeName: string): boolean;
/**
* Reloads the theme with the name.
* @param themeName The name of the theme you want to reload.
*/
reload(themeName: string): void;
/**
* Toggles the state of the theme with that name.
* @param themeName The name of the theme you want to toggle his state. (enabled/disabled).
*/
toggle(themeName: string): void
/**
* The themes folder where all bd themes are located.
*/
folder: string
}
interface Plugins {
/**
* Gets the instance of the requested plugin.
* @param pluginName The name of the plugin ou want. for example: ZeresPluginLibrary
*/
get(pluginName: string): Plugin;
/**
* Returns al list with all plugins that are loaded.
*/
getAll(): Plugin[];
/**
* Disables the plugin that was found with the name you given.
* @param pluginName The name of the plugin you want to disable. for example: ZeresPluginLibrary
*/
disable(pluginName: string): void;
/**
* Enables the plugin that was found with the name you given.
* @param pluginName The name of the plugin you want to enable. for example:: ZeresPluginLibrary
*/
enable(pluginName: string): void;
/**
* Checks of the requested plugin is enabled.
* @param pluginName The name of the plugin which you're aksing for.
*/
isEnabled(pluginName: string): boolean;
/**
* Reloads the plugin with the name.
* @param pluginName The name of the plugin you want to reload.
*/
reload(pluginName: string): void;
/**
* Toggles the state of the plugin with that name.
* @param pluginName The name of the plugin you want to toggle his state. (enabled/disabled).
*/
toggle(pluginName: string): void
/**
* The plugins folder where all bd plugins are located.
*/
folder: string
}
interface ConfirmModalOptions {
onConfirm?: () => void
onCancel?: () => void
danger?: boolean
confirmText?: string
cancelText?: string
}
declare namespace BdApi {
/**
* Saves the config data for plugins.
* @param pluginName Name of the plugin for the config file, will be completed to **PLUGINNAME.config.json**
* @param key key for the data
* @param data Defines under which category the data should be saved.
*/
function saveData(pluginName: string, key: string, data: any): void;
/**
* Loads the config data for plugins.
* @param pluginName Name of the plugin for the config file, will be completed to **PLUGINNAME.config.json**
* @param key the category you want to load. For example "settings"
*/
function loadData(pluginName: string, key: string): any;
/**
* Alias for `BdApi.saveData`, saves the config data for plugins.
* @param pluginName Name of the plugin for the config file, will be completed to **PLUGINNAME.config.json**
* @param key key for the data
* @param data Defines under which category the data should be saved.
*/
function setData(pluginName: string, key: string, data: any): void;
/**
* Alias for `BdApi.loadData`, loads the config data for plugins.
* @param pluginName Name of the plugin for the config file, will be completed to **PLUGINNAME.config.json**
* @param key the category you want to get. For example "settings"
*/
function getData(pluginName: string, key: string): any;
/**
* Deletes a propety in the plugin configfile.
* @param pluginName Name of the plugin, will be completed to PLUGINNAME.config.json
* @param key The key in the configfile object.
*/
function deleteData(pluginName: string, key: string): void;
/**
* Injects CSS stylesheet into discord's dom tree.
* @param styleId Id to clear the stylesheet
* @param css The css stylesheet which should be loaded.
*/
function injectCSS(styleId: string, css: string): void;
/**
* Clears the stylesheet of plugins.
* @param styleId Id of the styleelement
*/
function clearCSS(styleId: string): void;
/**
* Opens a alert modal with a title and body in the discord client.
* @param title The title of the alert modal.
* @param body The body of the alert modal.
* @returns Modal id.
*/
function alert(title: string|any, body: string|any): string
/**
* Find any module of discord's internal modules.
* @param filter function which process the module and returns true/false if the modules is the right one.
*/
function findModule(filter: ModuleFilter): any|void;
/**
* Find all modules of discord's internal modules that matches the filter.
* @param filter function which process the module and returns true/false if the modules is the right one.
*/
function findAllModules(filter: ModuleFilter): any[];
/**
* Returns any found module by his keys or undefined.
* @param properties A list of keys the module has. for example you search for the module with `{name, get, put}` you put as filter `BdApi.findModuleByProps("name", "get");`
*/
function findModuleByProps(...properties: string[]): any|void;
/**
* Returns any found module/function with that displayName.
* @param displayName Displayname of the function.
*/
function findModuleByDisplayName(displayName: string): any;
/**
* Show a confirmation modal in discord that the user can agree or cancel.
* @param title Title for the confirm modal
* @param body Body for the confirm modal
* @param options Options for the modal. See autocomplete for entries.
*/
function showConfirmationModal(title: any, body: any, options: ConfirmModalOptions): string;
/**
* Returns any module that was found by his prototype keys.
* @param prototypes Prototype keys of the module.
*/
function findModuleByPrototypes(...prototypes: string[]): any|void;
const Patcher: Patcher;
/**
* Plugin API to control plugins.
*/
const Plugins: Plugins
/**
* Theme API to control themes.
*/
const Themes: Themes;
/**
* Instance of React.
*/
const React: typeof import("react");
/**
* Instance of ReactDOM.
*/
const ReactDOM: typeof import("react-dom");
/**
* BD's current version.
*/
const version: string;
/**
* Path to discord's window config file.
*/
const WindowConfigFile: string;
function monkeyPatch(module: any, functionName: string, options: {
before: ({returnValue: any, methodArguments: IArguments}) => any,
after: ({returnValue: any, methodArguments: IArguments}) => any,
instead: ({returnValue: any, methodArguments: IArguments}) => any;
}): () => void;
}
declare module "betterdiscord/api" {
export default BdApi;
}