novaapp-sdk 1.3.2 → 1.4.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/dist/index.d.ts CHANGED
@@ -195,6 +195,19 @@ interface Interaction {
195
195
  values?: string[];
196
196
  /** For MODAL_SUBMIT interactions — field customId → submitted value. */
197
197
  modalData?: Record<string, string>;
198
+ /**
199
+ * For AUTOCOMPLETE interactions — the option being completed and the
200
+ * partial string the user has typed so far.
201
+ */
202
+ autocomplete?: {
203
+ name: string;
204
+ value: string;
205
+ };
206
+ /**
207
+ * For CONTEXT_MENU interactions — the ID of the message or user that was
208
+ * right-clicked.
209
+ */
210
+ contextTargetId?: string | null;
198
211
  userId: string;
199
212
  channelId: string;
200
213
  serverId?: string | null;
@@ -241,12 +254,22 @@ interface BotModalDefinition {
241
254
  interface SlashCommandOption {
242
255
  name: string;
243
256
  description: string;
244
- type: 'STRING' | 'INTEGER' | 'BOOLEAN' | 'USER' | 'CHANNEL' | 'ROLE';
257
+ type: 'STRING' | 'INTEGER' | 'NUMBER' | 'BOOLEAN' | 'USER' | 'CHANNEL' | 'ROLE' | 'ATTACHMENT';
245
258
  required?: boolean;
259
+ /** Whether to enable autocomplete for this option. Mutually exclusive with `choices`. */
260
+ autocomplete?: boolean;
246
261
  choices?: Array<{
247
262
  name: string;
248
263
  value: string | number;
249
264
  }>;
265
+ /** Minimum value (for INTEGER / NUMBER types). */
266
+ minValue?: number;
267
+ /** Maximum value (for INTEGER / NUMBER types). */
268
+ maxValue?: number;
269
+ /** Minimum length (for STRING type). */
270
+ minLength?: number;
271
+ /** Maximum length (for STRING type). */
272
+ maxLength?: number;
250
273
  }
251
274
  interface SlashCommandDefinition {
252
275
  name: string;
@@ -292,7 +315,7 @@ interface RegisteredContextCommand {
292
315
  enabled: boolean;
293
316
  createdAt: string;
294
317
  }
295
- type BotEventType = 'message.created' | 'message.edited' | 'message.deleted' | 'message.reaction_added' | 'message.reaction_removed' | 'message.pinned' | 'user.joined_server' | 'user.left_server' | 'user.updated_profile' | 'user.banned' | 'user.unbanned' | 'user.role_added' | 'user.role_removed' | 'user.started_typing' | 'user.voice_joined' | 'user.voice_left' | 'interaction.slash_command' | 'interaction.button_click' | 'interaction.select_menu' | 'interaction.modal_submit' | 'interaction.autocomplete' | 'server.updated' | 'channel.created' | 'channel.deleted' | 'channel.updated' | 'role.created' | 'role.deleted';
318
+ type BotEventType = 'message.created' | 'message.edited' | 'message.deleted' | 'message.reaction_added' | 'message.reaction_removed' | 'message.pinned' | 'user.joined_server' | 'user.left_server' | 'user.updated_profile' | 'user.banned' | 'user.unbanned' | 'user.role_added' | 'user.role_removed' | 'user.started_typing' | 'user.voice_joined' | 'user.voice_left' | 'interaction.slash_command' | 'interaction.button_click' | 'interaction.select_menu' | 'interaction.modal_submit' | 'interaction.autocomplete' | 'server.updated' | 'channel.created' | 'channel.deleted' | 'channel.updated' | 'role.created' | 'role.updated' | 'role.deleted';
296
319
  interface BotEvent<T = unknown> {
297
320
  type: BotEventType;
298
321
  data: T;
@@ -326,6 +349,10 @@ interface FetchMessagesOptions {
326
349
  }
327
350
  interface FetchMembersOptions {
328
351
  limit?: number;
352
+ /** Return members whose role matches this value. */
353
+ role?: 'OWNER' | 'ADMIN' | 'MEMBER';
354
+ /** Filter by partial username (case-insensitive). */
355
+ search?: string;
329
356
  }
330
357
  interface PollInteractionsOptions {
331
358
  limit?: number;
@@ -403,6 +430,103 @@ interface VoiceState {
403
430
  /** ISO timestamp when the user joined the voice channel. */
404
431
  joinedAt: string;
405
432
  }
433
+ interface RoleCreateOptions {
434
+ name: string;
435
+ color?: string;
436
+ hoist?: boolean;
437
+ /**
438
+ * Permission flags to grant for this role.
439
+ * Any key not set retains its default value from the server.
440
+ */
441
+ permissions?: Partial<{
442
+ manageServer: boolean;
443
+ manageChannels: boolean;
444
+ manageRoles: boolean;
445
+ viewAuditLog: boolean;
446
+ createInvites: boolean;
447
+ manageWebhooks: boolean;
448
+ kickMembers: boolean;
449
+ banMembers: boolean;
450
+ timeoutMembers: boolean;
451
+ changeNickname: boolean;
452
+ manageNicknames: boolean;
453
+ muteMembers: boolean;
454
+ deafenMembers: boolean;
455
+ moveMembers: boolean;
456
+ sendMessages: boolean;
457
+ manageMessages: boolean;
458
+ embedLinks: boolean;
459
+ attachFiles: boolean;
460
+ addReactions: boolean;
461
+ mentionEveryone: boolean;
462
+ readMessageHistory: boolean;
463
+ }>;
464
+ }
465
+ type RoleEditOptions = Partial<RoleCreateOptions>;
466
+ interface InviteCreateOptions {
467
+ /** Maximum number of times the invite can be used. `null` = unlimited. */
468
+ maxUses?: number | null;
469
+ /** ISO timestamp when the invite expires. `null` = never expires. */
470
+ expiresAt?: string | null;
471
+ }
472
+ interface Webhook {
473
+ id: string;
474
+ serverId: string;
475
+ channelId: string;
476
+ name: string;
477
+ /** A secret token used to post messages via this webhook. */
478
+ token: string;
479
+ createdAt: string;
480
+ }
481
+ interface WebhookCreateOptions {
482
+ /** Display name shown when the webhook posts a message. */
483
+ name: string;
484
+ }
485
+ interface WebhookEditOptions {
486
+ /** New display name for the webhook. */
487
+ name?: string;
488
+ /** Move the webhook to a different text channel. */
489
+ channelId?: string;
490
+ }
491
+ interface ExecuteWebhookOptions {
492
+ content?: string;
493
+ embed?: Embed;
494
+ /** Override the default display name for this execution. */
495
+ username?: string;
496
+ }
497
+ type AuditLogAction = 'member.kicked' | 'member.banned' | 'member.unbanned' | 'member.role_added' | 'member.role_removed' | 'message.deleted' | 'message.pinned' | 'message.unpinned' | 'channel.created' | 'channel.updated' | 'channel.deleted' | 'role.created' | 'role.updated' | 'role.deleted' | 'invite.created' | 'invite.deleted' | 'webhook.created' | 'webhook.updated' | 'webhook.deleted' | 'server.updated' | string;
498
+ interface AuditLogEntry {
499
+ id: string;
500
+ serverId: string;
501
+ action: AuditLogAction;
502
+ /** The user who performed the action. */
503
+ actorId: string;
504
+ actorName: string;
505
+ /** The entity affected (user, channel, role, etc.). */
506
+ targetId: string | null;
507
+ targetName: string | null;
508
+ /** Extra context (old/new values, reason, etc.). */
509
+ metadata: Record<string, unknown> | null;
510
+ createdAt: string;
511
+ }
512
+ interface FetchAuditLogsOptions {
513
+ limit?: number;
514
+ /** Only return entries for a specific action type. */
515
+ action?: AuditLogAction;
516
+ /** Only return entries targeting a specific user ID. */
517
+ userId?: string;
518
+ before?: string;
519
+ }
520
+ interface ServerUpdateOptions {
521
+ name?: string;
522
+ description?: string;
523
+ icon?: string | null;
524
+ }
525
+ /** Extended member object returned when fetching a single member by user ID. */
526
+ interface SingleMember extends Member {
527
+ /** The custom role assigned to this member, if any. */
528
+ customRole: Role | null;
529
+ }
406
530
  interface NovaClientOptions {
407
531
  /** Your bot token — starts with "nova_bot_" */
408
532
  token: string;
@@ -585,11 +709,24 @@ declare class MembersAPI {
585
709
  constructor(http: HttpClient);
586
710
  /**
587
711
  * Fetch members of a server the bot is in.
712
+ * Supports filtering by role and searching by username/displayName.
588
713
  *
589
714
  * @example
590
715
  * const members = await client.members.list('server-id', { limit: 50 })
716
+ * const admins = await client.members.list('server-id', { role: 'ADMIN' })
717
+ * const found = await client.members.list('server-id', { search: 'john' })
591
718
  */
592
719
  list(serverId: string, options?: FetchMembersOptions): Promise<Member[]>;
720
+ /**
721
+ * Fetch a single member from a server by their user ID.
722
+ * Returns the member's custom role if assigned.
723
+ * Requires the `members.read` scope.
724
+ *
725
+ * @example
726
+ * const member = await client.members.fetch('server-id', 'user-id')
727
+ * console.log(member.customRole?.name ?? 'No custom role')
728
+ */
729
+ fetch(serverId: string, userId: string): Promise<SingleMember>;
593
730
  /**
594
731
  * Kick a member from a server.
595
732
  * Bots cannot kick owners or admins (403 will be thrown).
@@ -673,6 +810,23 @@ declare class ServersAPI {
673
810
  * console.log(`Bot is in ${servers.length} servers`)
674
811
  */
675
812
  list(): Promise<NovaServer[]>;
813
+ /**
814
+ * Fetch a single server by ID.
815
+ * The bot must be a member of the server.
816
+ *
817
+ * @example
818
+ * const server = await client.servers.fetch('server-id')
819
+ * console.log(`${server.name} — ${server.memberCount} members`)
820
+ */
821
+ fetch(serverId: string): Promise<NovaServer>;
822
+ /**
823
+ * Update a server's name, description, or icon.
824
+ * Requires the `server.manage` scope.
825
+ *
826
+ * @example
827
+ * await client.servers.update('server-id', { name: 'Better Name', description: 'A great place!' })
828
+ */
829
+ update(serverId: string, options: ServerUpdateOptions): Promise<NovaServer>;
676
830
  /**
677
831
  * Fetch all roles in a server.
678
832
  * Results are sorted by position (lowest first).
@@ -716,6 +870,26 @@ declare class InteractionsAPI {
716
870
  ok: true;
717
871
  ephemeral: true;
718
872
  }>;
873
+ /**
874
+ * Respond to an autocomplete interaction with a list of suggested choices.
875
+ * The gateway fires `AUTOCOMPLETE` interactions when a user is typing in
876
+ * an option that has `autocomplete: true`. Call this within ~3 seconds.
877
+ *
878
+ * @example
879
+ * client.autocomplete('search', async (interaction) => {
880
+ * const query = interaction.autocomplete?.value ?? ''
881
+ * const results = await db.search(query)
882
+ * await client.interactions.autocomplete(interaction.id,
883
+ * results.map(r => ({ name: r.title, value: r.id }))
884
+ * )
885
+ * })
886
+ */
887
+ autocomplete(interactionId: string, choices: Array<{
888
+ name: string;
889
+ value: string | number;
890
+ }>): Promise<{
891
+ ok: true;
892
+ }>;
719
893
  /**
720
894
  * Poll for pending (unacknowledged) interactions.
721
895
  * Useful when not using the WebSocket gateway.
@@ -945,6 +1119,201 @@ declare class ReactionsAPI {
945
1119
  fetchEmoji(messageId: string, emoji: string): Promise<ReactionDetail>;
946
1120
  }
947
1121
 
1122
+ declare class RolesAPI {
1123
+ private readonly http;
1124
+ constructor(http: HttpClient);
1125
+ /**
1126
+ * List all custom roles in a server, sorted by position.
1127
+ *
1128
+ * @example
1129
+ * const roles = await client.roles.list('server-id')
1130
+ * const adminRole = roles.find(r => r.name === 'Admin')
1131
+ */
1132
+ list(serverId: string): Promise<Role[]>;
1133
+ /**
1134
+ * Create a new custom role in a server.
1135
+ * Requires the `roles.manage` scope.
1136
+ *
1137
+ * @example
1138
+ * const role = await client.roles.create('server-id', {
1139
+ * name: 'Verified',
1140
+ * color: '#00d4ff',
1141
+ * hoist: true,
1142
+ * permissions: { sendMessages: true, addReactions: true },
1143
+ * })
1144
+ */
1145
+ create(serverId: string, options: RoleCreateOptions): Promise<Role>;
1146
+ /**
1147
+ * Edit an existing role.
1148
+ * Requires the `roles.manage` scope.
1149
+ *
1150
+ * @example
1151
+ * await client.roles.edit('role-id', { color: '#ff0000', name: 'Danger' })
1152
+ */
1153
+ edit(roleId: string, options: RoleEditOptions): Promise<Role>;
1154
+ /**
1155
+ * Delete a custom role from a server.
1156
+ * Any member currently assigned this role will have it removed automatically.
1157
+ * Requires the `roles.manage` scope.
1158
+ *
1159
+ * @example
1160
+ * await client.roles.delete('role-id')
1161
+ */
1162
+ delete(roleId: string): Promise<{
1163
+ ok: true;
1164
+ }>;
1165
+ /**
1166
+ * Assign a custom role to a server member.
1167
+ * Requires the `members.roles` scope.
1168
+ *
1169
+ * @example
1170
+ * await client.roles.assign('server-id', 'user-id', 'role-id')
1171
+ */
1172
+ assign(serverId: string, userId: string, roleId: string): Promise<{
1173
+ ok: true;
1174
+ }>;
1175
+ /**
1176
+ * Remove a custom role from a server member.
1177
+ * Requires the `members.roles` scope.
1178
+ *
1179
+ * @example
1180
+ * await client.roles.remove('server-id', 'user-id', 'role-id')
1181
+ */
1182
+ remove(serverId: string, userId: string, roleId: string): Promise<{
1183
+ ok: true;
1184
+ }>;
1185
+ }
1186
+
1187
+ declare class InvitesAPI {
1188
+ private readonly http;
1189
+ constructor(http: HttpClient);
1190
+ /**
1191
+ * List all active invites for a server.
1192
+ *
1193
+ * @example
1194
+ * const invites = await client.invites.list('server-id')
1195
+ * console.log(`${invites.length} active invites`)
1196
+ */
1197
+ list(serverId: string): Promise<Invite[]>;
1198
+ /**
1199
+ * Create a new invite for a server.
1200
+ * Requires the `invites.manage` scope.
1201
+ *
1202
+ * @example
1203
+ * // A one-time invite that expires in 24 hours
1204
+ * const invite = await client.invites.create('server-id', {
1205
+ * maxUses: 1,
1206
+ * expiresAt: new Date(Date.now() + 86_400_000).toISOString(),
1207
+ * })
1208
+ * console.log(`https://novachatapp.com/invite/${invite.code}`)
1209
+ */
1210
+ create(serverId: string, options?: InviteCreateOptions): Promise<Invite>;
1211
+ /**
1212
+ * Fetch a single invite by its code.
1213
+ *
1214
+ * @example
1215
+ * const invite = await client.invites.fetch('abc123')
1216
+ * console.log(`${invite.uses} / ${invite.maxUses ?? '∞'} uses`)
1217
+ */
1218
+ fetch(code: string): Promise<Invite>;
1219
+ /**
1220
+ * Revoke (delete) an invite.
1221
+ * Requires the `invites.manage` scope.
1222
+ *
1223
+ * @example
1224
+ * await client.invites.revoke('abc123')
1225
+ */
1226
+ revoke(code: string): Promise<{
1227
+ ok: true;
1228
+ }>;
1229
+ }
1230
+
1231
+ declare class WebhooksAPI {
1232
+ private readonly http;
1233
+ constructor(http: HttpClient);
1234
+ /**
1235
+ * List all webhooks in a channel.
1236
+ * Requires the `webhooks.manage` scope.
1237
+ *
1238
+ * @example
1239
+ * const webhooks = await client.webhooks.list('channel-id')
1240
+ */
1241
+ list(channelId: string): Promise<Webhook[]>;
1242
+ /**
1243
+ * Create a webhook in a channel.
1244
+ * Requires the `webhooks.manage` scope.
1245
+ *
1246
+ * @example
1247
+ * const webhook = await client.webhooks.create('channel-id', { name: 'Announcements' })
1248
+ * console.log('Token:', webhook.token)
1249
+ */
1250
+ create(channelId: string, options: WebhookCreateOptions): Promise<Webhook>;
1251
+ /**
1252
+ * Fetch a webhook by its ID.
1253
+ * Requires the `webhooks.manage` scope.
1254
+ *
1255
+ * @example
1256
+ * const webhook = await client.webhooks.fetch('webhook-id')
1257
+ */
1258
+ fetch(webhookId: string): Promise<Webhook>;
1259
+ /**
1260
+ * Edit a webhook's name and/or target channel.
1261
+ * Requires the `webhooks.manage` scope.
1262
+ *
1263
+ * @example
1264
+ * await client.webhooks.edit('webhook-id', { name: 'New Name', channelId: 'other-channel' })
1265
+ */
1266
+ edit(webhookId: string, options: WebhookEditOptions): Promise<Webhook>;
1267
+ /**
1268
+ * Delete a webhook.
1269
+ * Requires the `webhooks.manage` scope.
1270
+ *
1271
+ * @example
1272
+ * await client.webhooks.delete('webhook-id')
1273
+ */
1274
+ delete(webhookId: string): Promise<{
1275
+ ok: true;
1276
+ }>;
1277
+ /**
1278
+ * Execute a webhook — post a message to the webhook's channel.
1279
+ * Does not require any extra scope (uses the webhook data already owned by
1280
+ * this bot application).
1281
+ *
1282
+ * @example
1283
+ * await client.webhooks.execute('webhook-id', {
1284
+ * content: '🚀 Deployment successful!',
1285
+ * username: 'Deploy Bot',
1286
+ * })
1287
+ */
1288
+ execute(webhookId: string, options: ExecuteWebhookOptions): Promise<Message>;
1289
+ }
1290
+
1291
+ declare class AuditLogAPI {
1292
+ private readonly http;
1293
+ constructor(http: HttpClient);
1294
+ /**
1295
+ * Fetch the audit log for a server.
1296
+ * Requires the `audit-log.read` scope.
1297
+ *
1298
+ * You can filter by action type, actor user ID, and paginate backwards
1299
+ * using the `before` cursor (an ISO timestamp).
1300
+ *
1301
+ * @example
1302
+ * // Most recent 50 entries
1303
+ * const entries = await client.auditLog.fetch('server-id')
1304
+ *
1305
+ * // Only kick and ban actions
1306
+ * const modActions = await client.auditLog.fetch('server-id', {
1307
+ * action: 'member.banned',
1308
+ * limit: 20,
1309
+ * })
1310
+ *
1311
+ * // All actions performed by a specific user
1312
+ * const byUser = await client.auditLog.fetch('server-id', { userId: 'user-id' })
1313
+ */
1314
+ fetch(serverId: string, options?: FetchAuditLogsOptions): Promise<AuditLogEntry[]>;
1315
+ }
1316
+
948
1317
  type TextInputStyle = 'short' | 'paragraph';
949
1318
  /**
950
1319
  * Fluent builder for a single text-input field inside a modal.
@@ -1130,6 +1499,21 @@ declare class NovaInteraction {
1130
1499
  */
1131
1500
  readonly options: InteractionOptions;
1132
1501
  constructor(_raw: Interaction, _api: InteractionsAPI);
1502
+ /**
1503
+ * For `AUTOCOMPLETE` interactions — the option being completed.
1504
+ * Contains `name` (option name) and `value` (partial text typed so far).
1505
+ * `null` for all other interaction types.
1506
+ *
1507
+ * @example
1508
+ * client.autocomplete('search', async (interaction) => {
1509
+ * const query = interaction.autocomplete?.value ?? ''
1510
+ * await interaction.respondAutocomplete([{ name: query, value: query }])
1511
+ * })
1512
+ */
1513
+ get autocomplete(): {
1514
+ name: string;
1515
+ value: string;
1516
+ } | null;
1133
1517
  /** `true` when triggered by a `/slash` command. */
1134
1518
  isSlashCommand(): boolean;
1135
1519
  /** `true` when triggered by a `!prefix` command. */
@@ -1144,6 +1528,24 @@ declare class NovaInteraction {
1144
1528
  isModalSubmit(): boolean;
1145
1529
  /** `true` during autocomplete suggestion requests. */
1146
1530
  isAutocomplete(): boolean;
1531
+ /**
1532
+ * Send autocomplete suggestions back to the user.
1533
+ * Call this inside a `client.autocomplete()` handler.
1534
+ * Up to 25 choices are shown; each needs a `name` (displayed) and `value` (submitted).
1535
+ *
1536
+ * @example
1537
+ * client.autocomplete('color', async (interaction) => {
1538
+ * const query = interaction.autocomplete?.value ?? ''
1539
+ * const colors = ['red', 'green', 'blue'].filter(c => c.startsWith(query))
1540
+ * await interaction.respondAutocomplete(colors.map(c => ({ name: c, value: c })))
1541
+ * })
1542
+ */
1543
+ respondAutocomplete(choices: Array<{
1544
+ name: string;
1545
+ value: string | number;
1546
+ }>): Promise<{
1547
+ ok: true;
1548
+ }>;
1147
1549
  /** `true` when triggered via a context-menu command. */
1148
1550
  isContextMenu(): boolean;
1149
1551
  /**
@@ -1562,6 +1964,304 @@ declare class NovaMember {
1562
1964
  toJSON(): Member;
1563
1965
  }
1564
1966
 
1967
+ /**
1968
+ * A rich wrapper around a raw `Role` with convenience methods.
1969
+ *
1970
+ * Returned by `client.fetchRole()` and `client.fetchRoles()`.
1971
+ *
1972
+ * @example
1973
+ * const roles = await client.fetchRoles('server-id')
1974
+ * const mod = roles.find(r => r.name === 'Moderator')
1975
+ * if (mod) await mod.assign('user-id')
1976
+ */
1977
+ declare class NovaRole {
1978
+ /** Unique role ID. */
1979
+ readonly id: string;
1980
+ /** Display name of the role. */
1981
+ readonly name: string;
1982
+ /** Hex colour string (e.g. `'#00d4ff'`), or `null` for no colour. */
1983
+ readonly color: string | null;
1984
+ /** Sort position — lower numbers appear higher in the role list. */
1985
+ readonly position: number;
1986
+ /** The server this role belongs to. */
1987
+ readonly serverId: string;
1988
+ /** Whether this role is displayed separately in the member sidebar. */
1989
+ readonly hoist: boolean;
1990
+ /** When the role was created. */
1991
+ readonly createdAt: Date;
1992
+ private readonly _roles;
1993
+ constructor(raw: Role, roles: RolesAPI);
1994
+ /**
1995
+ * Edit this role's name, colour, hoist flag, or permissions.
1996
+ *
1997
+ * @example
1998
+ * await role.edit({ color: '#ff0000', name: 'Red Team' })
1999
+ */
2000
+ edit(options: RoleEditOptions): Promise<Role>;
2001
+ /**
2002
+ * Delete this role from the server.
2003
+ * Any members currently assigned this role will have it removed.
2004
+ *
2005
+ * @example
2006
+ * await role.delete()
2007
+ */
2008
+ delete(): Promise<{
2009
+ ok: true;
2010
+ }>;
2011
+ /**
2012
+ * Assign this role to a server member.
2013
+ *
2014
+ * @example
2015
+ * await role.assign('user-id')
2016
+ */
2017
+ assign(userId: string): Promise<{
2018
+ ok: true;
2019
+ }>;
2020
+ /**
2021
+ * Remove this role from a server member.
2022
+ *
2023
+ * @example
2024
+ * await role.remove('user-id')
2025
+ */
2026
+ remove(userId: string): Promise<{
2027
+ ok: true;
2028
+ }>;
2029
+ /** Returns `true` if the role has a custom hex colour set. */
2030
+ hasColor(): boolean;
2031
+ /** Returns the CSS-safe hex colour string. Falls back to `'#99aab5'` (grey). */
2032
+ toHex(): string;
2033
+ toJSON(): Role;
2034
+ }
2035
+
2036
+ /**
2037
+ * A rich wrapper around a raw `NovaServer` with convenience methods.
2038
+ *
2039
+ * Returned by `client.fetchServer()` and `client.fetchServers()`.
2040
+ *
2041
+ * @example
2042
+ * const server = await client.fetchServer('server-id')
2043
+ * console.log(`${server.name} — ${server.memberCount} members`)
2044
+ * await server.send('welcome-channel-id', 'Bot is online! 🤖')
2045
+ */
2046
+ declare class NovaServerWrapper {
2047
+ /** Unique server ID. */
2048
+ readonly id: string;
2049
+ /** Server display name. */
2050
+ readonly name: string;
2051
+ /** URL to the server icon, or `null`. */
2052
+ readonly icon: string | null;
2053
+ /** Short description of the server, or `null`. */
2054
+ readonly description: string | null;
2055
+ /** Total member count at time of fetch. */
2056
+ readonly memberCount: number;
2057
+ /** Total channel count at time of fetch. */
2058
+ readonly channelCount: number;
2059
+ /** When the bot joined this server. */
2060
+ readonly joinedAt: Date;
2061
+ private readonly _servers;
2062
+ private readonly _channels;
2063
+ private readonly _members;
2064
+ private readonly _invites;
2065
+ private readonly _roles;
2066
+ private readonly _messages;
2067
+ constructor(raw: NovaServer, servers: ServersAPI, channels: ChannelsAPI, members: MembersAPI, invites: InvitesAPI, roles: RolesAPI, messages: MessagesAPI);
2068
+ /**
2069
+ * Update this server's name, description, or icon.
2070
+ * Requires the `server.manage` scope.
2071
+ *
2072
+ * @example
2073
+ * await server.update({ name: 'New Name' })
2074
+ */
2075
+ update(options: ServerUpdateOptions): Promise<NovaServer>;
2076
+ /**
2077
+ * Fetch all channels in this server.
2078
+ *
2079
+ * @example
2080
+ * const channels = await server.fetchChannels()
2081
+ * const text = channels.filter(c => c.type === 'TEXT')
2082
+ */
2083
+ fetchChannels(): Promise<Channel[]>;
2084
+ /**
2085
+ * Create a new channel in this server.
2086
+ * Requires the `channels.manage` scope.
2087
+ *
2088
+ * @example
2089
+ * const ch = await server.createChannel({ name: 'bot-logs', type: 'TEXT' })
2090
+ */
2091
+ createChannel(options: CreateChannelOptions): Promise<Channel>;
2092
+ /**
2093
+ * Fetch members in this server.
2094
+ *
2095
+ * @example
2096
+ * const members = await server.fetchMembers({ limit: 100 })
2097
+ */
2098
+ fetchMembers(options?: FetchMembersOptions): Promise<Member[]>;
2099
+ /**
2100
+ * Fetch a single member by user ID.
2101
+ *
2102
+ * @example
2103
+ * const member = await server.fetchMember('user-id')
2104
+ */
2105
+ fetchMember(userId: string): ReturnType<MembersAPI['fetch']>;
2106
+ /**
2107
+ * Kick a member from this server.
2108
+ *
2109
+ * @example
2110
+ * await server.kick('user-id')
2111
+ */
2112
+ kick(userId: string): Promise<{
2113
+ ok: true;
2114
+ }>;
2115
+ /**
2116
+ * Ban a member from this server.
2117
+ *
2118
+ * @example
2119
+ * await server.ban('user-id', 'Spamming')
2120
+ */
2121
+ ban(userId: string, reason?: string): Promise<{
2122
+ ok: true;
2123
+ }>;
2124
+ /**
2125
+ * Fetch the ban list for this server.
2126
+ */
2127
+ fetchBans(): Promise<BanEntry[]>;
2128
+ /**
2129
+ * Fetch all custom roles in this server.
2130
+ *
2131
+ * @example
2132
+ * const roles = await server.fetchRoles()
2133
+ */
2134
+ fetchRoles(): Promise<Role[]>;
2135
+ /**
2136
+ * Fetch all active invites for this server.
2137
+ *
2138
+ * @example
2139
+ * const invites = await server.fetchInvites()
2140
+ */
2141
+ fetchInvites(): Promise<Invite[]>;
2142
+ /**
2143
+ * Create an invite for this server.
2144
+ *
2145
+ * @example
2146
+ * const invite = await server.createInvite({ maxUses: 10 })
2147
+ * console.log(`https://novachatapp.com/invite/${invite.code}`)
2148
+ */
2149
+ createInvite(options?: InviteCreateOptions): Promise<Invite>;
2150
+ /**
2151
+ * Send a message to a channel in this server by channel ID.
2152
+ *
2153
+ * @example
2154
+ * await server.send('channel-id', 'Hello, server!')
2155
+ */
2156
+ send(channelId: string, content: string): ReturnType<MessagesAPI['send']>;
2157
+ toJSON(): NovaServer;
2158
+ }
2159
+
2160
+ /**
2161
+ * A rich wrapper around a raw `Invite` with convenience methods.
2162
+ *
2163
+ * Returned by `client.fetchInvite()` and `client.fetchInvites()`.
2164
+ *
2165
+ * @example
2166
+ * const invite = await client.fetchInvite('abc123')
2167
+ * if (invite.isExpired()) await invite.revoke()
2168
+ */
2169
+ declare class NovaInvite {
2170
+ /** The invite code — appended to `https://novachatapp.com/invite/`. */
2171
+ readonly code: string;
2172
+ /** The server this invite grants access to. */
2173
+ readonly serverId: string;
2174
+ /** The user ID of whoever created this invite. */
2175
+ readonly creatorId: string;
2176
+ /** How many times this invite has been used. */
2177
+ readonly uses: number;
2178
+ /** Maximum allowed uses before the invite deactivates. `null` = unlimited. */
2179
+ readonly maxUses: number | null;
2180
+ /** When the invite expires. `null` = never expires. */
2181
+ readonly expiresAt: Date | null;
2182
+ /** When the invite was created. */
2183
+ readonly createdAt: Date;
2184
+ private readonly _invites;
2185
+ constructor(raw: Invite, invites: InvitesAPI);
2186
+ /** The full URL users can follow to join the server. */
2187
+ get url(): string;
2188
+ /**
2189
+ * Returns `true` if the invite has passed its expiry time.
2190
+ * Always `false` for invites with no expiry.
2191
+ */
2192
+ isExpired(): boolean;
2193
+ /**
2194
+ * Returns `true` if the invite has reached its maximum use count.
2195
+ * Always `false` for unlimited invites.
2196
+ */
2197
+ isExhausted(): boolean;
2198
+ /** Whether this invite is still usable (not expired and not exhausted). */
2199
+ isValid(): boolean;
2200
+ /**
2201
+ * Revoke (delete) this invite, making the code unusable.
2202
+ * Requires the `invites.manage` scope.
2203
+ *
2204
+ * @example
2205
+ * await invite.revoke()
2206
+ */
2207
+ revoke(): Promise<{
2208
+ ok: true;
2209
+ }>;
2210
+ toJSON(): Invite;
2211
+ }
2212
+
2213
+ /**
2214
+ * A rich wrapper around a raw `Webhook` with convenience methods.
2215
+ *
2216
+ * Returned by `client.fetchWebhook()` and `client.fetchWebhooks()`.
2217
+ *
2218
+ * @example
2219
+ * const webhook = await client.fetchWebhook('webhook-id')
2220
+ * await webhook.execute({ content: '🚀 Build passed!', username: 'CI Bot' })
2221
+ */
2222
+ declare class NovaWebhook {
2223
+ /** Unique webhook ID. */
2224
+ readonly id: string;
2225
+ /** The server this webhook belongs to. */
2226
+ readonly serverId: string;
2227
+ /** The channel messages are posted to when this webhook is executed. */
2228
+ readonly channelId: string;
2229
+ /** Display name shown next to messages posted via this webhook. */
2230
+ readonly name: string;
2231
+ /** Secret token — required to execute the webhook via HTTP. */
2232
+ readonly token: string;
2233
+ /** When the webhook was created. */
2234
+ readonly createdAt: Date;
2235
+ private readonly _webhooks;
2236
+ constructor(raw: Webhook, webhooks: WebhooksAPI);
2237
+ /**
2238
+ * Edit this webhook's name or target channel.
2239
+ * Requires the `webhooks.manage` scope.
2240
+ *
2241
+ * @example
2242
+ * await webhook.edit({ name: 'New Name', channelId: 'other-channel-id' })
2243
+ */
2244
+ edit(options: WebhookEditOptions): Promise<Webhook>;
2245
+ /**
2246
+ * Delete this webhook.
2247
+ * Requires the `webhooks.manage` scope.
2248
+ *
2249
+ * @example
2250
+ * await webhook.delete()
2251
+ */
2252
+ delete(): Promise<{
2253
+ ok: true;
2254
+ }>;
2255
+ /**
2256
+ * Post a message via this webhook.
2257
+ *
2258
+ * @example
2259
+ * await webhook.execute({ content: '❌ Tests failed on branch main', username: 'CI' })
2260
+ */
2261
+ execute(options: ExecuteWebhookOptions): Promise<Message>;
2262
+ toJSON(): Webhook;
2263
+ }
2264
+
1565
2265
  interface NovaClientEvents {
1566
2266
  /** Fired when the bot connects and is identified by the gateway. */
1567
2267
  ready: (bot: BotApplication) => void;
@@ -1569,8 +2269,8 @@ interface NovaClientEvents {
1569
2269
  event: (event: BotEvent) => void;
1570
2270
  /**
1571
2271
  * Fired when an interaction is received (slash command, button click, etc.).
1572
- * Use `client.command()`, `client.button()`, or `client.selectMenu()` for
1573
- * convenient routing instead of handling everything here.
2272
+ * Use `client.command()`, `client.button()`, `client.selectMenu()`, or
2273
+ * `client.autocomplete()` for convenient routing instead of handling everything here.
1574
2274
  */
1575
2275
  interactionCreate: (interaction: NovaInteraction) => void;
1576
2276
  /** Fired when the WebSocket connection drops. */
@@ -1635,15 +2335,9 @@ interface NovaClientEvents {
1635
2335
  serverId: string;
1636
2336
  }) => void;
1637
2337
  /** A role was created in a server. */
1638
- roleCreate: (data: {
1639
- id: string;
1640
- name: string;
1641
- color: string | null;
1642
- serverId: string;
1643
- position: number;
1644
- hoist: boolean;
1645
- createdAt: string;
1646
- }) => void;
2338
+ roleCreate: (role: Role) => void;
2339
+ /** A role was updated. */
2340
+ roleUpdate: (role: Role) => void;
1647
2341
  /** A role was deleted. */
1648
2342
  roleDelete: (data: {
1649
2343
  id: string;
@@ -1673,11 +2367,36 @@ interface NovaClientEvents {
1673
2367
  userId: string;
1674
2368
  serverId: string;
1675
2369
  }) => void;
2370
+ /** A member received or lost a custom role. */
2371
+ memberRoleAdded: (data: {
2372
+ serverId: string;
2373
+ userId: string;
2374
+ roleId: string;
2375
+ }) => void;
2376
+ memberRoleRemoved: (data: {
2377
+ serverId: string;
2378
+ userId: string;
2379
+ roleId: string;
2380
+ }) => void;
1676
2381
  /** A member's profile data was updated. */
1677
2382
  memberUpdate: (data: {
1678
2383
  userId: string;
1679
2384
  serverId: string;
1680
2385
  }) => void;
2386
+ /** Server metadata (name, icon, etc.) was updated. */
2387
+ serverUpdate: (data: {
2388
+ id: string;
2389
+ name?: string;
2390
+ icon?: string | null;
2391
+ description?: string | null;
2392
+ }) => void;
2393
+ /** An invite was created. */
2394
+ inviteCreate: (invite: Invite) => void;
2395
+ /** An invite was deleted/revoked. */
2396
+ inviteDelete: (data: {
2397
+ code: string;
2398
+ serverId: string;
2399
+ }) => void;
1681
2400
  }
1682
2401
  /**
1683
2402
  * The main Nova bot client.
@@ -1706,9 +2425,9 @@ declare class NovaClient extends EventEmitter {
1706
2425
  readonly messages: MessagesAPI;
1707
2426
  /** Register and manage slash, prefix, and context menu commands. */
1708
2427
  readonly commands: CommandsAPI;
1709
- /** List, kick and ban server members. */
2428
+ /** List, kick, ban, and DM server members. */
1710
2429
  readonly members: MembersAPI;
1711
- /** List servers the bot is a member of. */
2430
+ /** List and update servers the bot is a member of. */
1712
2431
  readonly servers: ServersAPI;
1713
2432
  /** Acknowledge and respond to interactions. */
1714
2433
  readonly interactions: InteractionsAPI;
@@ -1718,6 +2437,14 @@ declare class NovaClient extends EventEmitter {
1718
2437
  readonly channels: ChannelsAPI;
1719
2438
  /** Add, remove and fetch reactions on messages. */
1720
2439
  readonly reactions: ReactionsAPI;
2440
+ /** Create, edit, delete and assign custom roles. */
2441
+ readonly roles: RolesAPI;
2442
+ /** Create, fetch and revoke server invites. */
2443
+ readonly invites: InvitesAPI;
2444
+ /** Create, edit, delete and execute webhooks. */
2445
+ readonly webhooks: WebhooksAPI;
2446
+ /** Fetch server audit logs. */
2447
+ readonly auditLog: AuditLogAPI;
1721
2448
  private socket;
1722
2449
  private readonly http;
1723
2450
  private readonly options;
@@ -1726,6 +2453,7 @@ declare class NovaClient extends EventEmitter {
1726
2453
  private readonly _buttonHandlers;
1727
2454
  private readonly _selectHandlers;
1728
2455
  private readonly _modalHandlers;
2456
+ private readonly _autocompleteHandlers;
1729
2457
  constructor(options: NovaClientOptions);
1730
2458
  /**
1731
2459
  * Register a handler for a slash or prefix command by name.
@@ -1767,6 +2495,23 @@ declare class NovaClient extends EventEmitter {
1767
2495
  * })
1768
2496
  */
1769
2497
  modal(customId: string, handler: (interaction: NovaInteraction) => unknown): this;
2498
+ /**
2499
+ * Register a handler for an autocomplete interaction by command name.
2500
+ * Called when the user is typing in an option with `autocomplete: true`.
2501
+ * The handler receives the interaction with `interaction.autocomplete.value`
2502
+ * containing the partial text, and should call `interaction.respondAutocomplete()`
2503
+ * to send completion suggestions.
2504
+ *
2505
+ * @example
2506
+ * client.autocomplete('search', async (interaction) => {
2507
+ * const query = interaction.autocomplete?.value ?? ''
2508
+ * const results = await myDB.search(query)
2509
+ * await interaction.respondAutocomplete(
2510
+ * results.map(r => ({ name: r.label, value: r.id }))
2511
+ * )
2512
+ * })
2513
+ */
2514
+ autocomplete(commandName: string, handler: (interaction: NovaInteraction) => unknown): this;
1770
2515
  /**
1771
2516
  * Connect to the Nova WebSocket gateway.
1772
2517
  * Resolves when the `ready` event is received.
@@ -1828,13 +2573,68 @@ declare class NovaClient extends EventEmitter {
1828
2573
  fetchMembers(serverId: string): Promise<NovaMember[]>;
1829
2574
  /**
1830
2575
  * Fetch a single member from a server and return them as a `NovaMember` wrapper.
1831
- * Throws if the user is not found in the server.
2576
+ * Uses the dedicated single-member endpoint (more efficient than listing all members).
1832
2577
  *
1833
2578
  * @example
1834
2579
  * const member = await client.fetchMember('server-id', 'user-id')
1835
2580
  * await member.dm('Welcome!')
1836
2581
  */
1837
2582
  fetchMember(serverId: string, userId: string): Promise<NovaMember>;
2583
+ /**
2584
+ * Fetch a single server by ID and return it as a `NovaServerWrapper`.
2585
+ *
2586
+ * @example
2587
+ * const server = await client.fetchServer('server-id')
2588
+ * console.log(`${server.name} — ${server.memberCount} members`)
2589
+ */
2590
+ fetchServer(serverId: string): Promise<NovaServerWrapper>;
2591
+ /**
2592
+ * Fetch all servers the bot is in and return them as `NovaServerWrapper` objects.
2593
+ *
2594
+ * @example
2595
+ * const servers = await client.fetchServers()
2596
+ * for (const s of servers) console.log(s.name)
2597
+ */
2598
+ fetchServers(): Promise<NovaServerWrapper[]>;
2599
+ /**
2600
+ * Fetch all custom roles in a server and return them as `NovaRole` wrappers.
2601
+ *
2602
+ * @example
2603
+ * const roles = await client.fetchRoles('server-id')
2604
+ * const mod = roles.find(r => r.name === 'Moderator')
2605
+ */
2606
+ fetchRoles(serverId: string): Promise<NovaRole[]>;
2607
+ /**
2608
+ * Fetch all active invites for a server and return them as `NovaInvite` wrappers.
2609
+ *
2610
+ * @example
2611
+ * const invites = await client.fetchInvites('server-id')
2612
+ * const active = invites.filter(i => i.isValid())
2613
+ */
2614
+ fetchInvites(serverId: string): Promise<NovaInvite[]>;
2615
+ /**
2616
+ * Fetch a single invite by code and return it as a `NovaInvite` wrapper.
2617
+ *
2618
+ * @example
2619
+ * const invite = await client.fetchInvite('abc123')
2620
+ * if (invite.isExpired()) await invite.revoke()
2621
+ */
2622
+ fetchInvite(code: string): Promise<NovaInvite>;
2623
+ /**
2624
+ * Fetch all webhooks in a channel and return them as `NovaWebhook` wrappers.
2625
+ *
2626
+ * @example
2627
+ * const webhooks = await client.fetchWebhooks('channel-id')
2628
+ */
2629
+ fetchWebhooks(channelId: string): Promise<NovaWebhook[]>;
2630
+ /**
2631
+ * Fetch a single webhook by ID and return it as a `NovaWebhook` wrapper.
2632
+ *
2633
+ * @example
2634
+ * const webhook = await client.fetchWebhook('webhook-id')
2635
+ * await webhook.execute({ content: 'Build passed! ✅' })
2636
+ */
2637
+ fetchWebhook(webhookId: string): Promise<NovaWebhook>;
1838
2638
  /**
1839
2639
  * Wait for a specific event to be emitted, optionally filtered.
1840
2640
  * Rejects after `timeoutMs` (default 30 s) if the condition never fires.
@@ -2853,4 +3653,4 @@ declare function countdown(target: Date | number | string): {
2853
3653
  total: number;
2854
3654
  };
2855
3655
 
2856
- export { ActionRowBuilder, type Attachment, type BanEntry, type BotApplication, type BotEvent, type BotEventType, type BotModalDefinition, type BotModalField, type BotPermissionRecord, type BotStatus, type BotUser, ButtonBuilder, type ButtonStyle, type Channel, type ChannelType, ChannelsAPI, Collection, CommandsAPI, type ContextCommandDefinition, Cooldown, CooldownManager, type CreateChannelOptions, type DirectMessage, type EditChannelOptions, type EditMessageOptions, type Embed, EmbedBuilder, type EmbedField, type FetchChannelsOptions, type FetchMembersOptions, type FetchMessagesOptions, HttpClient, type Interaction, InteractionOptions, type InteractionType, InteractionsAPI, type Invite, Logger, type Member, MembersAPI, type Message, MessageBuilder, type MessageComponent, MessagesAPI, ModalBuilder, NovaChannel, NovaClient, type NovaClientEvents, type NovaClientOptions, NovaInteraction, NovaMember, NovaMessage, type NovaServer, Paginator, type PermissionKey, Permissions, PermissionsAPI, PermissionsBitfield, type PermissionsQueryOptions, type PermissionsResult, PollBuilder, type PollDefinition, type PollInteractionsOptions, type PollOption, type PrefixCommandDefinition, type Reaction, type ReactionDetail, ReactionsAPI, type RegisteredContextCommand, type RegisteredPrefixCommand, type RegisteredSlashCommand, type RespondInteractionOptions, type Role, SelectMenuBuilder, type SelectMenuOption, type SendMessageOptions, ServersAPI, SlashCommandBuilder, type SlashCommandDefinition, type SlashCommandOption, SlashCommandOptionBuilder, TextInputBuilder, type TextInputStyle, type VoiceState, countdown, formatDuration, formatRelative, parseTimestamp, sleep, withTimeout };
3656
+ export { ActionRowBuilder, type Attachment, AuditLogAPI, type AuditLogAction, type AuditLogEntry, type BanEntry, type BotApplication, type BotEvent, type BotEventType, type BotModalDefinition, type BotModalField, type BotPermissionRecord, type BotStatus, type BotUser, ButtonBuilder, type ButtonStyle, type Channel, type ChannelType, ChannelsAPI, Collection, CommandsAPI, type ContextCommandDefinition, Cooldown, CooldownManager, type CreateChannelOptions, type DirectMessage, type EditChannelOptions, type EditMessageOptions, type Embed, EmbedBuilder, type EmbedField, type ExecuteWebhookOptions, type FetchAuditLogsOptions, type FetchChannelsOptions, type FetchMembersOptions, type FetchMessagesOptions, HttpClient, type Interaction, InteractionOptions, type InteractionType, InteractionsAPI, type Invite, type InviteCreateOptions, InvitesAPI, Logger, type Member, MembersAPI, type Message, MessageBuilder, type MessageComponent, MessagesAPI, ModalBuilder, NovaChannel, NovaClient, type NovaClientEvents, type NovaClientOptions, NovaInteraction, NovaInvite, NovaMember, NovaMessage, NovaRole, type NovaServer, NovaServerWrapper, NovaWebhook, Paginator, type PermissionKey, Permissions, PermissionsAPI, PermissionsBitfield, type PermissionsQueryOptions, type PermissionsResult, PollBuilder, type PollDefinition, type PollInteractionsOptions, type PollOption, type PrefixCommandDefinition, type Reaction, type ReactionDetail, ReactionsAPI, type RegisteredContextCommand, type RegisteredPrefixCommand, type RegisteredSlashCommand, type RespondInteractionOptions, type Role, type RoleCreateOptions, type RoleEditOptions, RolesAPI, SelectMenuBuilder, type SelectMenuOption, type SendMessageOptions, type ServerUpdateOptions, ServersAPI, type SingleMember, SlashCommandBuilder, type SlashCommandDefinition, type SlashCommandOption, SlashCommandOptionBuilder, TextInputBuilder, type TextInputStyle, type VoiceState, type Webhook, type WebhookCreateOptions, type WebhookEditOptions, WebhooksAPI, countdown, formatDuration, formatRelative, parseTimestamp, sleep, withTimeout };