nuxt-discord 0.0.16 → 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.
Files changed (112) hide show
  1. package/README.md +249 -171
  2. package/dist/module.d.mts +128 -11
  3. package/dist/module.json +3 -3
  4. package/dist/module.mjs +1015 -328
  5. package/dist/runtime/acknowledgement.d.ts +10 -0
  6. package/dist/runtime/acknowledgement.js +124 -0
  7. package/dist/runtime/client/chat-theme.css +52 -0
  8. package/dist/runtime/client/components/ChatAvatar.d.vue.ts +6 -0
  9. package/dist/runtime/client/components/ChatAvatar.vue +11 -0
  10. package/dist/runtime/client/components/ChatAvatar.vue.d.ts +6 -0
  11. package/dist/runtime/client/components/CommandPicker.d.vue.ts +24 -0
  12. package/dist/runtime/client/components/CommandPicker.vue +67 -0
  13. package/dist/runtime/client/components/CommandPicker.vue.d.ts +24 -0
  14. package/dist/runtime/client/components/CommandTestBar.d.vue.ts +60 -0
  15. package/dist/runtime/client/components/CommandTestBar.vue +335 -0
  16. package/dist/runtime/client/components/CommandTestBar.vue.d.ts +60 -0
  17. package/dist/runtime/client/components/CommandTranscript.d.vue.ts +39 -0
  18. package/dist/runtime/client/components/CommandTranscript.vue +147 -0
  19. package/dist/runtime/client/components/CommandTranscript.vue.d.ts +39 -0
  20. package/dist/runtime/client/components/ProjectLogo.d.vue.ts +3 -0
  21. package/dist/runtime/client/components/ProjectLogo.vue +31 -0
  22. package/dist/runtime/client/components/ProjectLogo.vue.d.ts +3 -0
  23. package/dist/runtime/client/components/TheHeader.d.vue.ts +3 -0
  24. package/dist/runtime/client/components/TheHeader.vue +53 -16
  25. package/dist/runtime/client/components/TheHeader.vue.d.ts +2 -2
  26. package/dist/runtime/client/components/appearance-select.d.ts +17 -0
  27. package/dist/runtime/client/components/appearance-select.js +15 -0
  28. package/dist/runtime/client/pages/activity.d.vue.ts +3 -0
  29. package/dist/runtime/client/pages/activity.vue +202 -0
  30. package/dist/runtime/client/pages/activity.vue.d.ts +3 -0
  31. package/dist/runtime/client/pages/context-menus.d.vue.ts +3 -0
  32. package/dist/runtime/client/pages/context-menus.vue +120 -0
  33. package/dist/runtime/client/pages/context-menus.vue.d.ts +3 -0
  34. package/dist/runtime/client/pages/listeners.d.vue.ts +3 -0
  35. package/dist/runtime/client/pages/listeners.vue +68 -0
  36. package/dist/runtime/client/pages/listeners.vue.d.ts +3 -0
  37. package/dist/runtime/client/pages/overview.d.vue.ts +3 -0
  38. package/dist/runtime/client/pages/overview.vue +280 -0
  39. package/dist/runtime/client/pages/overview.vue.d.ts +3 -0
  40. package/dist/runtime/client/pages/slash-commands.d.vue.ts +3 -0
  41. package/dist/runtime/client/pages/slash-commands.vue +185 -354
  42. package/dist/runtime/client/pages/slash-commands.vue.d.ts +2 -3
  43. package/dist/runtime/client/style.css +4 -1
  44. package/dist/runtime/client/useActivityLog.d.ts +7 -0
  45. package/dist/runtime/client/useActivityLog.js +76 -0
  46. package/dist/runtime/client/useCommandRegistry.d.ts +7 -0
  47. package/dist/runtime/client/useCommandRegistry.js +34 -0
  48. package/dist/runtime/client/useDashboardCatalog.d.ts +5 -0
  49. package/dist/runtime/client/useDashboardCatalog.js +9 -0
  50. package/dist/runtime/dashboard/auth.d.ts +4 -0
  51. package/dist/runtime/dashboard/auth.js +65 -0
  52. package/dist/runtime/dashboard/oauth.d.ts +3 -0
  53. package/dist/runtime/dashboard/oauth.js +151 -0
  54. package/dist/runtime/dashboard/permissions.d.ts +4 -0
  55. package/dist/runtime/dashboard/permissions.js +84 -0
  56. package/dist/runtime/dashboard/signin.d.ts +2 -0
  57. package/dist/runtime/dashboard/signin.js +39 -0
  58. package/dist/runtime/diagnostics.d.ts +4 -0
  59. package/dist/runtime/diagnostics.js +24 -0
  60. package/dist/runtime/discordInvocation.d.ts +14 -0
  61. package/dist/runtime/discordInvocation.js +28 -0
  62. package/dist/runtime/middleware.d.ts +1 -0
  63. package/dist/runtime/middleware.js +12 -0
  64. package/dist/runtime/registration.d.ts +65 -0
  65. package/dist/runtime/registration.js +354 -0
  66. package/dist/runtime/server/api/discord/activity.get.d.ts +2 -0
  67. package/dist/runtime/server/api/discord/activity.get.js +6 -0
  68. package/dist/runtime/server/api/discord/catalog.get.d.ts +2 -0
  69. package/dist/runtime/server/api/discord/catalog.get.js +3 -0
  70. package/dist/runtime/server/api/discord/slash-command/autocomplete.post.d.ts +2 -0
  71. package/dist/runtime/server/api/discord/slash-command/autocomplete.post.js +14 -0
  72. package/dist/runtime/server/api/discord/slash-command/register.post.d.ts +1 -1
  73. package/dist/runtime/server/api/discord/slash-command/register.post.js +1 -1
  74. package/dist/runtime/server/api/discord/slash-command/remote-all.get.d.ts +1 -1
  75. package/dist/runtime/server/api/discord/slash-command/remote-diff.post.d.ts +1 -19
  76. package/dist/runtime/server/api/discord/slash-command/remote-diff.post.js +3 -1
  77. package/dist/runtime/server/api/discord/slash-command/test.post.d.ts +20 -0
  78. package/dist/runtime/server/api/discord/slash-command/test.post.js +19 -0
  79. package/dist/runtime/server/plugins/discord.js +93 -31
  80. package/dist/runtime/server/utils/client.d.ts +58 -20
  81. package/dist/runtime/server/utils/client.js +410 -371
  82. package/dist/runtime/server/utils/defineContextMenu.d.ts +49 -0
  83. package/dist/runtime/server/utils/defineContextMenu.js +12 -0
  84. package/dist/runtime/server/utils/defineListener.d.ts +24 -0
  85. package/dist/runtime/server/utils/defineListener.js +7 -0
  86. package/dist/runtime/server/utils/defineMiddleware.d.ts +29 -0
  87. package/dist/runtime/server/utils/defineMiddleware.js +24 -0
  88. package/dist/runtime/server/utils/describeCommand.d.ts +2 -0
  89. package/dist/runtime/server/utils/describeOption.d.ts +1 -1
  90. package/dist/runtime/server/utils/messageSender.d.ts +37 -0
  91. package/dist/runtime/server/utils/messageSender.js +149 -0
  92. package/dist/runtime/server/utils/middleware/cooldown.d.ts +1 -0
  93. package/dist/runtime/server/utils/middleware/cooldown.js +39 -0
  94. package/dist/runtime/server/utils/middleware/guildOnly.d.ts +1 -0
  95. package/dist/runtime/server/utils/middleware/guildOnly.js +6 -0
  96. package/dist/runtime/server/utils/middleware/ownerOnly.d.ts +1 -0
  97. package/dist/runtime/server/utils/middleware/ownerOnly.js +10 -0
  98. package/dist/runtime/server/utils/middleware/requireRole.d.ts +1 -0
  99. package/dist/runtime/server/utils/middleware/requireRole.js +15 -0
  100. package/dist/runtime/server/utils/reply.d.ts +13 -3
  101. package/dist/runtime/server/utils/reply.js +111 -162
  102. package/dist/runtime/server/utils/simulateInteraction.d.ts +20 -0
  103. package/dist/runtime/server/utils/simulateInteraction.js +127 -0
  104. package/dist/runtime/server/utils/useTextChannel.d.ts +56 -0
  105. package/dist/runtime/server/utils/useTextChannel.js +105 -0
  106. package/dist/types.d.mts +11 -1
  107. package/dist/types.d.ts +11 -1
  108. package/package.json +62 -44
  109. package/dist/runtime/client/components/TheHeader.css +0 -1
  110. package/dist/runtime/client/pages/slash-commands.css +0 -1
  111. package/dist/runtime/client/uno.config.d.ts +0 -2
  112. 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 { DiscordClient } from '/Users/jeffz/Dev/nuxt-discord/dist/runtime/server/utils/client.js';
6
- import { IntegerOption, NumberOption, StringOption, DescribeOptionOptions } from '../dist/runtime/server/utils/describeOption.js';
7
- import { ClientOptions, ApplicationCommandOptionType, ChatInputCommandInteraction } from 'discord.js';
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
- * Whether to automatically defer the interaction reply
22
- * on slash command execution if the command returns a promise.
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
- type SlashCommandOptionType = number | integer | string | boolean;
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,28 +144,108 @@ interface SlashCommandStringOption extends SlashCommandOptionBase, Omit<StringOp
107
144
  interface SlashCommandBooleanOption extends SlashCommandOptionBase {
108
145
  type: ApplicationCommandOptionType.Boolean;
109
146
  }
110
- type SlashCommandOption = SlashCommandIntegerOption | SlashCommandNumberOption | SlashCommandStringOption | SlashCommandBooleanOption;
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;
119
187
  })[];
188
+ parents: [];
189
+ subcommands: (SlashCommandSubcommand | SlashCommandSubcommandGroup)[];
190
+ }
191
+ interface SlashCommandSubcommandGroup extends Omit<SlashCommand, 'subcommands' | 'parents'> {
192
+ parents: [string];
193
+ subcommands: SlashCommandSubcommand[];
194
+ }
195
+ interface SlashCommandSubcommand extends Omit<SlashCommand, 'subcommands' | 'parents'> {
196
+ parents: [string] | [string, string];
197
+ subcommands: [];
120
198
  }
121
- interface SlashCommandRuntime extends SlashCommand {
199
+ interface SlashCommandRuntime extends Omit<SlashCommand, 'subcommands'> {
122
200
  /** if execute is not defined load must be defined */
123
- load?: () => Promise<Pick<SlashCommandRuntime, 'execute' | 'optionMacros'>>;
201
+ load?: () => Promise<Pick<SlashCommandRuntime, 'execute' | 'optionMacros' | 'middlewareEntries'>>;
124
202
  execute?: (...args: (SlashCommandOptionType | undefined)[]) => SlashCommandReturnType;
125
203
  id?: string;
126
204
  optionMacros?: Record<string, DescribeOptionOptions>;
205
+ middlewareEntries?: MiddlewareEntry[];
206
+ subcommands?: (SlashCommandSubcommandRuntime | SlashCommandSubcommandGroupRuntime)[];
207
+ }
208
+ interface SlashCommandSubcommandGroupRuntime extends Omit<SlashCommandRuntime, 'subcommands' | 'parents'> {
209
+ parents: [string];
210
+ subcommands?: SlashCommandSubcommandRuntime[];
211
+ }
212
+ interface SlashCommandSubcommandRuntime extends Omit<SlashCommandRuntime, 'subcommands' | 'parents'> {
213
+ parents: [string] | [string, string];
214
+ subcommands?: [];
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[];
127
242
  }
128
243
  interface NuxtDiscordContext {
129
244
  nuxt: nuxt_schema.Nuxt;
130
245
  options: NuxtDiscordOptions;
131
246
  slashCommands: SlashCommand[];
247
+ contextMenus: ContextMenu[];
248
+ listeners: Listener[];
132
249
  resolve: {
133
250
  root: _nuxt_kit.Resolver['resolve'];
134
251
  module: _nuxt_kit.Resolver['resolve'];
@@ -139,4 +256,4 @@ interface NuxtDiscordContext {
139
256
  declare const _default: _nuxt_schema.NuxtModule<NuxtDiscordOptions, NuxtDiscordOptions, false>;
140
257
 
141
258
  export { _default as default, slashCommandOptionTypeIdentifiers, typeIdentifierToEnum };
142
- export type { DiscordRuntimeConfig, NuxtDiscordContext, NuxtDiscordOptions, SlashCommand, SlashCommandBooleanOption, SlashCommandCustomReturnHandler, SlashCommandIntegerOption, SlashCommandNumberOption, SlashCommandOption, SlashCommandOptionBase, SlashCommandOptionType, SlashCommandOptionTypeIdentifier, SlashCommandReturnType, SlashCommandRuntime, SlashCommandStringOption, 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
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "nuxt-discord",
3
3
  "configKey": "discord",
4
- "version": "0.0.16",
4
+ "version": "0.1.0",
5
5
  "builder": {
6
- "@nuxt/module-builder": "1.0.1",
7
- "unbuild": "3.5.0"
6
+ "@nuxt/module-builder": "1.0.4",
7
+ "unbuild": "3.6.1"
8
8
  }
9
9
  }