kythia-core 0.12.4-beta → 0.12.5-beta
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/Kythia.js +0 -5
- package/dist/Kythia.js.map +1 -1
- package/dist/KythiaClient.d.ts.map +1 -1
- package/dist/KythiaClient.js +7 -0
- package/dist/KythiaClient.js.map +1 -1
- package/dist/cli/commands/MakeMigrationCommand.js +1 -1
- package/dist/cli/commands/MakeModelCommand.js +1 -1
- package/dist/managers/AddonManager.d.ts.map +1 -1
- package/dist/managers/AddonManager.js +95 -45
- package/dist/managers/AddonManager.js.map +1 -1
- package/dist/managers/EventManager.d.ts.map +1 -1
- package/dist/managers/EventManager.js +73 -26
- package/dist/managers/EventManager.js.map +1 -1
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +198 -134
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/MiddlewareManager.d.ts.map +1 -1
- package/dist/managers/MiddlewareManager.js +64 -35
- package/dist/managers/MiddlewareManager.js.map +1 -1
- package/dist/managers/ShutdownManager.d.ts.map +1 -1
- package/dist/managers/ShutdownManager.js +109 -81
- package/dist/managers/ShutdownManager.js.map +1 -1
- package/dist/managers/TelemetryManager.d.ts.map +1 -1
- package/dist/managers/TelemetryManager.js +98 -52
- package/dist/managers/TelemetryManager.js.map +1 -1
- package/dist/managers/TranslatorManager.d.ts +1 -0
- package/dist/managers/TranslatorManager.d.ts.map +1 -1
- package/dist/managers/TranslatorManager.js +78 -61
- package/dist/managers/TranslatorManager.js.map +1 -1
- package/dist/utils/InteractionFactory.d.ts.map +1 -1
- package/dist/utils/InteractionFactory.js +305 -281
- package/dist/utils/InteractionFactory.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,308 +3,332 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InteractionFactory = void 0;
|
|
4
4
|
exports.InteractionFactory = {
|
|
5
5
|
create(message, commandName, rawArgsString) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(opt.
|
|
24
|
-
opt.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
try {
|
|
7
|
+
let replied = false;
|
|
8
|
+
let deferred = false;
|
|
9
|
+
let replyMessage = null;
|
|
10
|
+
const followUpMessages = [];
|
|
11
|
+
const argsPattern = /([^\s"]+|"[^"]*")+/g;
|
|
12
|
+
const rawTokens = rawArgsString.match(argsPattern)?.map((t) => t.replace(/^"|"$/g, '')) ||
|
|
13
|
+
[];
|
|
14
|
+
const client = message.client;
|
|
15
|
+
const targetCommand = client.commands?.get(commandName);
|
|
16
|
+
let resolvedGroup = null;
|
|
17
|
+
let resolvedSubcommand = null;
|
|
18
|
+
const resolvedOptions = [];
|
|
19
|
+
const remainingArgs = [...rawTokens];
|
|
20
|
+
let currentSchema = targetCommand?.slashCommand || targetCommand?.data;
|
|
21
|
+
if (remainingArgs.length > 0 && currentSchema?.options) {
|
|
22
|
+
const potentialGroup = remainingArgs[0].toLowerCase();
|
|
23
|
+
const groupOption = currentSchema.options.find((opt) => opt.name === potentialGroup &&
|
|
24
|
+
(opt.type === 2 ||
|
|
25
|
+
opt.constructor.name === 'SlashCommandSubcommandGroupBuilder'));
|
|
26
|
+
if (groupOption) {
|
|
27
|
+
resolvedGroup = potentialGroup;
|
|
28
|
+
remainingArgs.shift();
|
|
29
|
+
currentSchema = groupOption;
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
if (remainingArgs.length > 0) {
|
|
33
|
+
const potentialSub = remainingArgs[0].toLowerCase();
|
|
34
|
+
const subOptionsSource = currentSchema?.options || [];
|
|
35
|
+
const subOption = subOptionsSource.find((opt) => opt.name === potentialSub &&
|
|
36
|
+
(opt.type === 1 ||
|
|
37
|
+
opt.constructor.name === 'SlashCommandSubcommandBuilder'));
|
|
38
|
+
if (resolvedGroup || subOption) {
|
|
39
|
+
resolvedSubcommand = potentialSub;
|
|
40
|
+
remainingArgs.shift();
|
|
41
|
+
currentSchema = subOption;
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
const optionsMap = new Map();
|
|
45
|
+
const availableOptions = currentSchema?.options?.filter((opt) => opt.type !== 1 &&
|
|
46
|
+
opt.type !== 2 &&
|
|
47
|
+
opt.constructor.name !== 'SlashCommandSubcommandBuilder' &&
|
|
48
|
+
opt.constructor.name !== 'SlashCommandSubcommandGroupBuilder') || [];
|
|
49
|
+
let positionalIndex = 0;
|
|
50
|
+
const guessType = (val) => {
|
|
51
|
+
if (!Number.isNaN(Number(val)))
|
|
52
|
+
return 3;
|
|
53
|
+
if (val === 'true' || val === 'false')
|
|
54
|
+
return 5;
|
|
51
55
|
return 3;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (arg.includes(':')) {
|
|
58
|
-
const [key, ...valParts] = arg.split(':');
|
|
59
|
-
const val = valParts.join(':');
|
|
60
|
-
resolvedOptions.push({
|
|
61
|
-
name: key.toLowerCase(),
|
|
62
|
-
value: val,
|
|
63
|
-
type: guessType(val),
|
|
64
|
-
});
|
|
65
|
-
optionsMap.set(key.toLowerCase(), val);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
if (positionalIndex < availableOptions.length) {
|
|
69
|
-
const targetOption = availableOptions[positionalIndex];
|
|
56
|
+
};
|
|
57
|
+
remainingArgs.forEach((arg) => {
|
|
58
|
+
if (arg.includes(':')) {
|
|
59
|
+
const [key, ...valParts] = arg.split(':');
|
|
60
|
+
const val = valParts.join(':');
|
|
70
61
|
resolvedOptions.push({
|
|
71
|
-
name:
|
|
72
|
-
value:
|
|
73
|
-
type:
|
|
62
|
+
name: key.toLowerCase(),
|
|
63
|
+
value: val,
|
|
64
|
+
type: guessType(val),
|
|
74
65
|
});
|
|
75
|
-
optionsMap.set(
|
|
76
|
-
positionalIndex++;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const resolveUser = (val) => {
|
|
81
|
-
if (!val)
|
|
82
|
-
return null;
|
|
83
|
-
const id = val.replace(/[<@!>]/g, '');
|
|
84
|
-
return message.client.users.cache.get(id) || null;
|
|
85
|
-
};
|
|
86
|
-
const resolveMember = (val) => {
|
|
87
|
-
const user = resolveUser(val);
|
|
88
|
-
return user ? message.guild?.members.cache.get(user.id) || null : null;
|
|
89
|
-
};
|
|
90
|
-
const resolveChannel = (val) => {
|
|
91
|
-
if (!val)
|
|
92
|
-
return null;
|
|
93
|
-
const id = val.replace(/[<#>]/g, '');
|
|
94
|
-
return message.guild?.channels.cache.get(id) || null;
|
|
95
|
-
};
|
|
96
|
-
const resolveRole = (val) => {
|
|
97
|
-
if (!val)
|
|
98
|
-
return null;
|
|
99
|
-
const id = val.replace(/[<@&>]/g, '');
|
|
100
|
-
return message.guild?.roles.cache.get(id) || null;
|
|
101
|
-
};
|
|
102
|
-
const interaction = {
|
|
103
|
-
type: 2,
|
|
104
|
-
id: message.id,
|
|
105
|
-
applicationId: message.client.application?.id,
|
|
106
|
-
channelId: message.channel.id,
|
|
107
|
-
guildId: message.guild?.id,
|
|
108
|
-
user: message.author,
|
|
109
|
-
member: message.member,
|
|
110
|
-
guild: message.guild,
|
|
111
|
-
channel: message.channel,
|
|
112
|
-
client: message.client,
|
|
113
|
-
commandName: commandName,
|
|
114
|
-
commandType: 1,
|
|
115
|
-
commandId: message.id,
|
|
116
|
-
commandGuildId: message.guild?.id || null,
|
|
117
|
-
get responded() {
|
|
118
|
-
return replied || deferred;
|
|
119
|
-
},
|
|
120
|
-
get deferred() {
|
|
121
|
-
return deferred;
|
|
122
|
-
},
|
|
123
|
-
get replied() {
|
|
124
|
-
return replied;
|
|
125
|
-
},
|
|
126
|
-
set deferred(v) {
|
|
127
|
-
deferred = v;
|
|
128
|
-
},
|
|
129
|
-
set replied(v) {
|
|
130
|
-
replied = v;
|
|
131
|
-
},
|
|
132
|
-
createdTimestamp: message.createdTimestamp,
|
|
133
|
-
get createdAt() {
|
|
134
|
-
return new Date(message.createdTimestamp);
|
|
135
|
-
},
|
|
136
|
-
locale: message.guild?.preferredLocale || 'en-US',
|
|
137
|
-
guildLocale: message.guild?.preferredLocale || 'en-US',
|
|
138
|
-
deferReply: async (opts) => {
|
|
139
|
-
if (replied || deferred)
|
|
140
|
-
throw new Error('Already replied/deferred');
|
|
141
|
-
deferred = true;
|
|
142
|
-
replyMessage = await message.channel
|
|
143
|
-
.send({ content: '⏳ ...', ...opts })
|
|
144
|
-
.catch(() => null);
|
|
145
|
-
return replyMessage;
|
|
146
|
-
},
|
|
147
|
-
editReply: async (opts) => {
|
|
148
|
-
const options = typeof opts === 'string' ? { content: opts } : opts;
|
|
149
|
-
if (replyMessage && replyMessage.content === '⏳ ...') {
|
|
150
|
-
await replyMessage.delete().catch(() => { });
|
|
151
|
-
replyMessage = await message.channel
|
|
152
|
-
.send(options)
|
|
153
|
-
.catch(() => null);
|
|
154
|
-
}
|
|
155
|
-
else if (replyMessage) {
|
|
156
|
-
replyMessage = await replyMessage
|
|
157
|
-
.edit(options)
|
|
158
|
-
.catch(() => null);
|
|
66
|
+
optionsMap.set(key.toLowerCase(), val);
|
|
159
67
|
}
|
|
160
68
|
else {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
.
|
|
69
|
+
if (positionalIndex < availableOptions.length) {
|
|
70
|
+
const targetOption = availableOptions[positionalIndex];
|
|
71
|
+
resolvedOptions.push({
|
|
72
|
+
name: targetOption.name.toLowerCase(),
|
|
73
|
+
value: arg,
|
|
74
|
+
type: targetOption.type || guessType(arg),
|
|
75
|
+
});
|
|
76
|
+
optionsMap.set(targetOption.name.toLowerCase(), arg);
|
|
77
|
+
positionalIndex++;
|
|
78
|
+
}
|
|
164
79
|
}
|
|
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
|
-
|
|
80
|
+
});
|
|
81
|
+
const resolveUser = (val) => {
|
|
82
|
+
if (!val)
|
|
83
|
+
return null;
|
|
84
|
+
const id = val.replace(/[<@!>]/g, '');
|
|
85
|
+
return message.client.users.cache.get(id) || null;
|
|
86
|
+
};
|
|
87
|
+
const resolveMember = (val) => {
|
|
88
|
+
const user = resolveUser(val);
|
|
89
|
+
return user ? message.guild?.members.cache.get(user.id) || null : null;
|
|
90
|
+
};
|
|
91
|
+
const resolveChannel = (val) => {
|
|
92
|
+
if (!val)
|
|
93
|
+
return null;
|
|
94
|
+
const id = val.replace(/[<#>]/g, '');
|
|
95
|
+
return message.guild?.channels.cache.get(id) || null;
|
|
96
|
+
};
|
|
97
|
+
const resolveRole = (val) => {
|
|
98
|
+
if (!val)
|
|
99
|
+
return null;
|
|
100
|
+
const id = val.replace(/[<@&>]/g, '');
|
|
101
|
+
return message.guild?.roles.cache.get(id) || null;
|
|
102
|
+
};
|
|
103
|
+
const interaction = {
|
|
104
|
+
type: 2,
|
|
105
|
+
id: message.id,
|
|
106
|
+
applicationId: message.client.application?.id,
|
|
107
|
+
channelId: message.channel.id,
|
|
108
|
+
guildId: message.guild?.id,
|
|
109
|
+
user: message.author,
|
|
110
|
+
member: message.member,
|
|
111
|
+
guild: message.guild,
|
|
112
|
+
channel: message.channel,
|
|
192
113
|
client: message.client,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
attachments: new Map(),
|
|
200
|
-
messages: new Map(),
|
|
201
|
-
},
|
|
202
|
-
_group: resolvedGroup,
|
|
203
|
-
_subcommand: resolvedSubcommand,
|
|
204
|
-
_hoistedOptions: resolvedOptions,
|
|
205
|
-
get: (name, required) => {
|
|
206
|
-
const opt = resolvedOptions.find((o) => o.name === name.toLowerCase());
|
|
207
|
-
if (required && !opt)
|
|
208
|
-
throw new Error(`Option "${name}" required`);
|
|
209
|
-
return opt || null;
|
|
210
|
-
},
|
|
211
|
-
getSubcommand: (required) => {
|
|
212
|
-
if (required && !resolvedSubcommand)
|
|
213
|
-
throw new Error('Subcommand required');
|
|
214
|
-
return resolvedSubcommand;
|
|
114
|
+
commandName: commandName,
|
|
115
|
+
commandType: 1,
|
|
116
|
+
commandId: message.id,
|
|
117
|
+
commandGuildId: message.guild?.id || null,
|
|
118
|
+
get responded() {
|
|
119
|
+
return replied || deferred;
|
|
215
120
|
},
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
throw new Error('Group required');
|
|
219
|
-
return resolvedGroup;
|
|
121
|
+
get deferred() {
|
|
122
|
+
return deferred;
|
|
220
123
|
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (required && v === undefined)
|
|
224
|
-
throw new Error(`Option "${name}" required`);
|
|
225
|
-
return v || null;
|
|
124
|
+
get replied() {
|
|
125
|
+
return replied;
|
|
226
126
|
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (required && v === undefined)
|
|
230
|
-
throw new Error(`Option "${name}" required`);
|
|
231
|
-
return v ? v === 'true' || v === '1' : null;
|
|
127
|
+
set deferred(v) {
|
|
128
|
+
deferred = v;
|
|
232
129
|
},
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (required && v === undefined)
|
|
236
|
-
throw new Error(`Option "${name}" required`);
|
|
237
|
-
return v ? parseInt(v, 10) : null;
|
|
130
|
+
set replied(v) {
|
|
131
|
+
replied = v;
|
|
238
132
|
},
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
throw new Error(`Option "${name}" required`);
|
|
243
|
-
return v ? parseFloat(v) : null;
|
|
133
|
+
createdTimestamp: message.createdTimestamp,
|
|
134
|
+
get createdAt() {
|
|
135
|
+
return new Date(message.createdTimestamp);
|
|
244
136
|
},
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
throw new Error(`Option "${name}" required`);
|
|
256
|
-
return c;
|
|
137
|
+
locale: message.guild?.preferredLocale || 'en-US',
|
|
138
|
+
guildLocale: message.guild?.preferredLocale || 'en-US',
|
|
139
|
+
deferReply: async (opts) => {
|
|
140
|
+
if (replied || deferred)
|
|
141
|
+
throw new Error('Already replied/deferred');
|
|
142
|
+
deferred = true;
|
|
143
|
+
replyMessage = await message.channel
|
|
144
|
+
.send({ content: '⏳ ...', ...opts })
|
|
145
|
+
.catch(() => null);
|
|
146
|
+
return replyMessage;
|
|
257
147
|
},
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
|
|
148
|
+
editReply: async (opts) => {
|
|
149
|
+
const options = typeof opts === 'string' ? { content: opts } : opts;
|
|
150
|
+
if (replyMessage && replyMessage.content === '⏳ ...') {
|
|
151
|
+
await replyMessage.delete().catch(() => { });
|
|
152
|
+
replyMessage = await message.channel
|
|
153
|
+
.send(options)
|
|
154
|
+
.catch(() => null);
|
|
155
|
+
}
|
|
156
|
+
else if (replyMessage) {
|
|
157
|
+
replyMessage = await replyMessage
|
|
158
|
+
.edit(options)
|
|
159
|
+
.catch(() => null);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
replyMessage = await message.channel
|
|
163
|
+
.send(options)
|
|
164
|
+
.catch(() => null);
|
|
165
|
+
}
|
|
166
|
+
replied = true;
|
|
167
|
+
return replyMessage;
|
|
263
168
|
},
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
169
|
+
reply: async (opts) => {
|
|
170
|
+
if (replied || deferred)
|
|
171
|
+
return interaction.editReply(opts);
|
|
172
|
+
replied = true;
|
|
173
|
+
replyMessage = await message.channel
|
|
174
|
+
.send(opts)
|
|
175
|
+
.catch(() => null);
|
|
176
|
+
return replyMessage;
|
|
269
177
|
},
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
178
|
+
followUp: async (opts) => {
|
|
179
|
+
const msg = await message.channel
|
|
180
|
+
.send(opts)
|
|
181
|
+
.catch(() => null);
|
|
182
|
+
if (msg)
|
|
183
|
+
followUpMessages.push(msg);
|
|
184
|
+
return msg;
|
|
276
185
|
},
|
|
277
|
-
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
|
|
186
|
+
deleteReply: async () => {
|
|
187
|
+
if (replyMessage)
|
|
188
|
+
await replyMessage.delete().catch(() => { });
|
|
189
|
+
replyMessage = null;
|
|
281
190
|
},
|
|
282
|
-
|
|
283
|
-
|
|
191
|
+
fetchReply: async () => replyMessage,
|
|
192
|
+
options: {
|
|
193
|
+
client: message.client,
|
|
194
|
+
data: resolvedOptions,
|
|
195
|
+
resolved: {
|
|
196
|
+
users: new Map(),
|
|
197
|
+
members: new Map(),
|
|
198
|
+
channels: new Map(),
|
|
199
|
+
roles: new Map(),
|
|
200
|
+
attachments: new Map(),
|
|
201
|
+
messages: new Map(),
|
|
202
|
+
},
|
|
203
|
+
_group: resolvedGroup,
|
|
204
|
+
_subcommand: resolvedSubcommand,
|
|
205
|
+
_hoistedOptions: resolvedOptions,
|
|
206
|
+
get: (name, required) => {
|
|
207
|
+
const opt = resolvedOptions.find((o) => o.name === name.toLowerCase());
|
|
208
|
+
if (required && !opt)
|
|
209
|
+
throw new Error(`Option "${name}" required`);
|
|
210
|
+
return opt || null;
|
|
211
|
+
},
|
|
212
|
+
getSubcommand: (required) => {
|
|
213
|
+
if (required && !resolvedSubcommand)
|
|
214
|
+
throw new Error('Subcommand required');
|
|
215
|
+
return resolvedSubcommand;
|
|
216
|
+
},
|
|
217
|
+
getSubcommandGroup: (required) => {
|
|
218
|
+
if (required && !resolvedGroup)
|
|
219
|
+
throw new Error('Group required');
|
|
220
|
+
return resolvedGroup;
|
|
221
|
+
},
|
|
222
|
+
getString: (name, required) => {
|
|
223
|
+
const v = optionsMap.get(name.toLowerCase());
|
|
224
|
+
if (required && v === undefined)
|
|
225
|
+
throw new Error(`Option "${name}" required`);
|
|
226
|
+
return v || null;
|
|
227
|
+
},
|
|
228
|
+
getBoolean: (name, required) => {
|
|
229
|
+
const v = optionsMap.get(name.toLowerCase());
|
|
230
|
+
if (required && v === undefined)
|
|
231
|
+
throw new Error(`Option "${name}" required`);
|
|
232
|
+
return v ? v === 'true' || v === '1' : null;
|
|
233
|
+
},
|
|
234
|
+
getInteger: (name, required) => {
|
|
235
|
+
const v = optionsMap.get(name.toLowerCase());
|
|
236
|
+
if (required && v === undefined)
|
|
237
|
+
throw new Error(`Option "${name}" required`);
|
|
238
|
+
return v ? parseInt(v, 10) : null;
|
|
239
|
+
},
|
|
240
|
+
getNumber: (name, required) => {
|
|
241
|
+
const v = optionsMap.get(name.toLowerCase());
|
|
242
|
+
if (required && v === undefined)
|
|
243
|
+
throw new Error(`Option "${name}" required`);
|
|
244
|
+
return v ? parseFloat(v) : null;
|
|
245
|
+
},
|
|
246
|
+
getUser: (name, required) => {
|
|
247
|
+
const u = resolveUser(optionsMap.get(name.toLowerCase()));
|
|
248
|
+
if (required && !u)
|
|
249
|
+
throw new Error(`Option "${name}" required`);
|
|
250
|
+
return u;
|
|
251
|
+
},
|
|
252
|
+
getMember: (name) => resolveMember(optionsMap.get(name.toLowerCase())),
|
|
253
|
+
getChannel: (name, required) => {
|
|
254
|
+
const c = resolveChannel(optionsMap.get(name.toLowerCase()));
|
|
255
|
+
if (required && !c)
|
|
256
|
+
throw new Error(`Option "${name}" required`);
|
|
257
|
+
return c;
|
|
258
|
+
},
|
|
259
|
+
getRole: (name, required) => {
|
|
260
|
+
const r = resolveRole(optionsMap.get(name.toLowerCase()));
|
|
261
|
+
if (required && !r)
|
|
262
|
+
throw new Error(`Option "${name}" required`);
|
|
263
|
+
return r;
|
|
264
|
+
},
|
|
265
|
+
getAttachment: (name, required) => {
|
|
266
|
+
const a = message.attachments.first();
|
|
267
|
+
if (required && !a)
|
|
268
|
+
throw new Error(`Option "${name}" required`);
|
|
269
|
+
return a || null;
|
|
270
|
+
},
|
|
271
|
+
getMentionable: (name, required) => {
|
|
272
|
+
const v = optionsMap.get(name.toLowerCase());
|
|
273
|
+
const m = resolveUser(v) || resolveRole(v);
|
|
274
|
+
if (required && !m)
|
|
275
|
+
throw new Error(`Option "${name}" required`);
|
|
276
|
+
return m;
|
|
277
|
+
},
|
|
278
|
+
getMessage: (name, required) => {
|
|
279
|
+
if (required)
|
|
280
|
+
throw new Error(`Option "${name}" required`);
|
|
281
|
+
return null;
|
|
282
|
+
},
|
|
283
|
+
getFocused: (getFull) => {
|
|
284
|
+
return getFull ? { name: '', value: '', type: 3 } : '';
|
|
285
|
+
},
|
|
284
286
|
},
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
287
|
+
isCommand: () => true,
|
|
288
|
+
isChatInputCommand: () => true,
|
|
289
|
+
isContextMenuCommand: () => false,
|
|
290
|
+
isMessageContextMenuCommand: () => false,
|
|
291
|
+
isUserContextMenuCommand: () => false,
|
|
292
|
+
isMessageComponent: () => false,
|
|
293
|
+
isButton: () => false,
|
|
294
|
+
isStringSelectMenu: () => false,
|
|
295
|
+
isSelectMenu: () => false,
|
|
296
|
+
isUserSelectMenu: () => false,
|
|
297
|
+
isRoleSelectMenu: () => false,
|
|
298
|
+
isMentionableSelectMenu: () => false,
|
|
299
|
+
isChannelSelectMenu: () => false,
|
|
300
|
+
isAutocomplete: () => false,
|
|
301
|
+
isModalSubmit: () => false,
|
|
302
|
+
isRepliable: () => true,
|
|
303
|
+
inGuild: () => !!message.guild,
|
|
304
|
+
inCachedGuild: () => !!message.guild,
|
|
305
|
+
inRawGuild: () => false,
|
|
306
|
+
toString: () => `/${commandName} ${rawArgsString}`.trim(),
|
|
307
|
+
};
|
|
308
|
+
let commandKey = commandName;
|
|
309
|
+
if (resolvedGroup)
|
|
310
|
+
commandKey = `${commandKey} ${resolvedGroup} ${resolvedSubcommand}`;
|
|
311
|
+
else if (resolvedSubcommand)
|
|
312
|
+
commandKey = `${commandKey} ${resolvedSubcommand}`;
|
|
313
|
+
client.container?.telemetry?.report('info', `Command Executed (Mock): /${commandKey}`, {
|
|
314
|
+
user: `${message.author.tag} (${message.author.id})`,
|
|
315
|
+
guild: message.guild
|
|
316
|
+
? `${message.guild.name} (${message.guild.id})`
|
|
317
|
+
: 'DM',
|
|
318
|
+
channel: message.channel.id,
|
|
319
|
+
type: 'Prefix/Mock',
|
|
320
|
+
});
|
|
321
|
+
return interaction;
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
const client = message.client;
|
|
325
|
+
client.container?.logger?.error('Error creating mock interaction:', error);
|
|
326
|
+
client.container?.telemetry?.report('error', `Mock Interaction Creation Failed: [${commandName}]`, {
|
|
327
|
+
message: error.message,
|
|
328
|
+
stack: error.stack,
|
|
329
|
+
});
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
308
332
|
},
|
|
309
333
|
};
|
|
310
334
|
//# sourceMappingURL=InteractionFactory.js.map
|