oceanic.js 0.0.12-dev.b566fc5 → 0.0.12-dev.bcdbabd

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 (121) hide show
  1. package/.github/workflows/dev-publish.yml +4 -1
  2. package/.github/workflows/docs.yml +14 -0
  3. package/CONTRIBUTING.md +10 -0
  4. package/README.md +7 -2
  5. package/dist/lib/Client.d.ts +6 -4
  6. package/dist/lib/Client.js +41 -22
  7. package/dist/lib/Constants.d.ts +4 -2
  8. package/dist/lib/Constants.js +3 -1
  9. package/dist/lib/gateway/Shard.d.ts +4 -4
  10. package/dist/lib/gateway/Shard.js +157 -88
  11. package/dist/lib/gateway/ShardManager.js +26 -14
  12. package/dist/lib/rest/Bucket.js +7 -4
  13. package/dist/lib/rest/DiscordHTTPError.d.ts +3 -3
  14. package/dist/lib/rest/DiscordHTTPError.js +24 -11
  15. package/dist/lib/rest/DiscordRESTError.d.ts +3 -3
  16. package/dist/lib/rest/DiscordRESTError.js +30 -14
  17. package/dist/lib/rest/RESTManager.d.ts +1 -1
  18. package/dist/lib/rest/RESTManager.js +7 -3
  19. package/dist/lib/rest/RequestHandler.js +56 -29
  20. package/dist/lib/rest/SequentialBucket.js +13 -7
  21. package/dist/lib/routes/ApplicationCommands.d.ts +12 -12
  22. package/dist/lib/routes/ApplicationCommands.js +26 -20
  23. package/dist/lib/routes/Channels.d.ts +11 -9
  24. package/dist/lib/routes/Channels.js +38 -27
  25. package/dist/lib/routes/Guilds.d.ts +36 -35
  26. package/dist/lib/routes/Guilds.js +121 -71
  27. package/dist/lib/routes/Interactions.d.ts +6 -5
  28. package/dist/lib/routes/Interactions.js +4 -4
  29. package/dist/lib/routes/OAuth.d.ts +6 -4
  30. package/dist/lib/routes/OAuth.js +18 -10
  31. package/dist/lib/routes/Users.d.ts +6 -1
  32. package/dist/lib/routes/Users.js +7 -2
  33. package/dist/lib/routes/Webhooks.d.ts +3 -3
  34. package/dist/lib/routes/Webhooks.js +39 -22
  35. package/dist/lib/structures/AnnouncementChannel.d.ts +2 -1
  36. package/dist/lib/structures/AnnouncementChannel.js +1 -1
  37. package/dist/lib/structures/Application.js +35 -18
  38. package/dist/lib/structures/ApplicationCommand.d.ts +8 -4
  39. package/dist/lib/structures/ApplicationCommand.js +13 -4
  40. package/dist/lib/structures/AutoModerationRule.d.ts +1 -1
  41. package/dist/lib/structures/AutoModerationRule.js +17 -9
  42. package/dist/lib/structures/AutocompleteInteraction.js +3 -2
  43. package/dist/lib/structures/Base.js +1 -1
  44. package/dist/lib/structures/CategoryChannel.js +17 -9
  45. package/dist/lib/structures/Channel.js +1 -2
  46. package/dist/lib/structures/ClientApplication.d.ts +21 -19
  47. package/dist/lib/structures/ClientApplication.js +16 -15
  48. package/dist/lib/structures/CommandInteraction.js +27 -14
  49. package/dist/lib/structures/ComponentInteraction.js +11 -6
  50. package/dist/lib/structures/ExtendedUser.js +7 -4
  51. package/dist/lib/structures/ForumChannel.d.ts +2 -2
  52. package/dist/lib/structures/ForumChannel.js +35 -18
  53. package/dist/lib/structures/GroupChannel.d.ts +6 -5
  54. package/dist/lib/structures/GroupChannel.js +21 -11
  55. package/dist/lib/structures/Guild.d.ts +44 -46
  56. package/dist/lib/structures/Guild.js +117 -55
  57. package/dist/lib/structures/GuildChannel.js +3 -2
  58. package/dist/lib/structures/GuildPreview.js +21 -11
  59. package/dist/lib/structures/GuildScheduledEvent.js +27 -14
  60. package/dist/lib/structures/GuildTemplate.js +13 -7
  61. package/dist/lib/structures/Integration.js +29 -15
  62. package/dist/lib/structures/Invite.js +36 -19
  63. package/dist/lib/structures/Member.d.ts +6 -3
  64. package/dist/lib/structures/Member.js +64 -24
  65. package/dist/lib/structures/Message.d.ts +6 -4
  66. package/dist/lib/structures/Message.js +89 -33
  67. package/dist/lib/structures/ModalSubmitInteraction.d.ts +6 -5
  68. package/dist/lib/structures/ModalSubmitInteraction.js +9 -5
  69. package/dist/lib/structures/PartialApplication.js +11 -6
  70. package/dist/lib/structures/Permission.d.ts +3 -2
  71. package/dist/lib/structures/Permission.js +9 -5
  72. package/dist/lib/structures/PermissionOverwrite.d.ts +2 -2
  73. package/dist/lib/structures/PermissionOverwrite.js +10 -6
  74. package/dist/lib/structures/PingInteraction.d.ts +1 -1
  75. package/dist/lib/structures/PingInteraction.js +1 -1
  76. package/dist/lib/structures/PrivateChannel.d.ts +3 -3
  77. package/dist/lib/structures/PrivateChannel.js +3 -2
  78. package/dist/lib/structures/Role.js +19 -10
  79. package/dist/lib/structures/StageChannel.d.ts +3 -2
  80. package/dist/lib/structures/StageChannel.js +21 -11
  81. package/dist/lib/structures/StageInstance.js +11 -6
  82. package/dist/lib/structures/Team.js +9 -5
  83. package/dist/lib/structures/TextChannel.d.ts +12 -2
  84. package/dist/lib/structures/TextChannel.js +15 -1
  85. package/dist/lib/structures/TextableChannel.d.ts +5 -14
  86. package/dist/lib/structures/TextableChannel.js +25 -27
  87. package/dist/lib/structures/ThreadChannel.d.ts +5 -4
  88. package/dist/lib/structures/ThreadChannel.js +21 -11
  89. package/dist/lib/structures/User.d.ts +2 -1
  90. package/dist/lib/structures/User.js +13 -7
  91. package/dist/lib/structures/VoiceChannel.d.ts +7 -5
  92. package/dist/lib/structures/VoiceChannel.js +27 -14
  93. package/dist/lib/structures/VoiceState.js +23 -12
  94. package/dist/lib/structures/Webhook.js +20 -10
  95. package/dist/lib/types/application-commands.d.ts +35 -25
  96. package/dist/lib/types/channels.d.ts +6 -1
  97. package/dist/lib/types/client.d.ts +2 -232
  98. package/dist/lib/types/events.d.ts +233 -0
  99. package/dist/lib/types/guilds.d.ts +1 -1
  100. package/dist/lib/types/index.d.ts +1 -0
  101. package/dist/lib/types/oauth.d.ts +5 -2
  102. package/dist/lib/types/request-handler.d.ts +2 -1
  103. package/dist/lib/types/shared.d.ts +6 -0
  104. package/dist/lib/util/Collection.d.ts +3 -2
  105. package/dist/lib/util/Collection.js +12 -6
  106. package/dist/lib/util/InteractionOptionsWrapper.js +68 -41
  107. package/dist/lib/util/Routes.d.ts +1 -0
  108. package/dist/lib/util/Routes.js +5 -2
  109. package/dist/lib/util/TypedCollection.js +12 -7
  110. package/dist/lib/util/TypedEmitter.js +3 -3
  111. package/dist/lib/util/Util.js +108 -132
  112. package/dist/lib/voice/VoiceConnection.d.ts +2 -1
  113. package/dist/lib/voice/VoiceConnection.js +2 -1
  114. package/dist/package.json +8 -10
  115. package/doc-test.js +39 -0
  116. package/esm.mjs +1 -1
  117. package/examples/applicationCommand.js +4 -4
  118. package/examples/components.js +4 -4
  119. package/examples/embeds.js +3 -4
  120. package/examples/intents.js +8 -10
  121. package/package.json +8 -10
@@ -1,20 +1,20 @@
1
- import type { Uncached } from "./shared";
1
+ import type { Uncached, ExclusifyUnion } from "./shared";
2
2
  import type { ApplicationCommandOptionTypes, ApplicationCommandPermissionTypes, ApplicationCommandTypes, GuildChannelTypes } from "../Constants";
3
3
  import type ApplicationCommand from "../structures/ApplicationCommand";
4
4
  import type ClientApplication from "../structures/ClientApplication";
5
5
 
6
- // @TODO `name_localized` and `description_localized`
7
-
8
6
  export interface RawApplicationCommand {
9
7
  application_id: string;
10
8
  default_member_permissions: string | null;
11
9
  description: string;
12
10
  description_localizations?: Record<string, string> | null;
11
+ description_localized?: string;
13
12
  dm_permission?: boolean;
14
13
  guild_id?: string;
15
14
  id: string;
16
15
  name: string;
17
16
  name_localizations?: Record<string, string> | null;
17
+ name_localized?: string;
18
18
  options?: Array<RawApplicationCommandOption>;
19
19
  type: ApplicationCommandTypes;
20
20
  version: string;
@@ -26,12 +26,14 @@ export interface RawApplicationCommandOption {
26
26
  choices?: Array<RawApplicationCommandOptionChoice>;
27
27
  description: string;
28
28
  description_localizations?: Record<string, string> | null;
29
+ description_localized?: string;
29
30
  max_length?: number;
30
31
  max_value?: number;
31
32
  min_length?: number;
32
33
  min_value?: number;
33
34
  name: string;
34
35
  name_localizations?: Record<string, string> | null;
36
+ name_localized?: string;
35
37
  options?: Array<RawApplicationCommandOption>;
36
38
  required?: boolean;
37
39
  type: ApplicationCommandOptionTypes;
@@ -60,13 +62,13 @@ export interface RawApplicationCommandOptionChoice {
60
62
  value: string;
61
63
  }
62
64
 
63
- export type AnyApplicationCommand<W extends boolean = false> = ChatInputApplicationCommand<W> | UserApplicationCommand<W> | MessageApplicationCommand<W>;
65
+ export type AnyApplicationCommand = ChatInputApplicationCommand | UserApplicationCommand | MessageApplicationCommand;
64
66
  export type ApplicationCommandOptions = ApplicationCommandOptionsWithOptions | ApplicationCommandOptionsWithValue;
65
67
  export type ApplicationCommandOptionsWithOptions = ApplicationCommandOptionsSubCommand | ApplicationCommandOptionsSubCommandGroup;
66
68
  export type ApplicationCommandOptionsWithValue = ApplicationCommandOptionsString | ApplicationCommandOptionsInteger | ApplicationCommandOptionsBoolean | ApplicationCommandOptionsUser | ApplicationCommandOptionsChannel | ApplicationCommandOptionsRole | ApplicationCommandOptionsMentionable | ApplicationCommandOptionsNumber | ApplicationCommandOptionsAttachment;
67
- export type ChatInputApplicationCommand<W extends boolean = false> = WithLang<ApplicationCommand<ApplicationCommandTypes.CHAT_INPUT>, W>;
68
- export type UserApplicationCommand<W extends boolean = false> = WithLang<ApplicationCommand<ApplicationCommandTypes.USER>, W>;
69
- export type MessageApplicationCommand<W extends boolean = false> = WithLang<ApplicationCommand<ApplicationCommandTypes.MESSAGE>, W>;
69
+ export type ChatInputApplicationCommand = ApplicationCommand<ApplicationCommandTypes.CHAT_INPUT>;
70
+ export type UserApplicationCommand = ApplicationCommand<ApplicationCommandTypes.USER>;
71
+ export type MessageApplicationCommand = ApplicationCommand<ApplicationCommandTypes.MESSAGE>;
70
72
 
71
73
  export type ApplicationCommandOptionConversion<T extends EditApplicationCommandOptions | CreateApplicationCommandOptions> =
72
74
  T extends EditChatInputApplicationCommandOptions | CreateChatInputApplicationCommandOptions ? ChatInputApplicationCommand :
@@ -74,30 +76,26 @@ export type ApplicationCommandOptionConversion<T extends EditApplicationCommandO
74
76
  T extends EditMessageApplicationCommandOptions | CreateMessageApplicationCommandOptions ? MessageApplicationCommand :
75
77
  never;
76
78
 
77
- export type LangNames = "descriptionLocalizations" | "nameLocalizations";
78
- type WithLang<T extends ApplicationCommand, W extends boolean, V = Omit<T, "descriptionLocalizations" | "nameLocalizations">> = & (W extends false ? V : V & {
79
- descriptionLocalizations: Record<string, string> | null;
80
- nameLocalizations: Record<string, string> | null;
81
- });
82
79
 
83
80
  export interface ApplicationCommandOptionBase<T extends ApplicationCommandOptionTypes = ApplicationCommandOptionTypes> {
84
81
  description: string;
85
82
  descriptionLocalizations?: Record<string, string>;
83
+ /** The description of this application command in the requested locale. This cannot be sent. */
84
+ descriptionLocalized?: string;
86
85
  name: string;
87
86
  nameLocalizations?: Record<string, string>;
87
+ /** The description of this application command in the requested locale. This cannot be sent. */
88
+ nameLocalized?: string;
88
89
  required?: T extends ApplicationCommandOptionTypes.SUB_COMMAND | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP ? never : boolean;
89
90
  type: T;
90
91
  }
91
92
 
92
93
  type ApplicationCommandOptionsTypesWithAutocomplete = ApplicationCommandOptionTypes.INTEGER | ApplicationCommandOptionTypes.NUMBER | ApplicationCommandOptionTypes.STRING;
93
94
  type ApplicationCommandOptionsTypesWithChoices = ApplicationCommandOptionTypes.INTEGER | ApplicationCommandOptionTypes.NUMBER | ApplicationCommandOptionTypes.STRING;
94
- type ApplicationCommandOptionAutocomplete<T extends ApplicationCommandOptionTypes.INTEGER | ApplicationCommandOptionTypes.NUMBER | ApplicationCommandOptionTypes.STRING> = (ApplicationCommandOptionBase<T> & ApplicationCommandOptionsAutocomplete);
95
- type ApplicationCommandOptionChannelTypes<T extends ApplicationCommandOptionTypes.CHANNEL> = (ApplicationCommandOptionBase<T> & ApplicationCommandOptionsChannelTypes);
96
- type ApplicationCommandOptionChoices<T extends ApplicationCommandOptionTypes.INTEGER | ApplicationCommandOptionTypes.NUMBER | ApplicationCommandOptionTypes.STRING> = (ApplicationCommandOptionBase<T> & ApplicationCommandOptionsChoices<T>);
97
- type ApplicationCommandOptionMinMaxValue<T extends ApplicationCommandOptionTypes.INTEGER | ApplicationCommandOptionTypes.NUMBER> = (ApplicationCommandOptionBase<T> & ApplicationCommandOptionsMinMaxValue);
98
- type ApplicationCommandOptionMinMaxLength<T extends ApplicationCommandOptionTypes.STRING> = (ApplicationCommandOptionBase<T> & ApplicationCommandOptionsMinMaxLength);
99
95
 
100
- interface ApplicationCommandOptionsChoices<T extends ApplicationCommandOptionsTypesWithChoices = ApplicationCommandOptionsTypesWithChoices> { choices?: Array<ApplicationCommandOptionsChoice<T>>; }
96
+ interface ApplicationCommandOptionsChoices<T extends ApplicationCommandOptionsTypesWithChoices = ApplicationCommandOptionsTypesWithChoices> {
97
+ choices?: Array<ApplicationCommandOptionsChoice<T>>;
98
+ }
101
99
 
102
100
  interface ApplicationCommandOptionsChoice<T extends ApplicationCommandOptionsTypesWithChoices = ApplicationCommandOptionsTypesWithChoices> {
103
101
  name: string;
@@ -116,28 +114,32 @@ interface ApplicationCommandOptionsMinMaxValue {
116
114
  maxValue?: number;
117
115
  minValue?: number;
118
116
  }
119
- interface ApplicationCommandOptionsAutocomplete {
120
- autocomplete?: boolean;
121
- }
117
+
122
118
  interface ApplicationCommandOptionsMinMaxLength {
123
119
  maxLength?: number;
124
120
  minLength?: number;
125
121
  }
122
+
123
+ interface ApplicationCommandOptionsAutocomplete {
124
+ autocomplete?: boolean;
125
+ }
126
+
126
127
  interface ApplicationCommandOptionsSubCommand extends ApplicationCommandOptionBase<ApplicationCommandOptionTypes.SUB_COMMAND> {
127
128
  options?: Array<ApplicationCommandOptionsWithValue>;
128
129
  }
130
+
129
131
  interface ApplicationCommandOptionsSubCommandGroup extends ApplicationCommandOptionBase<ApplicationCommandOptionTypes.SUB_COMMAND_GROUP> {
130
132
  options?: Array<ApplicationCommandOptionsSubCommand | ApplicationCommandOptionsWithValue>;
131
133
  }
132
134
 
133
135
  type ApplicationCommandOptionsAttachment = ApplicationCommandOptionBase<ApplicationCommandOptionTypes.ATTACHMENT>;
134
136
  type ApplicationCommandOptionsBoolean = ApplicationCommandOptionBase<ApplicationCommandOptionTypes.BOOLEAN>;
135
- type ApplicationCommandOptionsChannel = ApplicationCommandOptionChannelTypes<ApplicationCommandOptionTypes.CHANNEL>;
136
- type ApplicationCommandOptionsInteger = ApplicationCommandOptionAutocomplete<ApplicationCommandOptionTypes.INTEGER> | ApplicationCommandOptionChoices<ApplicationCommandOptionTypes.INTEGER> | ApplicationCommandOptionMinMaxValue<ApplicationCommandOptionTypes.INTEGER>;
137
+ type ApplicationCommandOptionsChannel = ApplicationCommandOptionBase<ApplicationCommandOptionTypes.CHANNEL> & ApplicationCommandOptionsChannelTypes;
138
+ type ApplicationCommandOptionsInteger = ApplicationCommandOptionBase<ApplicationCommandOptionTypes.INTEGER> & ExclusifyUnion<ApplicationCommandOptionsAutocomplete | ApplicationCommandOptionsMinMaxValue | ApplicationCommandOptionsChoices<ApplicationCommandOptionTypes.INTEGER>>;
137
139
  type ApplicationCommandOptionsMentionable = ApplicationCommandOptionBase<ApplicationCommandOptionTypes.MENTIONABLE>;
138
- type ApplicationCommandOptionsNumber = ApplicationCommandOptionAutocomplete<ApplicationCommandOptionTypes.NUMBER> | ApplicationCommandOptionChoices<ApplicationCommandOptionTypes.NUMBER> | ApplicationCommandOptionMinMaxValue<ApplicationCommandOptionTypes.NUMBER>;
140
+ type ApplicationCommandOptionsNumber = ApplicationCommandOptionBase<ApplicationCommandOptionTypes.NUMBER> & ExclusifyUnion<ApplicationCommandOptionsAutocomplete | ApplicationCommandOptionsMinMaxValue | ApplicationCommandOptionsChoices<ApplicationCommandOptionTypes.NUMBER>>;
139
141
  type ApplicationCommandOptionsRole = ApplicationCommandOptionBase<ApplicationCommandOptionTypes.ROLE>;
140
- type ApplicationCommandOptionsString = ApplicationCommandOptionAutocomplete<ApplicationCommandOptionTypes.STRING> | ApplicationCommandOptionChoices<ApplicationCommandOptionTypes.STRING> | ApplicationCommandOptionMinMaxLength<ApplicationCommandOptionTypes.STRING>;
142
+ type ApplicationCommandOptionsString = ApplicationCommandOptionBase<ApplicationCommandOptionTypes.STRING> & ExclusifyUnion<ApplicationCommandOptionsAutocomplete | ApplicationCommandOptionsMinMaxLength | ApplicationCommandOptionsChoices<ApplicationCommandOptionTypes.STRING>>;
141
143
  type ApplicationCommandOptionsUser = ApplicationCommandOptionBase<ApplicationCommandOptionTypes.USER>;
142
144
 
143
145
  // desc, options
@@ -218,3 +220,11 @@ T extends ApplicationCommandTypes.CHAT_INPUT ? EditChatInputApplicationCommandOp
218
220
  T extends ApplicationCommandTypes.USER ? EditUserApplicationCommandOptions :
219
221
  T extends ApplicationCommandTypes.MESSAGE ? EditMessageApplicationCommandOptions :
220
222
  never;
223
+
224
+
225
+ export interface GetApplicationCommandOptions {
226
+ /** The [locale](https://discord.com/developers/docs/reference#locales) to recieve localized responses for (`descriptionLocalized`, `nameLocalized`). If no localization for the locale is present, the properties will not be present. */
227
+ locale?: string;
228
+ /** If localizations should be included. */
229
+ withLocalizations?: boolean;
230
+ }
@@ -3,6 +3,7 @@ import type { RawApplication, RawPartialApplication } from "./oauth";
3
3
  import type { RawUser, RawUserWithMember } from "./users";
4
4
  import type { File } from "./request-handler";
5
5
  import type { RawScheduledEvent } from "./scheduled-events";
6
+ import { Uncached } from "./shared";
6
7
  import type {
7
8
  ButtonStyles,
8
9
  ChannelTypes,
@@ -32,6 +33,7 @@ import type TextChannel from "../structures/TextChannel";
32
33
  import type User from "../structures/User";
33
34
  import type VoiceChannel from "../structures/VoiceChannel";
34
35
  import type ForumChannel from "../structures/ForumChannel";
36
+ import Message from "../structures/Message";
35
37
 
36
38
  export interface RawChannel {
37
39
  application_id?: string;
@@ -618,9 +620,9 @@ export interface StickerItem {
618
620
  }
619
621
 
620
622
 
621
- // @TODO directory & forum
622
623
  export type AnyChannel = TextChannel | PrivateChannel | VoiceChannel | GroupChannel | CategoryChannel | AnnouncementChannel | AnnouncementThreadChannel | PublicThreadChannel | PrivateThreadChannel | StageChannel | ForumChannel;
623
624
  export type AnyPrivateChannel = PrivateChannel | GroupChannel;
625
+ export type AnyEditableChannel = Exclude<AnyChannel, PrivateChannel>;
624
626
  export type AnyGuildChannel = Exclude<AnyChannel, AnyPrivateChannel>;
625
627
  export type AnyGuildChannelWithoutThreads = Exclude<AnyGuildChannel, AnyThreadChannel>;
626
628
  export type AnyTextChannelWithoutThreads = Exclude<AnyTextChannel, AnyThreadChannel>;
@@ -855,3 +857,6 @@ export interface ForumEmoji {
855
857
  /** The unicode codepoint of this emoji if default, null otherwise. */
856
858
  name: string | null;
857
859
  }
860
+
861
+ export type PossiblyUncachedMessage = Message | { channel: AnyTextChannel | Uncached; id: string; };
862
+ export type PossiblyUncachedThread = AnyThreadChannel | Pick<AnyThreadChannel, "id" | "type"> & { parentID: string; };
@@ -1,60 +1,6 @@
1
- import type {
2
- AllowedMentions,
3
- AnyGuildChannelWithoutThreads,
4
- AnyGuildTextChannel,
5
- AnyTextChannel,
6
- AnyThreadChannel,
7
- InviteChannel,
8
- ThreadMember
9
- } from "./channels";
10
- import type { RawRequest } from "./request-handler";
11
- import type { AutoModerationActionExecution, GatewayOptions, Presence } from "./gateway";
12
- import type { AnyDispatchPacket } from "./gateway-raw";
13
- import type { Uncached } from "./shared";
14
- import type {
15
- JSONAnnouncementChannel,
16
- JSONAnnouncementThreadChannel,
17
- JSONAutoModerationRule,
18
- JSONCategoryChannel,
19
- JSONGuild,
20
- JSONIntegration,
21
- JSONMember,
22
- JSONMessage,
23
- JSONPrivateThreadChannel,
24
- JSONPublicThreadChannel,
25
- JSONRole,
26
- JSONScheduledEvent,
27
- JSONStageChannel,
28
- JSONStageInstance,
29
- JSONTextChannel,
30
- JSONUser,
31
- JSONVoiceChannel,
32
- JSONVoiceState
33
- } from "./json";
34
- import type { GuildApplicationCommandPermissions } from "./application-commands";
35
- import type { GuildEmoji, PartialEmoji, Sticker } from "./guilds";
36
- import type { AnyInteractionGateway } from "./interactions";
1
+ import type { AllowedMentions } from "./channels";
2
+ import type { GatewayOptions } from "./gateway";
37
3
  import type { ImageFormat } from "../Constants";
38
- import type Guild from "../structures/Guild";
39
- import type UnavailableGuild from "../structures/UnavailableGuild";
40
- import type AutoModerationRule from "../structures/AutoModerationRule";
41
- import type AnnouncementThreadChannel from "../structures/AnnouncementThreadChannel";
42
- import type PublicThreadChannel from "../structures/PublicThreadChannel";
43
- import type PrivateThreadChannel from "../structures/PrivateThreadChannel";
44
- import type TextChannel from "../structures/TextChannel";
45
- import type VoiceChannel from "../structures/VoiceChannel";
46
- import type CategoryChannel from "../structures/CategoryChannel";
47
- import type AnnouncementChannel from "../structures/AnnouncementChannel";
48
- import type StageChannel from "../structures/StageChannel";
49
- import type User from "../structures/User";
50
- import type Member from "../structures/Member";
51
- import type Role from "../structures/Role";
52
- import type GuildScheduledEvent from "../structures/GuildScheduledEvent";
53
- import type Integration from "../structures/Integration";
54
- import type Invite from "../structures/Invite";
55
- import type Message from "../structures/Message";
56
- import type PrivateChannel from "../structures/PrivateChannel";
57
- import type StageInstance from "../structures/StageInstance";
58
4
  import type { Agent } from "undici";
59
5
 
60
6
  export interface ClientOptions {
@@ -147,182 +93,6 @@ export interface CollectionLimitsOptions {
147
93
  users?: number;
148
94
  }
149
95
 
150
- // @TODO document events
151
- export interface ClientEvents {
152
- /** @event Emitted when an application command's permissions are updated. */
153
- applicationCommandPermissionsUpdate: [guild: Guild, permissions: GuildApplicationCommandPermissions];
154
- /** @event Emitted when an auto moderation action is executed. Requires the `AUTO_MODERATION_EXECUTION` intent. */
155
- autoModerationActionExecution: [guild: Guild, channel: AnyGuildTextChannel | Uncached | null, user: User | Uncached, executionOptions: AutoModerationActionExecution];
156
- /** @event Emitted when an auto moderation rule is created. Requires the `AUTO_MODERATION_CONFIGURATION` intent. */
157
- autoModerationRuleCreate: [rule: AutoModerationRule];
158
- /** @event Emitted when an auto moderation rule is deleted. Requires the `AUTO_MODERATION_CONFIGURATION` intent. */
159
- autoModerationRuleDelete: [rule: AutoModerationRule];
160
- /** @event Emitted when an auto moderaiton rule is updated. Requires the `AUTO_MODERATION_CONFIGURATION` intent. */
161
- autoModerationRuleUpdate: [rule: AutoModerationRule, oldRule: JSONAutoModerationRule | null];
162
- /** @event Emitted when a channel is created. Requires the `GUILDS` intent. */
163
- channelCreate: [channel: AnyGuildChannelWithoutThreads];
164
- /** @event Emitted when channel is deleted. Requires the `GUILDS` intent. */
165
- channelDelete: [channel: AnyGuildChannelWithoutThreads];
166
- /** @event Emitted when a channel's pins are updated (message pinned, message unpinned). Requires the `GUILDS` intent for guild channels, and `DIRECT_MESSAGES` for direct messages. */
167
- channelPinsUpdate: [channel: AnyTextChannel, timestamp: Date | null];
168
- /** @event Emitted when a channel is updated. Requires the `GUILDS` intent. */
169
- channelUpdate: [channel: TextChannel, oldChannel: JSONTextChannel | null] | [channel: VoiceChannel, oldChannel: JSONVoiceChannel | null] | [channel: CategoryChannel, oldChannel: JSONCategoryChannel | null] | [channel: AnnouncementChannel, oldChannel: JSONAnnouncementChannel | null] | [channel: StageChannel, oldChannel: JSONStageChannel | null];
170
- /** @event Emitted when a shard connects. */
171
- connect: [id: number];
172
- /** @event Emitted with various information for debugging. */
173
- debug: [info: string, shard?: number];
174
- /** @event Emitted when all shards disconnect. */
175
- disconnect: [];
176
- /** @event Emitted when an error happens. */
177
- error: [info: Error | string, shard?: number];
178
- /** @event Eitted when a guild becoms available. Requires the `GUILDS` intent. */
179
- guildAvailable: [guild: Guild];
180
- /** @event Emitted when a guild ban is created. Requires the `GUILD_BANS` intent. */
181
- guildBanAdd: [guild: Guild, user: User];
182
- /** @event Emitted when a guild ban is revoked. Requires the `GUILD_BANS` intent. */
183
- guildBanRemove: [guild: Guild, user: User];
184
- /** @event Emitted when the client joins a new guild. Requires the `GUILDS` intent. */
185
- guildCreate: [guild: Guild];
186
- /** @event Emitted when the client leaves a guild. Requires the `GUILDS` intent. */
187
- guildDelete: [guild: Guild | Uncached];
188
- /** @event Emitted when a guild's emojis are updated. Requires the `GUILD_EMOJIS_AND_STICKERS` intent. */
189
- guildEmojisUpdate: [guild: Guild, emojis: Array<GuildEmoji>, oldEmojis: Array<GuildEmoji>];
190
- /** @event Emitted when a guild's integrations are updated. Requires the `GUILD_INTEGRATOPMS` intent. */
191
- guildIntegrationsUpdate: [guild: Guild];
192
- /** @event Emitted when a member joins a guild. Requires the `GUILD_MEMBERS` intent. */
193
- guildMemberAdd: [member: Member];
194
- /** @event Emitted when a chunk of guild members is received from Discord. */
195
- guildMemberChunk: [guild: Guild, members: Array<Member>];
196
- /** @event Emitted when a member leaves a guild. Requires the `GUILD_MEMBERS` intent. If the member is uncached, the first parameter will be a user. If the guild is uncached, the first parameter will be a user, and the second will be an object with only an `id`. */
197
- guildMemberRemove: [member: Member | User, guild: Guild | Uncached];
198
- /** @event Emitted when a guild member is updates. Requires the `GUILD_MEMBERS` intent.*/
199
- guildMemberUpdate: [member: Member, oldMember: JSONMember | null];
200
- /** @event Emitted when a role is created. Requires the `GUILDS` intent. */
201
- guildRoleCreate: [role: Role];
202
- /** @event Emitted when a role is deleted. Requires the `GUILDS` intent. */
203
- guildRoleDelete: [role: Role];
204
- /** @event Emitted when a role is updated. Requires the `GUILDS` intent. */
205
- guildRoleUpdate: [role: Role, oldRole: JSONRole | null];
206
- /** @event Emitted when a scheduled event is created. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
207
- guildScheduledEventCreate: [event: GuildScheduledEvent];
208
- /** @event Emitted when a scheduled event is deleted. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
209
- guildScheduledEventDelete: [event: GuildScheduledEvent];
210
- /** @event Emitted when a scheduled event is updated. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
211
- guildScheduledEventUpdate: [event: GuildScheduledEvent, oldEvent: JSONScheduledEvent | null];
212
- /** @event Emitted when a user subscribes to a scheduled event. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
213
- guildScheduledEventUserAdd: [event: GuildScheduledEvent | Uncached, user: User | Uncached];
214
- /** @event Emitted when a user unsubscribes from a scheduled event. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
215
- guildScheduledEventUserRemove: [event: GuildScheduledEvent | Uncached, user: User | Uncached];
216
- /** @event Emitted when a guild's stickers are updated. Requires the `GUILD_EMOJIS_AND_STICKERS` intent. */
217
- guildStickersUpdate: [guild: Guild, stickers: Array<Sticker>, oldStickers: Array<Sticker>];
218
- /** @event Emitted when a guild becomes unavailable. Requires the `GUILDS` intent. */
219
- guildUnavailable: [guild: UnavailableGuild];
220
- /** @event Emitted when a guild is updated. Requires the `GUILDS` intent. */
221
- guildUpdate: [guild: Guild, oldGuild: JSONGuild | null];
222
- /** @event Emitted when a shard receives the HELLO packet. */
223
- hello: [interval: number, shard: number];
224
- /** @event Emitted when an integration is created. Requires the `GUILD_INTEGRATIONS` intent. */
225
- integrationCreate: [guild: Guild, integration: Integration];
226
- /** @event Emitted when an integration is deleted. Requires the `GUILD_INTEGRATIONS` intent. */
227
- integrationDelete: [guild: Guild, integration: Integration | { applicationID?: string; id: string; }];
228
- /** @event Emitted when an integration is updated. Requires the `GUILD_INTEGRATIONS` intent. */
229
- integrationUpdate: [guild: Guild, integration: Integration, oldIntegration: JSONIntegration | null];
230
- /** @event Emitted when an interaction is created. */
231
- interactionCreate: [interaction: AnyInteractionGateway];
232
- /** @event Emitted when an invite is created. Requires the `GUILD_INVITES` intent. */
233
- inviteCreate: [guild: Guild | null, channel: InviteChannel, invite: Invite];
234
- /** @event Emitted when an invite is deleted. Requires the `GUILD_INVITES` intent. */
235
- inviteDelete: [guild: Guild | null, channel: InviteChannel, code: string];
236
- /** @event Emitted when a message is created. Requires the `GUILD_MESSAGES` intent for guild messages, `DIRECT_MESSAGES` for direct messages. The `MESSAGE_CONTENT` intent is required for `content`, `embeds`, and similar to be present on most messages. */
237
- messageCreate: [message: Message];
238
- /** @event Emitted when a message is created. Requires the `GUILD_MESSAGES` intent for guild messages, `DIRECT_MESSAGES` for direct messages. The `MESSAGE_CONTENT` intent is required for `content`, `embeds`, and similar to be present on most messages. */
239
- messageDelete: [message: Message | { channel: AnyTextChannel | Uncached; id: string; }];
240
- /** @event Emitted when messages are bulk deleted. Requires the `GUILD_MESSAGES` intent. The `MESSAGE_CONTENT` intent is required for `content`, `embeds`, and similar to be present on most messages. */
241
- messageDeleteBulk: [messages: Array<Message | { channel: AnyTextChannel | Uncached; id: string; }>];
242
- /** @event Emitted when a reaction is added to a message. Requires the `GUILD_MESSAGE_REACTIONS` for guild messages, and `DIRECT_MESSAGE_REACTIONS` for direct messages. */
243
- messageReactionAdd: [message: Message | { channel: AnyTextChannel | Uncached; id: string; }, reactor: Member | User | Uncached, reaction: PartialEmoji];
244
- /** @event Emitted when a reaction is removed from a message. Requires the `GUILD_MESSAGE_REACTIONS` for guild messages, and `DIRECT_MESSAGE_REACTIONS` for direct messages. */
245
- messageReactionRemove: [message: Message | { channel: AnyTextChannel | Uncached; id: string; }, reactor: Member | User | Uncached, reaction: PartialEmoji];
246
- /** @event Emitted when all reactions are removed from a message. Requires the `GUILD_MESSAGE_REACTIONS` for guild messages, and `DIRECT_MESSAGE_REACTIONS` for direct messages. */
247
- messageReactionRemoveAll: [message: Message | { channel: AnyTextChannel | Uncached; id: string; }];
248
- /** @event Emitted when a specific reaction is removed for all users from a message. Requires the `GUILD_MESSAGE_REACTIONS` for guild messages, and `DIRECT_MESSAGE_REACTIONS` for direct messages. */
249
- messageReactionRemoveEmoji: [message: Message | { channel: AnyTextChannel | Uncached; id: string; }, reaction: PartialEmoji];
250
- /** @event Emitted when a message is updated. Requires the `GUILD_MESSAGES` intent for guild messages, `DIRECT_MESSAGES` for direct messages. The `MESSAGE_CONTENT` intent is required for `content`, `embeds`, and similar to be present on most messages. */
251
- messageUpdate: [message: Message, oldMessage: JSONMessage | null];
252
- /** @event Emitted when a raw dispatch packet is received. */
253
- packet: [data: AnyDispatchPacket, shard: number];
254
- /** @event Emitted when a guild member's presence, or user is updated. Requires the `GUILD_PRESENCES` intent. */
255
- presenceUpdate: [guild: Guild, member: Member, presence: Presence, oldPresence: Presence | null];
256
- /** @event Emitted when all shards are ready. */
257
- ready: [];
258
- /** @event Emitted when a request is made. */
259
- request: [rawRequest: RawRequest];
260
- /** @event Emitted when this shard disconnects.*/
261
- shardDisconnect: [err: Error | undefined, id: number];
262
- /** @event Emitted when this shard has processed the READY packet from Discord. */
263
- shardPreReady: [id: number];
264
- /** @event Emitted when a shard is fully ready. */
265
- shardReady: [id: number];
266
- /** @event Emitted when a shard resumes a connection. */
267
- shardResume: [id: number];
268
- /** @event Emitted when a stage instance is created. */
269
- stageInstanceCreate: [instance: StageInstance];
270
- /** @event Emitted when a stage instance is deleted. */
271
- stageInstanceDelete: [instance: StageInstance];
272
- /** @event Emitted when a stage instance is updated. */
273
- stageInstanceUpdate: [instance: StageInstance, oldInstance: JSONStageInstance | null];
274
- /** @event Emitted when a thread is created. Requires the `GUILDS` intent. */
275
- threadCreate: [thread: AnyThreadChannel];
276
- /** @event Emitted when a thread is deleted. Requires the `GUILDS` intent. */
277
- threadDelete: [thread: AnyThreadChannel | Pick<AnyThreadChannel, "id" | "type"> & { parentID: string | null; }];
278
- /** @event Emitted when a guild's threads are synced. Requires the `GUILDS` intent. */
279
- threadListSync: [threads: Array<AnyThreadChannel>, members: Array<ThreadMember>];
280
- /** @event Emitted when a thread member is updated. Requires the `GUILDS` intent. */
281
- threadMemberUpdate: [thread: AnyThreadChannel, member: ThreadMember, oldMember: ThreadMember | null];
282
- /** @event Emitted when the members of a thread are updated. Requires the `GUILDS` intent. The received information will be different if `GUILD_MEMBERS` is also used. */
283
- threadMembersUpdate: [thread: AnyThreadChannel, addedMembers: Array<ThreadMember>, removedMembers: Array<ThreadMember>];
284
- /** @event Emitted when a thread is updated. Requires the `GUILDS` intent. */
285
- threadUpdate: [thread: AnnouncementThreadChannel, oldThread: JSONAnnouncementThreadChannel] | [thread: PublicThreadChannel, oldThread: JSONPublicThreadChannel | null] | [thread: PrivateThreadChannel | null, oldThread: JSONPrivateThreadChannel | null];
286
- /** @event Emitted when a user starts typing. Requires the `GUILD_MESSAGE_TYPING` for guilds, and `DIRECT_MESSAGE_TYPING` for direct messages. */
287
- typingStart: [channel: PrivateChannel | Uncached, user: User | Uncached, startTimestamp: Date] | [channel: AnyGuildTextChannel | Uncached, member: Member, startTimestamp: Date];
288
- /** @event Emitted when a guild is created, but is unavailable. Requires the `GUILDS` intent.*/
289
- unavailableGuildCreate: [guild: UnavailableGuild];
290
- /** @event Emitted when a user is updated. */
291
- userUpdate: [user: User, oldUser: JSONUser | null];
292
- /** @event Emitted when a user joins a voice channel. Requires the `GUILD_VOICE_STATES` intent. */
293
- voiceChannelJoin: [member: Member, channel: VoiceChannel | StageChannel];
294
- /** @event Emitted when a user leaves a voice channel. Requires the `GUILD_VOICE_STATES` intent. */
295
- voiceChannelLeave: [member: Member, channel: VoiceChannel | StageChannel];
296
- /** @event Emitted when a user switches voice channels. Requires the `GUILD_VOICE_STATES` intent. */
297
- voiceChannelSwitch: [member: Member, channel: VoiceChannel | StageChannel, oldChannel: VoiceChannel | StageChannel | null];
298
- /** @event Emitted when a user's voice state is updated. Requires the `GUILD_VOICE_STATES` intent. */
299
- voiceStateUpdate: [member: Member, oldState: JSONVoiceState | null];
300
- /** @event Emitted with various warning information. */
301
- warn: [info: string, shard?: number];
302
- /** @event Emitted when a guild's webhooks are updated. Requires the `GUILD_WEBHOOKS` intent. */
303
- webhooksUpdate: [guild: Guild, channel: AnyGuildChannelWithoutThreads | Uncached];
304
- }
305
-
306
- export interface ShardEvents {
307
- /** @event Emitted with various information for debugging. */
308
- debug: [info: string];
309
- /** @event Emitted when this shard disconnects.*/
310
- disconnect: [err?: Error];
311
- /** @event Emitted when an error happens. */
312
- error: [info: Error | string];
313
- /** @event Emitted when this shard has processed the READY packet from Discord. */
314
- preReady: [];
315
- /** @event Emitted when this shard is fully ready. */
316
- ready: [];
317
- /** @event Emitted when this shard resumes a connection. */
318
- resume: [];
319
- /** @event Emitted with various warning information. */
320
- warn: [info: string];
321
- }
322
-
323
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
324
- export interface VoiceEvents {}
325
-
326
96
  export interface JoinVoiceChannelOptions {
327
97
  opusOnly?: boolean;
328
98
  selfDeaf?: boolean;