nuxt-discord 0.0.17 → 0.1.0
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/README.md +249 -171
- package/dist/module.d.mts +108 -10
- package/dist/module.json +3 -3
- package/dist/module.mjs +966 -345
- package/dist/runtime/acknowledgement.d.ts +10 -0
- package/dist/runtime/acknowledgement.js +124 -0
- package/dist/runtime/client/chat-theme.css +52 -0
- package/dist/runtime/client/components/ChatAvatar.d.vue.ts +6 -0
- package/dist/runtime/client/components/ChatAvatar.vue +11 -0
- package/dist/runtime/client/components/ChatAvatar.vue.d.ts +6 -0
- package/dist/runtime/client/components/CommandPicker.d.vue.ts +24 -0
- package/dist/runtime/client/components/CommandPicker.vue +67 -0
- package/dist/runtime/client/components/CommandPicker.vue.d.ts +24 -0
- package/dist/runtime/client/components/CommandTestBar.d.vue.ts +60 -0
- package/dist/runtime/client/components/CommandTestBar.vue +335 -0
- package/dist/runtime/client/components/CommandTestBar.vue.d.ts +60 -0
- package/dist/runtime/client/components/CommandTranscript.d.vue.ts +39 -0
- package/dist/runtime/client/components/CommandTranscript.vue +147 -0
- package/dist/runtime/client/components/CommandTranscript.vue.d.ts +39 -0
- package/dist/runtime/client/components/ProjectLogo.d.vue.ts +3 -0
- package/dist/runtime/client/components/ProjectLogo.vue +31 -0
- package/dist/runtime/client/components/ProjectLogo.vue.d.ts +3 -0
- package/dist/runtime/client/components/TheHeader.d.vue.ts +3 -0
- package/dist/runtime/client/components/TheHeader.vue +53 -16
- package/dist/runtime/client/components/TheHeader.vue.d.ts +2 -2
- package/dist/runtime/client/components/appearance-select.d.ts +17 -0
- package/dist/runtime/client/components/appearance-select.js +15 -0
- package/dist/runtime/client/pages/activity.d.vue.ts +3 -0
- package/dist/runtime/client/pages/activity.vue +202 -0
- package/dist/runtime/client/pages/activity.vue.d.ts +3 -0
- package/dist/runtime/client/pages/context-menus.d.vue.ts +3 -0
- package/dist/runtime/client/pages/context-menus.vue +120 -0
- package/dist/runtime/client/pages/context-menus.vue.d.ts +3 -0
- package/dist/runtime/client/pages/listeners.d.vue.ts +3 -0
- package/dist/runtime/client/pages/listeners.vue +68 -0
- package/dist/runtime/client/pages/listeners.vue.d.ts +3 -0
- package/dist/runtime/client/pages/overview.d.vue.ts +3 -0
- package/dist/runtime/client/pages/overview.vue +280 -0
- package/dist/runtime/client/pages/overview.vue.d.ts +3 -0
- package/dist/runtime/client/pages/slash-commands.d.vue.ts +3 -0
- package/dist/runtime/client/pages/slash-commands.vue +185 -359
- package/dist/runtime/client/pages/slash-commands.vue.d.ts +2 -3
- package/dist/runtime/client/style.css +4 -1
- package/dist/runtime/client/useActivityLog.d.ts +7 -0
- package/dist/runtime/client/useActivityLog.js +76 -0
- package/dist/runtime/client/useCommandRegistry.d.ts +7 -0
- package/dist/runtime/client/useCommandRegistry.js +34 -0
- package/dist/runtime/client/useDashboardCatalog.d.ts +5 -0
- package/dist/runtime/client/useDashboardCatalog.js +9 -0
- package/dist/runtime/dashboard/auth.d.ts +4 -0
- package/dist/runtime/dashboard/auth.js +65 -0
- package/dist/runtime/dashboard/oauth.d.ts +3 -0
- package/dist/runtime/dashboard/oauth.js +151 -0
- package/dist/runtime/dashboard/permissions.d.ts +4 -0
- package/dist/runtime/dashboard/permissions.js +84 -0
- package/dist/runtime/dashboard/signin.d.ts +2 -0
- package/dist/runtime/dashboard/signin.js +39 -0
- package/dist/runtime/diagnostics.d.ts +4 -0
- package/dist/runtime/diagnostics.js +24 -0
- package/dist/runtime/discordInvocation.d.ts +14 -0
- package/dist/runtime/discordInvocation.js +28 -0
- package/dist/runtime/middleware.d.ts +1 -0
- package/dist/runtime/middleware.js +12 -0
- package/dist/runtime/registration.d.ts +65 -0
- package/dist/runtime/registration.js +354 -0
- package/dist/runtime/server/api/discord/activity.get.d.ts +2 -0
- package/dist/runtime/server/api/discord/activity.get.js +6 -0
- package/dist/runtime/server/api/discord/catalog.get.d.ts +2 -0
- package/dist/runtime/server/api/discord/catalog.get.js +3 -0
- package/dist/runtime/server/api/discord/slash-command/autocomplete.post.d.ts +2 -0
- package/dist/runtime/server/api/discord/slash-command/autocomplete.post.js +14 -0
- package/dist/runtime/server/api/discord/slash-command/register.post.d.ts +1 -1
- package/dist/runtime/server/api/discord/slash-command/register.post.js +1 -1
- package/dist/runtime/server/api/discord/slash-command/remote-all.get.d.ts +1 -1
- package/dist/runtime/server/api/discord/slash-command/remote-diff.post.d.ts +1 -238
- package/dist/runtime/server/api/discord/slash-command/remote-diff.post.js +3 -1
- package/dist/runtime/server/api/discord/slash-command/test.post.d.ts +20 -0
- package/dist/runtime/server/api/discord/slash-command/test.post.js +19 -0
- package/dist/runtime/server/plugins/discord.js +93 -31
- package/dist/runtime/server/utils/client.d.ts +59 -246
- package/dist/runtime/server/utils/client.js +413 -451
- package/dist/runtime/server/utils/defineContextMenu.d.ts +49 -0
- package/dist/runtime/server/utils/defineContextMenu.js +12 -0
- package/dist/runtime/server/utils/defineListener.d.ts +24 -0
- package/dist/runtime/server/utils/defineListener.js +7 -0
- package/dist/runtime/server/utils/defineMiddleware.d.ts +29 -0
- package/dist/runtime/server/utils/defineMiddleware.js +24 -0
- package/dist/runtime/server/utils/describeCommand.d.ts +2 -0
- package/dist/runtime/server/utils/describeOption.d.ts +1 -1
- package/dist/runtime/server/utils/messageSender.d.ts +37 -0
- package/dist/runtime/server/utils/messageSender.js +149 -0
- package/dist/runtime/server/utils/middleware/cooldown.d.ts +1 -0
- package/dist/runtime/server/utils/middleware/cooldown.js +39 -0
- package/dist/runtime/server/utils/middleware/guildOnly.d.ts +1 -0
- package/dist/runtime/server/utils/middleware/guildOnly.js +6 -0
- package/dist/runtime/server/utils/middleware/ownerOnly.d.ts +1 -0
- package/dist/runtime/server/utils/middleware/ownerOnly.js +10 -0
- package/dist/runtime/server/utils/middleware/requireRole.d.ts +1 -0
- package/dist/runtime/server/utils/middleware/requireRole.js +15 -0
- package/dist/runtime/server/utils/reply.d.ts +13 -3
- package/dist/runtime/server/utils/reply.js +111 -162
- package/dist/runtime/server/utils/simulateInteraction.d.ts +20 -0
- package/dist/runtime/server/utils/simulateInteraction.js +127 -0
- package/dist/runtime/server/utils/useTextChannel.d.ts +56 -0
- package/dist/runtime/server/utils/useTextChannel.js +105 -0
- package/dist/types.d.mts +11 -1
- package/dist/types.d.ts +11 -1
- package/package.json +62 -44
- package/dist/runtime/client/components/TheHeader.css +0 -1
- package/dist/runtime/client/pages/slash-commands.css +0 -1
- package/dist/runtime/client/uno.config.d.ts +0 -2
- package/dist/runtime/client/uno.config.js +0 -10
package/dist/module.d.mts
CHANGED
|
@@ -2,11 +2,18 @@ import * as _nuxt_schema from '@nuxt/schema';
|
|
|
2
2
|
import * as __runtime_logger from '../dist/runtime/logger.js';
|
|
3
3
|
import * as _nuxt_kit from '@nuxt/kit';
|
|
4
4
|
import * as nuxt_schema from 'nuxt/schema';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
5
|
+
import * as __runtime_acknowledgement from '../dist/runtime/acknowledgement.js';
|
|
6
|
+
import * as __runtime_server_utils_defineMiddleware from '../dist/runtime/server/utils/defineMiddleware.js';
|
|
7
|
+
export { MiddlewareDefinition, MiddlewareError, MiddlewareFn, MiddlewareOpts } from '../dist/runtime/server/utils/defineMiddleware.js';
|
|
8
|
+
import { LocalizationMap, ApplicationCommandOptionType, ClientOptions, CommandInteractionOption, ChatInputCommandInteraction, User, Role, APIRole, GuildMember, APIInteractionDataResolvedGuildMember, Attachment } from 'discord.js';
|
|
8
9
|
import { ListenOptions } from 'listhen';
|
|
9
10
|
import { MaybeRef } from 'vue';
|
|
11
|
+
import { DiscordClient } from '../dist/runtime/server/utils/client.js';
|
|
12
|
+
export { ActivityLogEntry, DiscordClient, DiscordClientError } from '../dist/runtime/server/utils/client.js';
|
|
13
|
+
import { IntegerOption, NumberOption, StringOption, DescribeOptionOptions } from '../dist/runtime/server/utils/describeOption.js';
|
|
14
|
+
export { ContextMenuDefinition } from '../dist/runtime/server/utils/defineContextMenu.js';
|
|
15
|
+
export { ListenerDefinition } from '../dist/runtime/server/utils/defineListener.js';
|
|
16
|
+
export { SendHandle, UseTextChannelReturn } from '../dist/runtime/server/utils/useTextChannel.js';
|
|
10
17
|
|
|
11
18
|
interface NuxtDiscordOptions {
|
|
12
19
|
/**
|
|
@@ -18,8 +25,8 @@ interface NuxtDiscordOptions {
|
|
|
18
25
|
*/
|
|
19
26
|
client: ClientOptions & {
|
|
20
27
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
28
|
+
* Automatically acknowledge a slash command whose reply approaches Discord’s deadline.
|
|
29
|
+
* The default acknowledgement is private. Fast commands reply directly.
|
|
23
30
|
*
|
|
24
31
|
* @default true
|
|
25
32
|
*/
|
|
@@ -38,6 +45,25 @@ interface NuxtDiscordOptions {
|
|
|
38
45
|
* @default true
|
|
39
46
|
*/
|
|
40
47
|
autoStart: boolean;
|
|
48
|
+
/** Build the authenticated dashboard into the production Node server. */
|
|
49
|
+
dashboard?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Timeout in milliseconds before an interaction's reactive scope is disposed.
|
|
52
|
+
* This cleans up watchers (reactive replies) and component collectors (buttons).
|
|
53
|
+
* Defaults to Discord's interaction token lifetime (15 minutes).
|
|
54
|
+
* Set to `0` to disable automatic cleanup.
|
|
55
|
+
*/
|
|
56
|
+
interactionTimeout?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Guild IDs to register guild-specific commands to.
|
|
59
|
+
* Commands tagged with `@guild` will be registered to these guilds
|
|
60
|
+
* instead of globally. Useful for development (instant updates)
|
|
61
|
+
* or server-specific commands.
|
|
62
|
+
*
|
|
63
|
+
* Can also be set via the DISCORD_GUILD_ID environment variable
|
|
64
|
+
* (comma-separated for multiple guilds).
|
|
65
|
+
*/
|
|
66
|
+
guilds?: string[];
|
|
41
67
|
/**
|
|
42
68
|
* HMR options
|
|
43
69
|
*/
|
|
@@ -67,16 +93,23 @@ interface DiscordRuntimeConfig {
|
|
|
67
93
|
client: NuxtDiscordOptions['client'];
|
|
68
94
|
autoStart: boolean;
|
|
69
95
|
sync: NuxtDiscordOptions['watch']['sync'];
|
|
96
|
+
guilds: string[];
|
|
70
97
|
dir: string;
|
|
71
98
|
buildDir: string;
|
|
72
99
|
rootDir: string;
|
|
100
|
+
interactionTimeout?: number;
|
|
73
101
|
}
|
|
74
|
-
declare const slashCommandOptionTypeIdentifiers: readonly ["number", "integer", "string", "boolean"];
|
|
102
|
+
declare const slashCommandOptionTypeIdentifiers: readonly ["number", "integer", "string", "boolean", "User", "Channel", "Role", "Mentionable", "Attachment"];
|
|
75
103
|
declare const typeIdentifierToEnum: {
|
|
76
104
|
readonly number: ApplicationCommandOptionType.Number;
|
|
77
105
|
readonly integer: ApplicationCommandOptionType.Integer;
|
|
78
106
|
readonly string: ApplicationCommandOptionType.String;
|
|
79
107
|
readonly boolean: ApplicationCommandOptionType.Boolean;
|
|
108
|
+
readonly User: ApplicationCommandOptionType.User;
|
|
109
|
+
readonly Channel: ApplicationCommandOptionType.Channel;
|
|
110
|
+
readonly Role: ApplicationCommandOptionType.Role;
|
|
111
|
+
readonly Mentionable: ApplicationCommandOptionType.Mentionable;
|
|
112
|
+
readonly Attachment: ApplicationCommandOptionType.Attachment;
|
|
80
113
|
};
|
|
81
114
|
type SlashCommandOptionTypeIdentifier = (typeof slashCommandOptionTypeIdentifiers)[number];
|
|
82
115
|
declare const integerLabel: unique symbol;
|
|
@@ -87,13 +120,17 @@ declare const integerLabel: unique symbol;
|
|
|
87
120
|
type integer = number & {
|
|
88
121
|
[integerLabel]: never;
|
|
89
122
|
};
|
|
90
|
-
|
|
123
|
+
/** A Discord mentionable option resolves to a user, guild member, or role. */
|
|
124
|
+
type Mentionable = NonNullable<CommandInteractionOption['user' | 'member' | 'role']>;
|
|
125
|
+
type SlashCommandOptionType = number | integer | string | boolean | User | Role | APIRole | GuildMember | APIInteractionDataResolvedGuildMember | Attachment | NonNullable<CommandInteractionOption['channel']>;
|
|
91
126
|
interface SlashCommandOptionBase {
|
|
92
127
|
name: string;
|
|
93
128
|
description: string;
|
|
94
129
|
type: ApplicationCommandOptionType;
|
|
95
130
|
required: boolean;
|
|
96
131
|
hasAutocomplete: boolean;
|
|
132
|
+
nameLocalizations?: LocalizationMap;
|
|
133
|
+
descriptionLocalizations?: LocalizationMap;
|
|
97
134
|
}
|
|
98
135
|
interface SlashCommandIntegerOption extends SlashCommandOptionBase, Omit<IntegerOption, 'name' | 'description'> {
|
|
99
136
|
type: ApplicationCommandOptionType.Integer;
|
|
@@ -107,12 +144,43 @@ interface SlashCommandStringOption extends SlashCommandOptionBase, Omit<StringOp
|
|
|
107
144
|
interface SlashCommandBooleanOption extends SlashCommandOptionBase {
|
|
108
145
|
type: ApplicationCommandOptionType.Boolean;
|
|
109
146
|
}
|
|
110
|
-
|
|
147
|
+
interface SlashCommandUserOption extends SlashCommandOptionBase {
|
|
148
|
+
type: ApplicationCommandOptionType.User;
|
|
149
|
+
}
|
|
150
|
+
interface SlashCommandChannelOption extends SlashCommandOptionBase {
|
|
151
|
+
type: ApplicationCommandOptionType.Channel;
|
|
152
|
+
}
|
|
153
|
+
interface SlashCommandRoleOption extends SlashCommandOptionBase {
|
|
154
|
+
type: ApplicationCommandOptionType.Role;
|
|
155
|
+
}
|
|
156
|
+
interface SlashCommandMentionableOption extends SlashCommandOptionBase {
|
|
157
|
+
type: ApplicationCommandOptionType.Mentionable;
|
|
158
|
+
}
|
|
159
|
+
interface SlashCommandAttachmentOption extends SlashCommandOptionBase {
|
|
160
|
+
type: ApplicationCommandOptionType.Attachment;
|
|
161
|
+
}
|
|
162
|
+
type SlashCommandOption = SlashCommandIntegerOption | SlashCommandNumberOption | SlashCommandStringOption | SlashCommandBooleanOption | SlashCommandUserOption | SlashCommandChannelOption | SlashCommandRoleOption | SlashCommandMentionableOption | SlashCommandAttachmentOption;
|
|
111
163
|
type SlashCommandCustomReturnHandler = (this: DiscordClient, interaction: ChatInputCommandInteraction, client: DiscordClient) => unknown;
|
|
112
164
|
type SlashCommandReturnType = void | MaybeRef<string> | SlashCommandCustomReturnHandler | Promise<SlashCommandReturnType> | Generator<SlashCommandReturnType> | AsyncGenerator<SlashCommandReturnType>;
|
|
165
|
+
interface MiddlewareEntry {
|
|
166
|
+
name: string;
|
|
167
|
+
fn: __runtime_server_utils_defineMiddleware.MiddlewareFn;
|
|
168
|
+
options?: Record<string, unknown>;
|
|
169
|
+
}
|
|
113
170
|
interface SlashCommand {
|
|
114
171
|
name: string;
|
|
115
172
|
description: string;
|
|
173
|
+
defer?: __runtime_acknowledgement.DeferPolicy;
|
|
174
|
+
nsfw?: boolean;
|
|
175
|
+
/** Middleware names from @middleware JSDoc tags */
|
|
176
|
+
middleware?: string[];
|
|
177
|
+
/** Interaction contexts where this command is available (Guild=0, BotDM=1, PrivateChannel=2) */
|
|
178
|
+
contexts?: number[];
|
|
179
|
+
defaultMemberPermissions?: string | null;
|
|
180
|
+
/** Register to specific guilds instead of globally. `true` = all configured guilds, `string[]` = specific guild IDs */
|
|
181
|
+
guilds?: true | string[];
|
|
182
|
+
nameLocalizations?: LocalizationMap;
|
|
183
|
+
descriptionLocalizations?: LocalizationMap;
|
|
116
184
|
path: string;
|
|
117
185
|
options: (SlashCommandOption & {
|
|
118
186
|
varname: string;
|
|
@@ -130,10 +198,11 @@ interface SlashCommandSubcommand extends Omit<SlashCommand, 'subcommands' | 'par
|
|
|
130
198
|
}
|
|
131
199
|
interface SlashCommandRuntime extends Omit<SlashCommand, 'subcommands'> {
|
|
132
200
|
/** if execute is not defined load must be defined */
|
|
133
|
-
load?: () => Promise<Pick<SlashCommandRuntime, 'execute' | 'optionMacros'>>;
|
|
201
|
+
load?: () => Promise<Pick<SlashCommandRuntime, 'execute' | 'optionMacros' | 'middlewareEntries'>>;
|
|
134
202
|
execute?: (...args: (SlashCommandOptionType | undefined)[]) => SlashCommandReturnType;
|
|
135
203
|
id?: string;
|
|
136
204
|
optionMacros?: Record<string, DescribeOptionOptions>;
|
|
205
|
+
middlewareEntries?: MiddlewareEntry[];
|
|
137
206
|
subcommands?: (SlashCommandSubcommandRuntime | SlashCommandSubcommandGroupRuntime)[];
|
|
138
207
|
}
|
|
139
208
|
interface SlashCommandSubcommandGroupRuntime extends Omit<SlashCommandRuntime, 'subcommands' | 'parents'> {
|
|
@@ -144,10 +213,39 @@ interface SlashCommandSubcommandRuntime extends Omit<SlashCommandRuntime, 'subco
|
|
|
144
213
|
parents: [string] | [string, string];
|
|
145
214
|
subcommands?: [];
|
|
146
215
|
}
|
|
216
|
+
interface Listener {
|
|
217
|
+
/** File path */
|
|
218
|
+
path: string;
|
|
219
|
+
/** Discord event name (e.g. 'guildMemberAdd') */
|
|
220
|
+
event: string;
|
|
221
|
+
/** Whether this listener fires only once */
|
|
222
|
+
once?: boolean;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
interface ContextMenu {
|
|
226
|
+
/** Display name for the context menu */
|
|
227
|
+
name: string;
|
|
228
|
+
/** 'user' or 'message' */
|
|
229
|
+
type: 'user' | 'message';
|
|
230
|
+
/** File path */
|
|
231
|
+
path: string;
|
|
232
|
+
/** Register to specific guilds */
|
|
233
|
+
guilds?: true | string[];
|
|
234
|
+
/** Middleware names from @middleware JSDoc tags */
|
|
235
|
+
middleware?: string[];
|
|
236
|
+
nameLocalizations?: LocalizationMap;
|
|
237
|
+
}
|
|
238
|
+
interface DashboardCatalog {
|
|
239
|
+
commands: SlashCommand[];
|
|
240
|
+
menus: ContextMenu[];
|
|
241
|
+
listeners: Listener[];
|
|
242
|
+
}
|
|
147
243
|
interface NuxtDiscordContext {
|
|
148
244
|
nuxt: nuxt_schema.Nuxt;
|
|
149
245
|
options: NuxtDiscordOptions;
|
|
150
246
|
slashCommands: SlashCommand[];
|
|
247
|
+
contextMenus: ContextMenu[];
|
|
248
|
+
listeners: Listener[];
|
|
151
249
|
resolve: {
|
|
152
250
|
root: _nuxt_kit.Resolver['resolve'];
|
|
153
251
|
module: _nuxt_kit.Resolver['resolve'];
|
|
@@ -158,4 +256,4 @@ interface NuxtDiscordContext {
|
|
|
158
256
|
declare const _default: _nuxt_schema.NuxtModule<NuxtDiscordOptions, NuxtDiscordOptions, false>;
|
|
159
257
|
|
|
160
258
|
export { _default as default, slashCommandOptionTypeIdentifiers, typeIdentifierToEnum };
|
|
161
|
-
export type { DiscordRuntimeConfig, NuxtDiscordContext, NuxtDiscordOptions, SlashCommand, SlashCommandBooleanOption, SlashCommandCustomReturnHandler, SlashCommandIntegerOption, SlashCommandNumberOption, SlashCommandOption, SlashCommandOptionBase, SlashCommandOptionType, SlashCommandOptionTypeIdentifier, SlashCommandReturnType, SlashCommandRuntime, SlashCommandStringOption, SlashCommandSubcommand, SlashCommandSubcommandGroup, SlashCommandSubcommandGroupRuntime, SlashCommandSubcommandRuntime, integer };
|
|
259
|
+
export type { ContextMenu, DashboardCatalog, DiscordRuntimeConfig, Listener, Mentionable, MiddlewareEntry, NuxtDiscordContext, NuxtDiscordOptions, SlashCommand, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandCustomReturnHandler, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandOption, SlashCommandOptionBase, SlashCommandOptionType, SlashCommandOptionTypeIdentifier, SlashCommandReturnType, SlashCommandRoleOption, SlashCommandRuntime, SlashCommandStringOption, SlashCommandSubcommand, SlashCommandSubcommandGroup, SlashCommandSubcommandGroupRuntime, SlashCommandSubcommandRuntime, SlashCommandUserOption, integer };
|
package/dist/module.json
CHANGED