nuxt-discord 0.0.10 → 0.0.11
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -411,8 +411,8 @@ async function generateDynamicCommandBuild(file, config, ctx) {
|
|
|
411
411
|
bundle = await rollup({
|
|
412
412
|
...config,
|
|
413
413
|
input: file,
|
|
414
|
-
// externalize all modules except the command file itself
|
|
415
|
-
external: (id) => !id.includes(file)
|
|
414
|
+
// externalize all modules except the command file itself, excluding .ts files
|
|
415
|
+
external: (id) => !id.includes(file) && !id.endsWith(".ts")
|
|
416
416
|
});
|
|
417
417
|
const { output } = await bundle.generate({ ...config.output, sourcemap: false });
|
|
418
418
|
mkdirSync(path.join(ctx.nuxt.options.buildDir, "discord", "commands"), { recursive: true });
|
|
@@ -161,7 +161,11 @@ export class DiscordClient {
|
|
|
161
161
|
}
|
|
162
162
|
try {
|
|
163
163
|
if (typeof result === "string") {
|
|
164
|
-
|
|
164
|
+
if (interaction.deferred) {
|
|
165
|
+
return interaction.editReply({ content: result });
|
|
166
|
+
} else {
|
|
167
|
+
return interaction.reply({ content: result });
|
|
168
|
+
}
|
|
165
169
|
} else if (typeof result === "function") {
|
|
166
170
|
const newResult = result.call(this, interaction, this);
|
|
167
171
|
return this.#handleSlashCommandReturn(newResult, interaction, command);
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type { InteractionReplyOptions } from 'discord.js';
|
|
1
|
+
import type { InteractionEditReplyOptions, InteractionReplyOptions } from 'discord.js';
|
|
2
2
|
import type { SlashCommandCustomReturnHandler } from '~/src/types';
|
|
3
|
+
type OmitPreservingCallSignature<T, K extends keyof T = keyof T> = Omit<T, K> & (T extends (...args: infer R) => infer S ? (...args: R) => S : unknown);
|
|
3
4
|
interface ReplyFunction {
|
|
4
5
|
(text: string, options?: InteractionReplyOptions): SlashCommandCustomReturnHandler;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
edit: EditReplyFunction;
|
|
7
|
+
ephemeral: OmitPreservingCallSignature<ReplyFunction, 'edit' | 'ephemeral'>;
|
|
8
|
+
flags: (flags: InteractionReplyOptions['flags']) => OmitPreservingCallSignature<ReplyFunction, 'edit'>;
|
|
9
|
+
}
|
|
10
|
+
interface EditReplyFunction {
|
|
11
|
+
(text: string, options?: InteractionEditReplyOptions): SlashCommandCustomReturnHandler;
|
|
12
|
+
flags: (flags: InteractionEditReplyOptions['flags']) => EditReplyFunction;
|
|
7
13
|
}
|
|
8
14
|
export declare const reply: ReplyFunction;
|
|
9
15
|
export {};
|
|
@@ -1,27 +1,46 @@
|
|
|
1
1
|
import { MessageFlags } from "discord.js";
|
|
2
|
-
function createReplyFunction(defaultOptions = {}) {
|
|
3
|
-
const reply2 = (text, options) => (interaction) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
function createReplyFunction({ editReply, ...defaultOptions } = {}) {
|
|
3
|
+
const reply2 = (text, options) => async (interaction) => {
|
|
4
|
+
if (editReply) {
|
|
5
|
+
await interaction.editReply({
|
|
6
|
+
content: text,
|
|
7
|
+
...defaultOptions,
|
|
8
|
+
...options
|
|
9
|
+
});
|
|
10
|
+
} else {
|
|
11
|
+
await interaction.reply({
|
|
12
|
+
content: text,
|
|
13
|
+
...defaultOptions,
|
|
14
|
+
...options
|
|
15
|
+
});
|
|
16
|
+
}
|
|
9
17
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
Object.defineProperties(reply2, {
|
|
19
|
+
ephemeral: {
|
|
20
|
+
get() {
|
|
13
21
|
return createReplyFunction({
|
|
14
22
|
...defaultOptions,
|
|
15
23
|
flags: defaultOptions.flags == null ? MessageFlags.Ephemeral : typeof defaultOptions.flags === "string" ? [defaultOptions.flags, "Ephemeral"] : Array.isArray(defaultOptions.flags) ? [...defaultOptions.flags, "Ephemeral"] : typeof defaultOptions.flags === "number" || typeof defaultOptions.flags === "bigint" ? defaultOptions.flags | MessageFlags.Ephemeral : MessageFlags.Ephemeral
|
|
16
24
|
});
|
|
17
|
-
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
flags: {
|
|
28
|
+
get() {
|
|
18
29
|
return (flags) => createReplyFunction({
|
|
19
30
|
...defaultOptions,
|
|
20
31
|
flags
|
|
21
32
|
});
|
|
22
33
|
}
|
|
23
|
-
|
|
34
|
+
},
|
|
35
|
+
edit: {
|
|
36
|
+
get() {
|
|
37
|
+
return createReplyFunction({
|
|
38
|
+
...defaultOptions,
|
|
39
|
+
editReply: true
|
|
40
|
+
});
|
|
41
|
+
}
|
|
24
42
|
}
|
|
25
43
|
});
|
|
44
|
+
return reply2;
|
|
26
45
|
}
|
|
27
46
|
export const reply = createReplyFunction();
|
package/package.json
CHANGED