-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
events.d.ts
245 lines (242 loc) · 17.5 KB
/
events.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/** @module Events */
import type {
AnyGuildChannelWithoutThreads,
AnyGuildTextChannel,
AnyTextChannelWithoutGroup,
AnyThreadChannel,
MinimalPossiblyUncachedThread,
PossiblyUncachedInvite,
PossiblyUncachedMessage,
PossiblyUncachedThread,
ThreadMember,
UncachedThreadMember
} from "./channels";
import type { RawRequest } from "./request-handler";
import type { AutoModerationActionExecution, DeletedPrivateChannel } from "./gateway";
import type { AnyDispatchPacket } from "./gateway-raw";
import type { Uncached } from "./shared";
import type {
JSONAnnouncementChannel,
JSONAnnouncementThreadChannel,
JSONAutoModerationRule,
JSONCategoryChannel,
JSONForumChannel,
JSONGuild,
JSONIntegration,
JSONMember,
JSONMessage,
JSONPrivateThreadChannel,
JSONPublicThreadChannel,
JSONRole,
JSONScheduledEvent,
JSONStageChannel,
JSONStageInstance,
JSONTextChannel,
JSONUser,
JSONVoiceChannel,
JSONVoiceState
} from "./json";
import type { GuildApplicationCommandPermissions } from "./application-commands";
import type {
GuildEmoji,
PartialEmoji,
PossiblyUncachedIntegration,
Sticker,
Presence
} from "./guilds";
import type { AnyInteractionGateway } from "./interactions";
import type Guild from "../structures/Guild";
import type UnavailableGuild from "../structures/UnavailableGuild";
import type AutoModerationRule from "../structures/AutoModerationRule";
import type AnnouncementThreadChannel from "../structures/AnnouncementThreadChannel";
import type PublicThreadChannel from "../structures/PublicThreadChannel";
import type PrivateThreadChannel from "../structures/PrivateThreadChannel";
import type TextChannel from "../structures/TextChannel";
import type VoiceChannel from "../structures/VoiceChannel";
import type CategoryChannel from "../structures/CategoryChannel";
import type AnnouncementChannel from "../structures/AnnouncementChannel";
import type StageChannel from "../structures/StageChannel";
import type User from "../structures/User";
import type Member from "../structures/Member";
import type Role from "../structures/Role";
import type GuildScheduledEvent from "../structures/GuildScheduledEvent";
import type Integration from "../structures/Integration";
import type Invite from "../structures/Invite";
import type Message from "../structures/Message";
import type PrivateChannel from "../structures/PrivateChannel";
import type StageInstance from "../structures/StageInstance";
import type ForumChannel from "../structures/ForumChannel";
import type AuditLogEntry from "../structures/AuditLogEntry";
import type GroupChannel from "../structures/GroupChannel";
export interface ClientEvents {
/** @event Emitted when an application command's permissions are updated. */
applicationCommandPermissionsUpdate: [guild: Guild | Uncached, permissions: GuildApplicationCommandPermissions];
/** @event Emitted when an auto moderation action is executed. Requires the `AUTO_MODERATION_EXECUTION` intent. */
autoModerationActionExecution: [guild: Guild | Uncached, channel: AnyGuildTextChannel | Uncached | null, user: User | Uncached, executionOptions: AutoModerationActionExecution];
/** @event Emitted when an auto moderation rule is created. Requires the `AUTO_MODERATION_CONFIGURATION` intent. */
autoModerationRuleCreate: [rule: AutoModerationRule];
/** @event Emitted when an auto moderation rule is deleted. Requires the `AUTO_MODERATION_CONFIGURATION` intent. */
autoModerationRuleDelete: [rule: AutoModerationRule];
/** @event Emitted when an auto moderation rule is updated. Requires the `AUTO_MODERATION_CONFIGURATION` intent. */
autoModerationRuleUpdate: [rule: AutoModerationRule, oldRule: JSONAutoModerationRule | null];
/** @event Emitted when a channel is created. Guild channels require the `GUILDS` intent. */
channelCreate: [channel: AnyGuildChannelWithoutThreads | GroupChannel];
/** @event Emitted when channel is deleted. Requires the `GUILDS` intent. */
channelDelete: [channel: AnyGuildChannelWithoutThreads | PrivateChannel | DeletedPrivateChannel];
/** @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. */
channelPinsUpdate: [channel: AnyTextChannelWithoutGroup | Uncached, timestamp: Date | null];
/** @event Emitted when a channel is updated. Requires the `GUILDS` intent. */
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] | [channel: ForumChannel, oldChannel: JSONForumChannel | null];
/** @event Emitted when a shard connects. */
connect: [id: number];
/** @event Emitted with various information for debugging. */
debug: [info: string, shard?: number];
/** @event Emitted when all shards disconnect. */
disconnect: [];
/** @event Emitted when an error happens. If an error is emitted and no handlers are present, the error will be thrown. */
error: [info: Error | string, shard?: number];
/** @event Emitted when an audit log entry is created. Requires both the `GUILD_MODERATION` intent, as well as the `VIEW_AUDIT_LOG` permission. */
guildAuditLogEntryCreate: [guild: Guild | Uncached, auditLogEntry: AuditLogEntry];
/** @event Emitted when a guild becomes available. Requires the `GUILDS` intent. */
guildAvailable: [guild: Guild];
/** @event Emitted when a guild ban is created. Requires the `GUILD_BANS` intent. */
guildBanAdd: [guild: Guild | Uncached, user: User];
/** @event Emitted when a guild ban is revoked. Requires the `GUILD_BANS` intent. */
guildBanRemove: [guild: Guild | Uncached, user: User];
/** @event Emitted when the client joins a new guild. Requires the `GUILDS` intent. */
guildCreate: [guild: Guild];
/** @event Emitted when the client leaves a guild. Requires the `GUILDS` intent. */
guildDelete: [guild: Guild | Uncached];
/** @event Emitted when a guild's emojis are updated. Requires the `GUILD_EMOJIS_AND_STICKERS` intent. */
guildEmojisUpdate: [guild: Guild | Uncached, emojis: Array<GuildEmoji>, oldEmojis: Array<GuildEmoji> | null];
/** @event Emitted when a guild's integrations are updated. Requires the `GUILD_INTEGRATIONS` intent. */
guildIntegrationsUpdate: [guild: Guild | Uncached];
/** @event Emitted when a member joins a guild. Requires the `GUILD_MEMBERS` intent. */
guildMemberAdd: [member: Member];
/** @event Emitted when a chunk of guild members is received from Discord. */
guildMemberChunk: [members: Array<Member>];
/** @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`. */
guildMemberRemove: [member: Member | User, guild: Guild | Uncached];
/** @event Emitted when a guild member is updates. Requires the `GUILD_MEMBERS` intent.*/
guildMemberUpdate: [member: Member, oldMember: JSONMember | null];
/** @event Emitted when a role is created. Requires the `GUILDS` intent. */
guildRoleCreate: [role: Role];
/** @event Emitted when a role is deleted. Requires the `GUILDS` intent. */
guildRoleDelete: [role: Role | Uncached, guild: Guild | Uncached];
/** @event Emitted when a role is updated. Requires the `GUILDS` intent. */
guildRoleUpdate: [role: Role, oldRole: JSONRole | null];
/** @event Emitted when a scheduled event is created. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
guildScheduledEventCreate: [event: GuildScheduledEvent];
/** @event Emitted when a scheduled event is deleted. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
guildScheduledEventDelete: [event: GuildScheduledEvent];
/** @event Emitted when a scheduled event is updated. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
guildScheduledEventUpdate: [event: GuildScheduledEvent, oldEvent: JSONScheduledEvent | null];
/** @event Emitted when a user subscribes to a scheduled event. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
guildScheduledEventUserAdd: [event: GuildScheduledEvent | Uncached, user: User | Uncached];
/** @event Emitted when a user unsubscribes from a scheduled event. Requires the `GUILD_SCHEDULED_EVENTS` intent. */
guildScheduledEventUserRemove: [event: GuildScheduledEvent | Uncached, user: User | Uncached];
/** @event Emitted when a guild's stickers are updated. Requires the `GUILD_EMOJIS_AND_STICKERS` intent. */
guildStickersUpdate: [guild: Guild | Uncached, stickers: Array<Sticker>, oldStickers: Array<Sticker> | null];
/** @event Emitted when a guild becomes unavailable. Requires the `GUILDS` intent. */
guildUnavailable: [guild: UnavailableGuild];
/** @event Emitted when a guild is updated. Requires the `GUILDS` intent. */
guildUpdate: [guild: Guild, oldGuild: JSONGuild | null];
/** @event Emitted when a shard receives the HELLO packet. */
hello: [interval: number, shard: number];
/** @event Emitted when an integration is created. Requires the `GUILD_INTEGRATIONS` intent. */
integrationCreate: [guild: Guild | Uncached, integration: Integration];
/** @event Emitted when an integration is deleted. Requires the `GUILD_INTEGRATIONS` intent. */
integrationDelete: [guild: Guild | Uncached, integration: Integration | PossiblyUncachedIntegration];
/** @event Emitted when an integration is updated. Requires the `GUILD_INTEGRATIONS` intent. */
integrationUpdate: [guild: Guild | Uncached, integration: Integration, oldIntegration: JSONIntegration | null];
/** @event Emitted when an interaction is created. */
interactionCreate: [interaction: AnyInteractionGateway];
/** @event Emitted when an invite is created. Requires the `GUILD_INVITES` intent. */
inviteCreate: [invite: Invite];
/** @event Emitted when an invite is deleted. Requires the `GUILD_INVITES` intent. */
inviteDelete: [invite: PossiblyUncachedInvite];
/** @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. */
messageCreate: [message: Message];
/** @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. */
messageDelete: [message: PossiblyUncachedMessage];
/** @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. */
messageDeleteBulk: [messages: Array<PossiblyUncachedMessage>];
/** @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. */
messageReactionAdd: [message: PossiblyUncachedMessage, reactor: Member | User | Uncached, reaction: PartialEmoji];
/** @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. */
messageReactionRemove: [message: PossiblyUncachedMessage, reactor: Member | User | Uncached, reaction: PartialEmoji];
/** @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. */
messageReactionRemoveAll: [message: PossiblyUncachedMessage];
/** @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. */
messageReactionRemoveEmoji: [message: PossiblyUncachedMessage, reaction: PartialEmoji];
/** @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. */
messageUpdate: [message: Message, oldMessage: JSONMessage | null];
/** @event Emitted when a raw dispatch packet is received. */
packet: [data: AnyDispatchPacket, shard: number];
/** @event Emitted when a guild member's presence, or user is updated. Requires the `GUILD_PRESENCES` intent. */
presenceUpdate: [guild: Guild | Uncached, member: Member | Uncached, presence: Presence, oldPresence: Presence | null];
/** @event Emitted when all shards are ready. */
ready: [];
/** @event Emitted when a request is made. */
request: [rawRequest: RawRequest];
/** @event Emitted when this shard disconnects.*/
shardDisconnect: [err: Error | undefined, id: number];
/** @event Emitted when this shard has processed the READY packet from Discord. */
shardPreReady: [id: number];
/** @event Emitted when a shard is fully ready. */
shardReady: [id: number];
/** @event Emitted when a shard resumes a connection. */
shardResume: [id: number];
/** @event Emitted when a stage instance is created. */
stageInstanceCreate: [instance: StageInstance];
/** @event Emitted when a stage instance is deleted. */
stageInstanceDelete: [instance: StageInstance];
/** @event Emitted when a stage instance is updated. */
stageInstanceUpdate: [instance: StageInstance, oldInstance: JSONStageInstance | null];
/** @event Emitted when a thread is created. Requires the `GUILDS` intent. */
threadCreate: [thread: AnyThreadChannel];
/** @event Emitted when a thread is deleted. Requires the `GUILDS` intent. */
threadDelete: [thread: PossiblyUncachedThread];
/** @event Emitted when a guild's threads are synced. Requires the `GUILDS` intent. */
threadListSync: [threads: Array<AnyThreadChannel>, members: Array<ThreadMember>];
/** @event Emitted when the client's thread member is updated. Requires the `GUILDS` intent. */
threadMemberUpdate: [thread: MinimalPossiblyUncachedThread, member: ThreadMember, oldMember: ThreadMember | null];
/** @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. */
threadMembersUpdate: [thread: MinimalPossiblyUncachedThread, addedMembers: Array<ThreadMember>, removedMembers: Array<ThreadMember | UncachedThreadMember>];
/** @event Emitted when a thread is updated. Requires the `GUILDS` intent. */
threadUpdate: [thread: AnnouncementThreadChannel, oldThread: JSONAnnouncementThreadChannel | null] | [thread: PublicThreadChannel, oldThread: JSONPublicThreadChannel | null] | [thread: PrivateThreadChannel, oldThread: JSONPrivateThreadChannel | null];
/** @event Emitted when a user starts typing. Requires the `GUILD_MESSAGE_TYPING` for guilds, and `DIRECT_MESSAGE_TYPING` for direct messages. */
typingStart: [channel: PrivateChannel | Uncached, user: User | Uncached, startTimestamp: Date] | [channel: AnyGuildTextChannel | Uncached, member: Member, startTimestamp: Date];
/** @event Emitted when a guild is created, but is unavailable. Requires the `GUILDS` intent.*/
unavailableGuildCreate: [guild: UnavailableGuild];
/** @event Emitted when a user is updated. */
userUpdate: [user: User, oldUser: JSONUser | null];
/** @event Emitted when a user joins a voice channel. Requires the `GUILD_VOICE_STATES` intent. */
voiceChannelJoin: [member: Member, channel: VoiceChannel | StageChannel | Uncached];
/** @event Emitted when a user leaves a voice channel. Requires the `GUILD_VOICE_STATES` intent. */
voiceChannelLeave: [member: Member, channel: VoiceChannel | StageChannel | Uncached];
/** @event Emitted when a user switches voice channels. Requires the `GUILD_VOICE_STATES` intent. */
voiceChannelSwitch: [member: Member, channel: VoiceChannel | StageChannel | Uncached, oldChannel: VoiceChannel | StageChannel | Uncached | null];
/** @event Emitted when a user's voice state is updated. Requires the `GUILD_VOICE_STATES` intent. */
voiceStateUpdate: [member: Member, oldState: JSONVoiceState | null];
/** @event Emitted with various warning information. */
warn: [info: string, shard?: number];
/** @event Emitted when a guild's webhooks are updated. Requires the `GUILD_WEBHOOKS` intent. */
webhooksUpdate: [guild: Guild | Uncached, channel: AnyGuildChannelWithoutThreads | Uncached];
}
export interface ShardEvents {
/** @event Emitted with various information for debugging. */
debug: [info: string];
/** @event Emitted when this shard disconnects.*/
disconnect: [err?: Error];
/** @event Emitted when an error happens. If an error is emitted and no handlers are present, the error will be thrown. */
error: [info: Error | string];
/** @event Emitted when this shard has processed the READY packet from Discord. */
preReady: [];
/** @event Emitted when this shard is fully ready. */
ready: [];
/** @event Emitted when this shard resumes a connection. */
resume: [];
/** @event Emitted with various warning information. */
warn: [info: string];
}