@mostfeatured/dbi 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DBI.d.ts +4 -1
- package/dist/DBI.d.ts.map +1 -1
- package/dist/DBI.js +106 -49
- package/dist/DBI.js.map +1 -1
- package/dist/Events.d.ts +6 -6
- package/dist/Events.d.ts.map +1 -1
- package/dist/Events.js +1 -1
- package/dist/Events.js.map +1 -1
- package/dist/methods/handleMessageCommands.d.ts.map +1 -1
- package/dist/methods/handleMessageCommands.js +71 -37
- package/dist/methods/handleMessageCommands.js.map +1 -1
- package/dist/methods/hookInteractionListeners.d.ts.map +1 -1
- package/dist/methods/hookInteractionListeners.js +122 -36
- package/dist/methods/hookInteractionListeners.js.map +1 -1
- package/dist/types/ChatInput/ChatInputOptions.d.ts +81 -23
- package/dist/types/ChatInput/ChatInputOptions.d.ts.map +1 -1
- package/dist/types/ChatInput/ChatInputOptions.js +28 -15
- package/dist/types/ChatInput/ChatInputOptions.js.map +1 -1
- package/package.json +1 -1
- package/src/DBI.ts +523 -170
- package/src/Events.ts +68 -21
- package/src/methods/handleMessageCommands.ts +182 -63
- package/src/methods/hookInteractionListeners.ts +155 -60
- package/src/types/ChatInput/ChatInputOptions.ts +213 -36
package/src/DBI.ts
CHANGED
|
@@ -1,30 +1,64 @@
|
|
|
1
|
-
import Discord from "discord.js";
|
|
2
|
-
import {
|
|
1
|
+
import Discord, { MessagePayload } from "discord.js";
|
|
2
|
+
import {
|
|
3
|
+
DBIChatInput,
|
|
4
|
+
TDBIChatInputOmitted,
|
|
5
|
+
} from "./types/ChatInput/ChatInput";
|
|
3
6
|
import { DBIChatInputOptions } from "./types/ChatInput/ChatInputOptions";
|
|
4
7
|
import { publishInteractions } from "./methods/publishInteractions";
|
|
5
8
|
import { ClientEvents, DBIEvent, TDBIEventOmitted } from "./types/Event";
|
|
6
9
|
import { MemoryStore } from "./utils/MemoryStore";
|
|
7
10
|
import { hookInteractionListeners } from "./methods/hookInteractionListeners";
|
|
8
11
|
import { Events } from "./Events";
|
|
9
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
DBILocale,
|
|
14
|
+
TDBILocaleConstructor,
|
|
15
|
+
TDBILocaleString,
|
|
16
|
+
} from "./types/other/Locale";
|
|
10
17
|
import { DBIButton, TDBIButtonOmitted } from "./types/Components/Button";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
import {
|
|
19
|
+
DBIStringSelectMenu,
|
|
20
|
+
TDBIStringSelectMenuOmitted,
|
|
21
|
+
} from "./types/Components/StringSelectMenu";
|
|
22
|
+
import {
|
|
23
|
+
DBIMessageContextMenu,
|
|
24
|
+
TDBIMessageContextMenuOmitted,
|
|
25
|
+
} from "./types/other/MessageContextMenu";
|
|
26
|
+
import {
|
|
27
|
+
DBIUserContextMenu,
|
|
28
|
+
TDBIUserContextMenuOmitted,
|
|
29
|
+
} from "./types/other/UserContextMenu";
|
|
14
30
|
import { hookEventListeners } from "./methods/hookEventListeners";
|
|
15
31
|
import eventMap from "./data/eventMap.json";
|
|
16
32
|
import { DBIModal, TDBIModalOmitted } from "./types/Components/Modal";
|
|
17
33
|
import * as Sharding from "discord-hybrid-sharding";
|
|
18
34
|
import _ from "lodash";
|
|
19
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
DBIInteractionLocale,
|
|
37
|
+
TDBIInteractionLocaleOmitted,
|
|
38
|
+
} from "./types/other/InteractionLocale";
|
|
20
39
|
import { TDBIInteractions } from "./types/Interaction";
|
|
21
40
|
import { NamespaceData, NamespaceEnums } from "../generated/namespaceData";
|
|
22
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
DBICustomEvent,
|
|
43
|
+
TDBICustomEventOmitted,
|
|
44
|
+
} from "./types/other/CustomEvent";
|
|
23
45
|
import aaq from "async-and-quick";
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
46
|
+
import {
|
|
47
|
+
DBIUserSelectMenu,
|
|
48
|
+
TDBIUserSelectMenuOmitted,
|
|
49
|
+
} from "./types/Components/UserSelectMenu";
|
|
50
|
+
import {
|
|
51
|
+
DBIMentionableSelectMenu,
|
|
52
|
+
TDBIMentionableSelectMenuOmitted,
|
|
53
|
+
} from "./types/Components/MentionableSelectMenu";
|
|
54
|
+
import {
|
|
55
|
+
DBIChannelSelectMenu,
|
|
56
|
+
TDBIChannelSelectMenuOmitted,
|
|
57
|
+
} from "./types/Components/ChannelSelectMenu";
|
|
58
|
+
import {
|
|
59
|
+
DBIRoleSelectMenu,
|
|
60
|
+
TDBIRoleSelectMenuOmitted,
|
|
61
|
+
} from "./types/Components/RoleSelectMenu";
|
|
28
62
|
import { handleMessageCommands } from "./methods/handleMessageCommands";
|
|
29
63
|
|
|
30
64
|
export interface DBIStore {
|
|
@@ -34,18 +68,23 @@ export interface DBIStore {
|
|
|
34
68
|
has(key: string): Promise<boolean>;
|
|
35
69
|
}
|
|
36
70
|
|
|
37
|
-
export type DBIClientData<TNamespace extends NamespaceEnums> = {
|
|
71
|
+
export type DBIClientData<TNamespace extends NamespaceEnums> = {
|
|
72
|
+
namespace: NamespaceData[TNamespace]["clientNamespaces"];
|
|
73
|
+
token: string;
|
|
74
|
+
options: Discord.ClientOptions;
|
|
75
|
+
client: Discord.Client<true>;
|
|
76
|
+
};
|
|
38
77
|
|
|
39
78
|
export interface DBIConfig {
|
|
40
79
|
discord: {
|
|
41
|
-
namespace: string
|
|
42
|
-
token: string
|
|
43
|
-
options: Discord.ClientOptions
|
|
80
|
+
namespace: string;
|
|
81
|
+
token: string;
|
|
82
|
+
options: Discord.ClientOptions;
|
|
44
83
|
}[];
|
|
45
84
|
defaults: {
|
|
46
|
-
locale: TDBILocaleString
|
|
47
|
-
directMessages: boolean
|
|
48
|
-
defaultMemberPermissions: Discord.PermissionsString[]
|
|
85
|
+
locale: TDBILocaleString;
|
|
86
|
+
directMessages: boolean;
|
|
87
|
+
defaultMemberPermissions: Discord.PermissionsString[];
|
|
49
88
|
};
|
|
50
89
|
|
|
51
90
|
sharding: "hybrid" | "default" | "off";
|
|
@@ -58,7 +97,7 @@ export interface DBIConfig {
|
|
|
58
97
|
autoClear?: {
|
|
59
98
|
check: number;
|
|
60
99
|
ttl: number;
|
|
61
|
-
}
|
|
100
|
+
};
|
|
62
101
|
};
|
|
63
102
|
|
|
64
103
|
strict: boolean;
|
|
@@ -66,24 +105,29 @@ export interface DBIConfig {
|
|
|
66
105
|
prefixes: string[];
|
|
67
106
|
typeAliases: {
|
|
68
107
|
booleans: Record<string, boolean>;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
108
|
+
};
|
|
109
|
+
};
|
|
71
110
|
}
|
|
72
111
|
|
|
73
112
|
export interface DBIConfigConstructor {
|
|
74
|
-
discord:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
113
|
+
discord:
|
|
114
|
+
| {
|
|
115
|
+
token: string;
|
|
116
|
+
options: Discord.ClientOptions;
|
|
117
|
+
}
|
|
118
|
+
| {
|
|
119
|
+
namespace: string;
|
|
120
|
+
token: string;
|
|
121
|
+
options: Discord.ClientOptions;
|
|
122
|
+
}[];
|
|
82
123
|
|
|
83
124
|
defaults?: {
|
|
84
|
-
locale?: TDBILocaleString
|
|
85
|
-
directMessages?: boolean
|
|
86
|
-
defaultMemberPermissions?: Discord.PermissionsString[]
|
|
125
|
+
locale?: TDBILocaleString;
|
|
126
|
+
directMessages?: boolean;
|
|
127
|
+
defaultMemberPermissions?: Discord.PermissionsString[];
|
|
128
|
+
messageCommands?: {
|
|
129
|
+
deferReplyContent?: MessagePayload | string;
|
|
130
|
+
};
|
|
87
131
|
};
|
|
88
132
|
|
|
89
133
|
sharding?: "hybrid" | "default" | "off";
|
|
@@ -96,13 +140,13 @@ export interface DBIConfigConstructor {
|
|
|
96
140
|
autoClear?: {
|
|
97
141
|
check: number;
|
|
98
142
|
ttl: number;
|
|
99
|
-
}
|
|
143
|
+
};
|
|
100
144
|
};
|
|
101
145
|
|
|
102
146
|
data?: {
|
|
103
147
|
other?: Record<string, any>;
|
|
104
|
-
refs?: Map<string, { at: number
|
|
105
|
-
}
|
|
148
|
+
refs?: Map<string, { at: number; value: any; ttl?: number }>;
|
|
149
|
+
};
|
|
106
150
|
|
|
107
151
|
strict?: boolean;
|
|
108
152
|
|
|
@@ -113,8 +157,8 @@ export interface DBIConfigConstructor {
|
|
|
113
157
|
* Example: {"yes": true, "no": false}
|
|
114
158
|
*/
|
|
115
159
|
booleans?: Record<string, boolean>;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
160
|
+
};
|
|
161
|
+
};
|
|
118
162
|
}
|
|
119
163
|
|
|
120
164
|
export interface DBIRegisterAPI<TNamespace extends NamespaceEnums> {
|
|
@@ -123,20 +167,39 @@ export interface DBIRegisterAPI<TNamespace extends NamespaceEnums> {
|
|
|
123
167
|
Event(cfg: TDBIEventOmitted<TNamespace>): DBIEvent<TNamespace>;
|
|
124
168
|
Locale(cfg: TDBILocaleConstructor<TNamespace>): DBILocale<TNamespace>;
|
|
125
169
|
Button(cfg: TDBIButtonOmitted<TNamespace>): DBIButton<TNamespace>;
|
|
126
|
-
StringSelectMenu(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
170
|
+
StringSelectMenu(
|
|
171
|
+
cfg: TDBIStringSelectMenuOmitted<TNamespace>
|
|
172
|
+
): DBIStringSelectMenu<TNamespace>;
|
|
173
|
+
UserSelectMenu(
|
|
174
|
+
cfg: TDBIUserSelectMenuOmitted<TNamespace>
|
|
175
|
+
): DBIUserSelectMenu<TNamespace>;
|
|
176
|
+
RoleSelectMenu(
|
|
177
|
+
cfg: TDBIRoleSelectMenuOmitted<TNamespace>
|
|
178
|
+
): DBIRoleSelectMenu<TNamespace>;
|
|
179
|
+
ChannelSelectMenu(
|
|
180
|
+
cfg: TDBIChannelSelectMenuOmitted<TNamespace>
|
|
181
|
+
): DBIChannelSelectMenu<TNamespace>;
|
|
182
|
+
MentionableSelectMenu(
|
|
183
|
+
cfg: TDBIMentionableSelectMenuOmitted<TNamespace>
|
|
184
|
+
): DBIMentionableSelectMenu<TNamespace>;
|
|
185
|
+
MessageContextMenu(
|
|
186
|
+
cfg: TDBIMessageContextMenuOmitted<TNamespace>
|
|
187
|
+
): DBIMessageContextMenu<TNamespace>;
|
|
188
|
+
UserContextMenu(
|
|
189
|
+
cfg: TDBIUserContextMenuOmitted<TNamespace>
|
|
190
|
+
): DBIUserContextMenu<TNamespace>;
|
|
133
191
|
InteractionLocale(cfg: TDBIInteractionLocaleOmitted): DBIInteractionLocale;
|
|
134
192
|
Modal(cfg: TDBIModalOmitted<TNamespace>): DBIModal<TNamespace>;
|
|
135
|
-
CustomEvent<T extends keyof NamespaceData[TNamespace]["customEvents"]>(
|
|
193
|
+
CustomEvent<T extends keyof NamespaceData[TNamespace]["customEvents"]>(
|
|
194
|
+
cfg: TDBICustomEventOmitted<TNamespace, T>
|
|
195
|
+
): DBICustomEvent<TNamespace, T>;
|
|
136
196
|
onUnload(cb: () => Promise<any> | any): any;
|
|
137
197
|
}
|
|
138
198
|
|
|
139
|
-
export class DBI<
|
|
199
|
+
export class DBI<
|
|
200
|
+
TNamespace extends NamespaceEnums,
|
|
201
|
+
TOtherData = Record<string, any>
|
|
202
|
+
> {
|
|
140
203
|
namespace: TNamespace;
|
|
141
204
|
config: DBIConfig;
|
|
142
205
|
data: {
|
|
@@ -150,17 +213,17 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
150
213
|
unloaders: Set<() => void>;
|
|
151
214
|
registers: Set<(...args: any[]) => any>;
|
|
152
215
|
registerUnloaders: Set<(...args: any[]) => any>;
|
|
153
|
-
refs: Map<string, { at: number
|
|
154
|
-
clients:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
indexes: Record<string, number
|
|
163
|
-
}
|
|
216
|
+
refs: Map<string, { at: number; value: any; ttl?: number }>;
|
|
217
|
+
clients: DBIClientData<TNamespace>[] & {
|
|
218
|
+
next(key?: string): DBIClientData<TNamespace>;
|
|
219
|
+
random(): DBIClientData<TNamespace>;
|
|
220
|
+
random(size: number): DBIClientData<TNamespace>[];
|
|
221
|
+
first(): DBIClientData<TNamespace>;
|
|
222
|
+
get(
|
|
223
|
+
namespace: NamespaceData[TNamespace]["clientNamespaces"]
|
|
224
|
+
): DBIClientData<TNamespace>;
|
|
225
|
+
indexes: Record<string, number>;
|
|
226
|
+
};
|
|
164
227
|
};
|
|
165
228
|
events: Events<TNamespace>;
|
|
166
229
|
cluster?: Sharding.ClusterClient<Discord.Client>;
|
|
@@ -170,36 +233,41 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
170
233
|
this.namespace = namespace as any;
|
|
171
234
|
const self = this;
|
|
172
235
|
|
|
173
|
-
config.store = config.store as any || new MemoryStore();
|
|
236
|
+
config.store = (config.store as any) || new MemoryStore();
|
|
174
237
|
config.defaults = {
|
|
175
238
|
locale: "en",
|
|
176
239
|
defaultMemberPermissions: [],
|
|
177
240
|
directMessages: false,
|
|
178
|
-
...(config.defaults || {})
|
|
241
|
+
...(config.defaults || {}),
|
|
242
|
+
messageCommands: {
|
|
243
|
+
deferReplyContent: "Loading...",
|
|
244
|
+
...(config.defaults?.messageCommands || {}),
|
|
245
|
+
},
|
|
179
246
|
};
|
|
180
247
|
config.sharding = config.sharding ?? "off";
|
|
181
248
|
config.strict = config.strict ?? true;
|
|
182
249
|
config.references = {
|
|
183
250
|
autoClear: undefined,
|
|
184
|
-
...(config.references || {})
|
|
185
|
-
}
|
|
251
|
+
...(config.references || {}),
|
|
252
|
+
};
|
|
186
253
|
|
|
187
254
|
if (config.messageCommands) {
|
|
188
|
-
if (config.strict && !config.messageCommands?.prefixes?.length)
|
|
255
|
+
if (config.strict && !config.messageCommands?.prefixes?.length)
|
|
256
|
+
throw new Error("No message command prefixes provided.");
|
|
189
257
|
|
|
190
258
|
let { typeAliases } = config.messageCommands;
|
|
191
259
|
|
|
192
260
|
config.messageCommands.typeAliases = {
|
|
193
261
|
booleans: typeAliases.booleans ?? {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
262
|
+
true: true,
|
|
263
|
+
false: false,
|
|
264
|
+
yes: true,
|
|
265
|
+
no: false,
|
|
266
|
+
y: true,
|
|
267
|
+
n: false,
|
|
200
268
|
"1": true,
|
|
201
|
-
"0": false
|
|
202
|
-
}
|
|
269
|
+
"0": false,
|
|
270
|
+
},
|
|
203
271
|
};
|
|
204
272
|
}
|
|
205
273
|
|
|
@@ -220,7 +288,7 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
220
288
|
refs: config.data?.refs ?? new Map(),
|
|
221
289
|
clients: Object.assign([], {
|
|
222
290
|
next(key = "global") {
|
|
223
|
-
this.indexes[key] = ((
|
|
291
|
+
this.indexes[key] = ((this.indexes[key] ?? -1) + 1) % this.length;
|
|
224
292
|
return this[this.indexes[key]];
|
|
225
293
|
},
|
|
226
294
|
random(size?: number) {
|
|
@@ -236,35 +304,47 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
236
304
|
get(namespace: string) {
|
|
237
305
|
return this.find((i: any) => i.namespace === namespace);
|
|
238
306
|
},
|
|
239
|
-
indexes: {}
|
|
240
|
-
}) as any
|
|
241
|
-
}
|
|
307
|
+
indexes: {},
|
|
308
|
+
}) as any,
|
|
309
|
+
};
|
|
242
310
|
|
|
243
311
|
this.events = new Events(this as any);
|
|
244
312
|
|
|
245
|
-
config.discord = Array.isArray(config.discord)
|
|
246
|
-
config.discord
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
313
|
+
config.discord = Array.isArray(config.discord)
|
|
314
|
+
? config.discord
|
|
315
|
+
: [
|
|
316
|
+
{
|
|
317
|
+
token: config.discord.token,
|
|
318
|
+
options: config.discord.options,
|
|
319
|
+
namespace: "default",
|
|
320
|
+
},
|
|
321
|
+
];
|
|
322
|
+
|
|
323
|
+
this.data.clients.push(...(config.discord as any));
|
|
252
324
|
for (let clientContext of this.data.clients) {
|
|
253
325
|
let client = new Discord.Client({
|
|
254
|
-
...(clientContext.options || {}) as any,
|
|
255
|
-
...(config.sharding == "hybrid"
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
326
|
+
...((clientContext.options || {}) as any),
|
|
327
|
+
...(config.sharding == "hybrid"
|
|
328
|
+
? {
|
|
329
|
+
shards: Sharding.getInfo().SHARD_LIST,
|
|
330
|
+
shardCount: Sharding.getInfo().TOTAL_SHARDS,
|
|
331
|
+
}
|
|
332
|
+
: {}),
|
|
259
333
|
});
|
|
260
334
|
clientContext.client = client as Discord.Client<true>;
|
|
261
335
|
}
|
|
262
336
|
|
|
263
337
|
if (this.data.clients.length === 0) throw new Error("No clients provided.");
|
|
264
|
-
if (
|
|
338
|
+
if (
|
|
339
|
+
this.data.clients.length !== 1 &&
|
|
340
|
+
!(config.sharding && config.sharding === "off")
|
|
341
|
+
)
|
|
265
342
|
throw new Error("Sharding only supports 1 client.");
|
|
266
343
|
|
|
267
|
-
this.cluster =
|
|
344
|
+
this.cluster =
|
|
345
|
+
config.sharding == "hybrid"
|
|
346
|
+
? new Sharding.ClusterClient(this.data.clients[0].client)
|
|
347
|
+
: undefined;
|
|
268
348
|
this._loaded = false;
|
|
269
349
|
this._hooked = false;
|
|
270
350
|
}
|
|
@@ -276,39 +356,46 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
276
356
|
this.data.unloaders.add(hookInteractionListeners(this as any));
|
|
277
357
|
this.data.unloaders.add(hookEventListeners(this as any));
|
|
278
358
|
if (typeof this.config.references.autoClear !== "undefined") {
|
|
279
|
-
this.data.unloaders.add(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
359
|
+
this.data.unloaders.add(
|
|
360
|
+
(() => {
|
|
361
|
+
let interval = setInterval(() => {
|
|
362
|
+
this.data.refs.forEach(({ at, ttl }, key) => {
|
|
363
|
+
if (
|
|
364
|
+
Date.now() >
|
|
365
|
+
at + (ttl || this.config.references.autoClear.ttl)
|
|
366
|
+
) {
|
|
367
|
+
this.data.refs.delete(key);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}, this.config.references.autoClear.check);
|
|
371
|
+
return () => {
|
|
372
|
+
clearInterval(interval);
|
|
373
|
+
};
|
|
374
|
+
})()
|
|
375
|
+
);
|
|
291
376
|
}
|
|
292
377
|
if (typeof this.config.messageCommands !== "undefined") {
|
|
293
|
-
this.data.unloaders.add(
|
|
294
|
-
|
|
378
|
+
this.data.unloaders.add(
|
|
379
|
+
(() => {
|
|
380
|
+
const { client } = this.client();
|
|
295
381
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
382
|
+
function onMessage(message: Discord.Message) {
|
|
383
|
+
handleMessageCommands(self as any, message);
|
|
384
|
+
}
|
|
299
385
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
386
|
+
client.on("messageCreate", onMessage);
|
|
387
|
+
return () => {
|
|
388
|
+
client.off("messageCreate", onMessage);
|
|
389
|
+
};
|
|
390
|
+
})()
|
|
391
|
+
);
|
|
305
392
|
}
|
|
306
393
|
}
|
|
307
394
|
|
|
308
395
|
private async _unhookListeners() {
|
|
309
396
|
if (!this._hooked) return;
|
|
310
397
|
this._hooked = false;
|
|
311
|
-
this.data.unloaders.forEach(f => {
|
|
398
|
+
this.data.unloaders.forEach((f) => {
|
|
312
399
|
f();
|
|
313
400
|
});
|
|
314
401
|
}
|
|
@@ -332,117 +419,357 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
332
419
|
for await (const cb of this.data.registers) {
|
|
333
420
|
let ChatInput = function (cfg: DBIChatInput<TNamespace>) {
|
|
334
421
|
let dbiChatInput = new DBIChatInput(self, cfg);
|
|
335
|
-
if (self.data.interactions.has(dbiChatInput.name))
|
|
422
|
+
if (self.data.interactions.has(dbiChatInput.name))
|
|
423
|
+
throw new Error(
|
|
424
|
+
`DBIChatInput "${dbiChatInput.name}" already loaded as "${
|
|
425
|
+
self.data.interactions.get(dbiChatInput.name)?.type
|
|
426
|
+
}"!`
|
|
427
|
+
);
|
|
336
428
|
self.data.interactions.set(dbiChatInput.name, dbiChatInput);
|
|
337
429
|
return dbiChatInput;
|
|
338
430
|
};
|
|
339
|
-
ChatInput = Object.assign(
|
|
431
|
+
ChatInput = Object.assign(
|
|
432
|
+
ChatInput,
|
|
433
|
+
class {
|
|
434
|
+
constructor(...args: any[]) {
|
|
435
|
+
return ChatInput.apply(this, args as any);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
);
|
|
340
439
|
|
|
341
440
|
let Event = function (cfg: TDBIEventOmitted<TNamespace>) {
|
|
342
441
|
let dbiEvent = new DBIEvent(self as any, cfg);
|
|
343
|
-
if (
|
|
442
|
+
if (
|
|
443
|
+
self.config.strict &&
|
|
444
|
+
self.data.events.has(dbiEvent.id || dbiEvent.name)
|
|
445
|
+
)
|
|
446
|
+
throw new Error(
|
|
447
|
+
`DBIEvent "${dbiEvent.id || dbiEvent.name}" already loaded!`
|
|
448
|
+
);
|
|
344
449
|
self.data.events.set(dbiEvent.id || dbiEvent.name, dbiEvent);
|
|
345
450
|
return dbiEvent;
|
|
346
451
|
};
|
|
347
|
-
Event = Object.assign(
|
|
452
|
+
Event = Object.assign(
|
|
453
|
+
Event,
|
|
454
|
+
class {
|
|
455
|
+
constructor(...args: any[]) {
|
|
456
|
+
return Event.apply(this, args as any);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
);
|
|
348
460
|
|
|
349
461
|
let Button = function (cfg: TDBIButtonOmitted<TNamespace>) {
|
|
350
462
|
let dbiButton = new DBIButton(self as any, cfg);
|
|
351
|
-
if (self.config.strict && self.data.interactions.has(dbiButton.name))
|
|
463
|
+
if (self.config.strict && self.data.interactions.has(dbiButton.name))
|
|
464
|
+
throw new Error(
|
|
465
|
+
`DBIButton "${dbiButton.name}" already loaded as "${
|
|
466
|
+
self.data.interactions.get(dbiButton.name)?.type
|
|
467
|
+
}"!`
|
|
468
|
+
);
|
|
352
469
|
self.data.interactions.set(dbiButton.name, dbiButton as any);
|
|
353
470
|
return dbiButton;
|
|
354
471
|
};
|
|
355
|
-
Button = Object.assign(
|
|
472
|
+
Button = Object.assign(
|
|
473
|
+
Button,
|
|
474
|
+
class {
|
|
475
|
+
constructor(...args: any[]) {
|
|
476
|
+
return Button.apply(this, args as any);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
);
|
|
356
480
|
|
|
357
|
-
let StringSelectMenu = function (
|
|
481
|
+
let StringSelectMenu = function (
|
|
482
|
+
cfg: TDBIStringSelectMenuOmitted<TNamespace>
|
|
483
|
+
) {
|
|
358
484
|
let dbiStringSelectMenu = new DBIStringSelectMenu(self as any, cfg);
|
|
359
|
-
if (
|
|
360
|
-
|
|
485
|
+
if (
|
|
486
|
+
self.config.strict &&
|
|
487
|
+
self.data.interactions.has(dbiStringSelectMenu.name)
|
|
488
|
+
)
|
|
489
|
+
throw new Error(
|
|
490
|
+
`DBIStringSelectMenu "${
|
|
491
|
+
dbiStringSelectMenu.name
|
|
492
|
+
}" already loaded as "${
|
|
493
|
+
self.data.interactions.get(dbiStringSelectMenu.name)?.type
|
|
494
|
+
}"!`
|
|
495
|
+
);
|
|
496
|
+
self.data.interactions.set(
|
|
497
|
+
dbiStringSelectMenu.name,
|
|
498
|
+
dbiStringSelectMenu as any
|
|
499
|
+
);
|
|
361
500
|
return dbiStringSelectMenu;
|
|
362
501
|
};
|
|
363
|
-
StringSelectMenu = Object.assign(
|
|
502
|
+
StringSelectMenu = Object.assign(
|
|
503
|
+
StringSelectMenu,
|
|
504
|
+
class {
|
|
505
|
+
constructor(...args: any[]) {
|
|
506
|
+
return StringSelectMenu.apply(this, args as any);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
);
|
|
364
510
|
|
|
365
|
-
let UserSelectMenu = function (
|
|
511
|
+
let UserSelectMenu = function (
|
|
512
|
+
cfg: TDBIUserSelectMenuOmitted<TNamespace>
|
|
513
|
+
) {
|
|
366
514
|
let dbiUserSelectMenu = new DBIUserSelectMenu(self as any, cfg);
|
|
367
|
-
if (
|
|
368
|
-
|
|
515
|
+
if (
|
|
516
|
+
self.config.strict &&
|
|
517
|
+
self.data.interactions.has(dbiUserSelectMenu.name)
|
|
518
|
+
)
|
|
519
|
+
throw new Error(
|
|
520
|
+
`DBIUserSelectMenu "${dbiUserSelectMenu.name}" already loaded as "${
|
|
521
|
+
self.data.interactions.get(dbiUserSelectMenu.name)?.type
|
|
522
|
+
}"!`
|
|
523
|
+
);
|
|
524
|
+
self.data.interactions.set(
|
|
525
|
+
dbiUserSelectMenu.name,
|
|
526
|
+
dbiUserSelectMenu as any
|
|
527
|
+
);
|
|
369
528
|
return dbiUserSelectMenu;
|
|
370
529
|
};
|
|
371
|
-
UserSelectMenu = Object.assign(
|
|
530
|
+
UserSelectMenu = Object.assign(
|
|
531
|
+
UserSelectMenu,
|
|
532
|
+
class {
|
|
533
|
+
constructor(...args: any[]) {
|
|
534
|
+
return UserSelectMenu.apply(this, args as any);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
);
|
|
372
538
|
|
|
373
|
-
let RoleSelectMenu = function (
|
|
539
|
+
let RoleSelectMenu = function (
|
|
540
|
+
cfg: TDBIRoleSelectMenuOmitted<TNamespace>
|
|
541
|
+
) {
|
|
374
542
|
let dbiRoleSelectMenu = new DBIRoleSelectMenu(self as any, cfg);
|
|
375
|
-
if (
|
|
376
|
-
|
|
543
|
+
if (
|
|
544
|
+
self.config.strict &&
|
|
545
|
+
self.data.interactions.has(dbiRoleSelectMenu.name)
|
|
546
|
+
)
|
|
547
|
+
throw new Error(
|
|
548
|
+
`DBIRoleSelectMenu "${dbiRoleSelectMenu.name}" already loaded as "${
|
|
549
|
+
self.data.interactions.get(dbiRoleSelectMenu.name)?.type
|
|
550
|
+
}"!`
|
|
551
|
+
);
|
|
552
|
+
self.data.interactions.set(
|
|
553
|
+
dbiRoleSelectMenu.name,
|
|
554
|
+
dbiRoleSelectMenu as any
|
|
555
|
+
);
|
|
377
556
|
return dbiRoleSelectMenu;
|
|
378
557
|
};
|
|
379
|
-
RoleSelectMenu = Object.assign(
|
|
558
|
+
RoleSelectMenu = Object.assign(
|
|
559
|
+
RoleSelectMenu,
|
|
560
|
+
class {
|
|
561
|
+
constructor(...args: any[]) {
|
|
562
|
+
return RoleSelectMenu.apply(this, args as any);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
);
|
|
380
566
|
|
|
381
|
-
let ChannelSelectMenu = function (
|
|
567
|
+
let ChannelSelectMenu = function (
|
|
568
|
+
cfg: TDBIChannelSelectMenuOmitted<TNamespace>
|
|
569
|
+
) {
|
|
382
570
|
let dbiChannelSelectMenu = new DBIChannelSelectMenu(self as any, cfg);
|
|
383
|
-
if (
|
|
384
|
-
|
|
571
|
+
if (
|
|
572
|
+
self.config.strict &&
|
|
573
|
+
self.data.interactions.has(dbiChannelSelectMenu.name)
|
|
574
|
+
)
|
|
575
|
+
throw new Error(
|
|
576
|
+
`DBIChannelSelectMenu "${
|
|
577
|
+
dbiChannelSelectMenu.name
|
|
578
|
+
}" already loaded as "${
|
|
579
|
+
self.data.interactions.get(dbiChannelSelectMenu.name)?.type
|
|
580
|
+
}"!`
|
|
581
|
+
);
|
|
582
|
+
self.data.interactions.set(
|
|
583
|
+
dbiChannelSelectMenu.name,
|
|
584
|
+
dbiChannelSelectMenu as any
|
|
585
|
+
);
|
|
385
586
|
return dbiChannelSelectMenu;
|
|
386
587
|
};
|
|
387
|
-
ChannelSelectMenu = Object.assign(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
588
|
+
ChannelSelectMenu = Object.assign(
|
|
589
|
+
ChannelSelectMenu,
|
|
590
|
+
class {
|
|
591
|
+
constructor(...args: any[]) {
|
|
592
|
+
return ChannelSelectMenu.apply(this, args as any);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
);
|
|
596
|
+
|
|
597
|
+
let MentionableSelectMenu = function (
|
|
598
|
+
cfg: TDBIMentionableSelectMenuOmitted<TNamespace>
|
|
599
|
+
) {
|
|
600
|
+
let dbiMentionableSelectMenu = new DBIMentionableSelectMenu(
|
|
601
|
+
self as any,
|
|
602
|
+
cfg
|
|
603
|
+
);
|
|
604
|
+
if (
|
|
605
|
+
self.config.strict &&
|
|
606
|
+
self.data.interactions.has(dbiMentionableSelectMenu.name)
|
|
607
|
+
)
|
|
608
|
+
throw new Error(
|
|
609
|
+
`DBIMentionableSelectMenu "${
|
|
610
|
+
dbiMentionableSelectMenu.name
|
|
611
|
+
}" already loaded as "${
|
|
612
|
+
self.data.interactions.get(dbiMentionableSelectMenu.name)?.type
|
|
613
|
+
}"!`
|
|
614
|
+
);
|
|
615
|
+
self.data.interactions.set(
|
|
616
|
+
dbiMentionableSelectMenu.name,
|
|
617
|
+
dbiMentionableSelectMenu as any
|
|
618
|
+
);
|
|
393
619
|
return dbiMentionableSelectMenu;
|
|
394
620
|
};
|
|
395
|
-
MentionableSelectMenu = Object.assign(
|
|
621
|
+
MentionableSelectMenu = Object.assign(
|
|
622
|
+
MentionableSelectMenu,
|
|
623
|
+
class {
|
|
624
|
+
constructor(...args: any[]) {
|
|
625
|
+
return MentionableSelectMenu.apply(this, args as any);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
);
|
|
396
629
|
|
|
397
|
-
let MessageContextMenu = function (
|
|
630
|
+
let MessageContextMenu = function (
|
|
631
|
+
cfg: TDBIMessageContextMenuOmitted<TNamespace>
|
|
632
|
+
) {
|
|
398
633
|
let dbiMessageContextMenu = new DBIMessageContextMenu(self as any, cfg);
|
|
399
|
-
if (
|
|
400
|
-
|
|
634
|
+
if (
|
|
635
|
+
self.config.strict &&
|
|
636
|
+
self.data.interactions.has(dbiMessageContextMenu.name)
|
|
637
|
+
)
|
|
638
|
+
throw new Error(
|
|
639
|
+
`DBIMessageContextMenu "${
|
|
640
|
+
dbiMessageContextMenu.name
|
|
641
|
+
}" already loaded as "${
|
|
642
|
+
self.data.interactions.get(dbiMessageContextMenu.name)?.type
|
|
643
|
+
}"!`
|
|
644
|
+
);
|
|
645
|
+
self.data.interactions.set(
|
|
646
|
+
dbiMessageContextMenu.name,
|
|
647
|
+
dbiMessageContextMenu as any
|
|
648
|
+
);
|
|
401
649
|
return dbiMessageContextMenu;
|
|
402
650
|
};
|
|
403
|
-
MessageContextMenu = Object.assign(
|
|
651
|
+
MessageContextMenu = Object.assign(
|
|
652
|
+
MessageContextMenu,
|
|
653
|
+
class {
|
|
654
|
+
constructor(...args: any[]) {
|
|
655
|
+
return MessageContextMenu.apply(this, args as any);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
);
|
|
404
659
|
|
|
405
|
-
let UserContextMenu = function (
|
|
660
|
+
let UserContextMenu = function (
|
|
661
|
+
cfg: TDBIUserContextMenuOmitted<TNamespace>
|
|
662
|
+
) {
|
|
406
663
|
let dbiUserContextMenu = new DBIUserContextMenu(self as any, cfg);
|
|
407
|
-
if (
|
|
408
|
-
|
|
664
|
+
if (
|
|
665
|
+
self.config.strict &&
|
|
666
|
+
self.data.interactions.has(dbiUserContextMenu.name)
|
|
667
|
+
)
|
|
668
|
+
throw new Error(
|
|
669
|
+
`DBIUserContextMenu "${
|
|
670
|
+
dbiUserContextMenu.name
|
|
671
|
+
}" already loaded as "${
|
|
672
|
+
self.data.interactions.get(dbiUserContextMenu.name)?.type
|
|
673
|
+
}"!`
|
|
674
|
+
);
|
|
675
|
+
self.data.interactions.set(
|
|
676
|
+
dbiUserContextMenu.name,
|
|
677
|
+
dbiUserContextMenu as any
|
|
678
|
+
);
|
|
409
679
|
return dbiUserContextMenu;
|
|
410
680
|
};
|
|
411
|
-
UserContextMenu = Object.assign(
|
|
681
|
+
UserContextMenu = Object.assign(
|
|
682
|
+
UserContextMenu,
|
|
683
|
+
class {
|
|
684
|
+
constructor(...args: any[]) {
|
|
685
|
+
return UserContextMenu.apply(this, args as any);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
);
|
|
412
689
|
|
|
413
690
|
let Modal = function (cfg: TDBIModalOmitted<TNamespace>) {
|
|
414
691
|
let dbiModal = new DBIModal(self as any, cfg);
|
|
415
|
-
if (self.config.strict && self.data.interactions.has(dbiModal.name))
|
|
692
|
+
if (self.config.strict && self.data.interactions.has(dbiModal.name))
|
|
693
|
+
throw new Error(
|
|
694
|
+
`DBIModal "${dbiModal.name}" already loaded as "${
|
|
695
|
+
self.data.interactions.get(dbiModal.name)?.type
|
|
696
|
+
}"!`
|
|
697
|
+
);
|
|
416
698
|
self.data.interactions.set(dbiModal.name, dbiModal as any);
|
|
417
699
|
return dbiModal;
|
|
418
700
|
};
|
|
419
|
-
Modal = Object.assign(
|
|
701
|
+
Modal = Object.assign(
|
|
702
|
+
Modal,
|
|
703
|
+
class {
|
|
704
|
+
constructor(...args: any[]) {
|
|
705
|
+
return Modal.apply(this, args as any);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
);
|
|
420
709
|
|
|
421
710
|
let Locale = function (cfg: TDBILocaleConstructor<TNamespace>) {
|
|
422
711
|
let dbiLocale = new DBILocale(self as any, cfg);
|
|
423
|
-
if (
|
|
424
|
-
|
|
712
|
+
if (
|
|
713
|
+
self.config.strict &&
|
|
714
|
+
self.data.interactionLocales.has(dbiLocale.name)
|
|
715
|
+
)
|
|
716
|
+
throw new Error(`DBILocale "${dbiLocale.name}" already loaded!`);
|
|
717
|
+
if (self.data.locales.has(dbiLocale.name))
|
|
718
|
+
dbiLocale.mergeLocale(self.data.locales.get(dbiLocale.name));
|
|
425
719
|
self.data.locales.set(dbiLocale.name, dbiLocale);
|
|
426
720
|
return dbiLocale;
|
|
427
721
|
};
|
|
428
|
-
Locale = Object.assign(
|
|
722
|
+
Locale = Object.assign(
|
|
723
|
+
Locale,
|
|
724
|
+
class {
|
|
725
|
+
constructor(...args: any[]) {
|
|
726
|
+
return Locale.apply(this, args as any);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
);
|
|
429
730
|
|
|
430
731
|
let CustomEvent = function (cfg: TDBICustomEventOmitted<TNamespace>) {
|
|
431
732
|
let dbiCustomEvent = new DBICustomEvent(self, cfg) as any;
|
|
432
|
-
if (self.config.strict && self.data.eventMap[dbiCustomEvent.name])
|
|
733
|
+
if (self.config.strict && self.data.eventMap[dbiCustomEvent.name])
|
|
734
|
+
throw new Error(
|
|
735
|
+
`DBICustomEvent "${dbiCustomEvent.name}" already loaded!`
|
|
736
|
+
);
|
|
433
737
|
self.data.eventMap[dbiCustomEvent.name] = dbiCustomEvent.map;
|
|
434
738
|
self.data.customEventNames.add(dbiCustomEvent.name);
|
|
435
739
|
return dbiCustomEvent;
|
|
436
740
|
};
|
|
437
|
-
CustomEvent = Object.assign(
|
|
741
|
+
CustomEvent = Object.assign(
|
|
742
|
+
CustomEvent,
|
|
743
|
+
class {
|
|
744
|
+
constructor(...args: any[]) {
|
|
745
|
+
return CustomEvent.apply(this, args as any);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
);
|
|
438
749
|
|
|
439
750
|
let InteractionLocale = function (cfg: TDBIInteractionLocaleOmitted) {
|
|
440
751
|
let dbiInteractionLocale = new DBIInteractionLocale(self, cfg);
|
|
441
|
-
if (
|
|
442
|
-
|
|
752
|
+
if (
|
|
753
|
+
self.config.strict &&
|
|
754
|
+
self.data.interactionLocales.has(dbiInteractionLocale.name)
|
|
755
|
+
)
|
|
756
|
+
throw new Error(
|
|
757
|
+
`DBIInteractionLocale "${dbiInteractionLocale.name}" already loaded!`
|
|
758
|
+
);
|
|
759
|
+
self.data.interactionLocales.set(
|
|
760
|
+
dbiInteractionLocale.name,
|
|
761
|
+
dbiInteractionLocale
|
|
762
|
+
);
|
|
443
763
|
return dbiInteractionLocale;
|
|
444
764
|
};
|
|
445
|
-
InteractionLocale = Object.assign(
|
|
765
|
+
InteractionLocale = Object.assign(
|
|
766
|
+
InteractionLocale,
|
|
767
|
+
class {
|
|
768
|
+
constructor(...args: any[]) {
|
|
769
|
+
return InteractionLocale.apply(this, args as any);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
);
|
|
446
773
|
|
|
447
774
|
await cb({
|
|
448
775
|
ChatInput,
|
|
@@ -468,38 +795,59 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
468
795
|
self.data.interactions.sort((a, b) => b.name.length - a.name.length);
|
|
469
796
|
}
|
|
470
797
|
|
|
471
|
-
emit<
|
|
472
|
-
|
|
798
|
+
emit<
|
|
799
|
+
TEventName extends keyof (NamespaceData[TNamespace]["customEvents"] &
|
|
800
|
+
ClientEvents)
|
|
801
|
+
>(
|
|
802
|
+
name: TEventName,
|
|
803
|
+
args: (NamespaceData[TNamespace]["customEvents"] & ClientEvents)[TEventName]
|
|
804
|
+
): void {
|
|
805
|
+
this.data.clients.forEach((d) =>
|
|
806
|
+
d.client.emit(name as any, { ...args, _DIRECT_: true } as any)
|
|
807
|
+
);
|
|
473
808
|
}
|
|
474
809
|
|
|
475
810
|
/**
|
|
476
811
|
* this.data.interactions.get(name)
|
|
477
812
|
*/
|
|
478
|
-
interaction<
|
|
813
|
+
interaction<
|
|
814
|
+
TInteractionName extends keyof NamespaceData[TNamespace]["interactionMapping"]
|
|
815
|
+
>(
|
|
816
|
+
name: TInteractionName
|
|
817
|
+
): NamespaceData[TNamespace]["interactionMapping"][TInteractionName] {
|
|
479
818
|
return this.data.interactions.get(name as any) as any;
|
|
480
819
|
}
|
|
481
820
|
|
|
482
|
-
client<TClientName extends NamespaceData[TNamespace]["clientNamespaces"]>(
|
|
821
|
+
client<TClientName extends NamespaceData[TNamespace]["clientNamespaces"]>(
|
|
822
|
+
name?: TClientName
|
|
823
|
+
): DBIClientData<TNamespace> {
|
|
483
824
|
return name ? this.data.clients.get(name) : this.data.clients.first();
|
|
484
825
|
}
|
|
485
826
|
/**
|
|
486
827
|
* this.data.events.get(name)
|
|
487
828
|
*/
|
|
488
|
-
event<TEventName extends NamespaceData[TNamespace]["eventNames"]>(
|
|
829
|
+
event<TEventName extends NamespaceData[TNamespace]["eventNames"]>(
|
|
830
|
+
name: TEventName
|
|
831
|
+
): DBIEvent<TNamespace> {
|
|
489
832
|
return this.data.events.get(name);
|
|
490
833
|
}
|
|
491
834
|
|
|
492
835
|
/**
|
|
493
836
|
* this.data.locales.get(name)
|
|
494
837
|
*/
|
|
495
|
-
locale<TLocaleName extends NamespaceData[TNamespace]["localeNames"]>(
|
|
838
|
+
locale<TLocaleName extends NamespaceData[TNamespace]["localeNames"]>(
|
|
839
|
+
name: TLocaleName
|
|
840
|
+
): DBILocale<TNamespace> {
|
|
496
841
|
return this.data.locales.get(name) as any;
|
|
497
842
|
}
|
|
498
843
|
|
|
499
844
|
/**
|
|
500
845
|
* Shorthands for modifying `dbi.data.other`
|
|
501
846
|
*/
|
|
502
|
-
get<K extends keyof TOtherData>(
|
|
847
|
+
get<K extends keyof TOtherData>(
|
|
848
|
+
k: K,
|
|
849
|
+
defaultValue?: TOtherData[K]
|
|
850
|
+
): TOtherData[K] {
|
|
503
851
|
if (defaultValue && !this.has(k as any)) {
|
|
504
852
|
this.set(k, defaultValue);
|
|
505
853
|
return defaultValue;
|
|
@@ -530,7 +878,9 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
530
878
|
|
|
531
879
|
async login(): Promise<any> {
|
|
532
880
|
await aaq.quickForEach(this.data.clients, async (clientContext) => {
|
|
533
|
-
await clientContext.client.login(
|
|
881
|
+
await clientContext.client.login(
|
|
882
|
+
this.config.sharding == "default" ? null : clientContext.token
|
|
883
|
+
);
|
|
534
884
|
});
|
|
535
885
|
}
|
|
536
886
|
|
|
@@ -562,7 +912,12 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
562
912
|
async publish(type: "Guild", guildId: string, clear?: boolean): Promise<any>;
|
|
563
913
|
|
|
564
914
|
async publish(...args: any[]) {
|
|
565
|
-
let interactions = this.data.interactions.filter(
|
|
915
|
+
let interactions = this.data.interactions.filter(
|
|
916
|
+
(i) =>
|
|
917
|
+
i.type == "ChatInput" ||
|
|
918
|
+
i.type == "MessageContextMenu" ||
|
|
919
|
+
i.type == "UserContextMenu"
|
|
920
|
+
) as any;
|
|
566
921
|
switch (args[0]) {
|
|
567
922
|
case "Global": {
|
|
568
923
|
return await publishInteractions(
|
|
@@ -583,6 +938,4 @@ export class DBI<TNamespace extends NamespaceEnums, TOtherData = Record<string,
|
|
|
583
938
|
}
|
|
584
939
|
}
|
|
585
940
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
}
|
|
941
|
+
}
|