chapterjs 0.2.3 → 0.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/README.md +65 -0
- package/dist/cli/build.js +14 -1
- package/dist/cli/cli.js +41 -6
- package/dist/cli/dev.js +29 -1
- package/dist/cli/env.d.ts +5 -0
- package/dist/cli/env.js +39 -3
- package/dist/cli/project.d.ts +49 -7
- package/dist/cli/project.js +103 -19
- package/dist/cli/redis.d.ts +23 -0
- package/dist/cli/redis.js +57 -0
- package/dist/cli/start.js +43 -17
- package/dist/cli/test.d.ts +29 -0
- package/dist/cli/test.js +446 -0
- package/dist/commands/autocomplete.d.ts +1 -1
- package/dist/commands/autocomplete.js +37 -41
- package/dist/commands/router.d.ts +4 -1
- package/dist/commands/router.js +15 -17
- package/dist/components/router.d.ts +7 -2
- package/dist/components/router.js +16 -16
- package/dist/discord/types/channel.d.ts +9 -1
- package/dist/discord/types/guild.d.ts +5 -5
- package/dist/discord/types/permissions.d.ts +6 -0
- package/dist/discord/types/poll.d.ts +7 -1
- package/dist/events/registry.d.ts +252 -239
- package/dist/events/registry.js +125 -100
- package/dist/events/router.d.ts +9 -4
- package/dist/events/router.js +24 -11
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -0
- package/dist/interactions/dispatch.d.ts +5 -1
- package/dist/interactions/dispatch.js +6 -2
- package/dist/loader/hot.js +22 -2
- package/dist/loader/loader.d.ts +7 -0
- package/dist/loader/loader.js +22 -12
- package/dist/ranking/declaration.d.ts +12 -0
- package/dist/ranking/declaration.js +48 -0
- package/dist/ranking/ranking.d.ts +102 -0
- package/dist/ranking/ranking.js +129 -0
- package/dist/redis/client.d.ts +36 -0
- package/dist/redis/client.js +252 -0
- package/dist/redis/protocol.d.ts +22 -0
- package/dist/redis/protocol.js +99 -0
- package/dist/redis/url.d.ts +24 -0
- package/dist/redis/url.js +50 -0
- package/dist/store/backend.d.ts +49 -4
- package/dist/store/backend.js +66 -11
- package/dist/store/declaration.d.ts +3 -0
- package/dist/store/declaration.js +8 -3
- package/dist/store/file-backend.d.ts +3 -1
- package/dist/store/file-backend.js +29 -0
- package/dist/store/ipc-backend.d.ts +24 -1
- package/dist/store/ipc-backend.js +49 -0
- package/dist/store/memory-backend.d.ts +17 -0
- package/dist/store/memory-backend.js +82 -0
- package/dist/store/ranking-backend.d.ts +45 -0
- package/dist/store/ranking-backend.js +82 -0
- package/dist/store/redis-backend.d.ts +38 -0
- package/dist/store/redis-backend.js +245 -0
- package/dist/store/redis-ranking.d.ts +15 -0
- package/dist/store/redis-ranking.js +69 -0
- package/dist/store/scope.d.ts +11 -0
- package/dist/store/scope.js +23 -0
- package/dist/store/store.d.ts +39 -5
- package/dist/store/store.js +83 -33
- package/dist/structures/invite.d.ts +6 -0
- package/dist/structures/invite.js +11 -0
- package/dist/tasks/scheduler.d.ts +6 -0
- package/dist/tasks/scheduler.js +9 -3
- package/dist/testing/failure.d.ts +9 -0
- package/dist/testing/failure.js +20 -0
- package/dist/testing/fake-discord.d.ts +59 -0
- package/dist/testing/fake-discord.js +120 -0
- package/dist/testing/fake-gateway.d.ts +59 -0
- package/dist/testing/fake-gateway.js +123 -0
- package/dist/testing/harness.d.ts +387 -0
- package/dist/testing/harness.js +1418 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +5 -0
- package/dist/testing/scenario.d.ts +39 -0
- package/dist/testing/scenario.js +58 -0
- package/dist/testing/smoke.d.ts +20 -0
- package/dist/testing/smoke.js +659 -0
- package/dist/testing/websocket.d.ts +34 -0
- package/dist/testing/websocket.js +167 -0
- package/dist/testing/world.d.ts +145 -0
- package/dist/testing/world.js +1479 -0
- package/package.json +20 -3
|
@@ -11,7 +11,152 @@ import type { DmMessage, GuildMessage, MemberMessage, Message, PrivateMessage, R
|
|
|
11
11
|
import type { Role } from '../structures/role.js';
|
|
12
12
|
import type { User, UserPresence } from '../structures/user.js';
|
|
13
13
|
import type { TranslationContext } from '../messages/messages.js';
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* A message that was deleted: what is known of it. The message itself is
|
|
16
|
+
* only there when the bot remembered it.
|
|
17
|
+
*/
|
|
18
|
+
export interface DeletedMessage {
|
|
19
|
+
/** The id of the deleted message. */
|
|
20
|
+
id: Snowflake;
|
|
21
|
+
/** The id of the channel the message was in. */
|
|
22
|
+
channelId: Snowflake;
|
|
23
|
+
/** The channel, when the bot knows it. */
|
|
24
|
+
channel: TextBasedChannel | null;
|
|
25
|
+
/** The id of the server; `null` for a private message. */
|
|
26
|
+
guildId: Snowflake | null;
|
|
27
|
+
/** The message as it was, when the bot remembered it. */
|
|
28
|
+
before: Message | null;
|
|
29
|
+
}
|
|
30
|
+
/** A reaction added to a message, or removed from it. */
|
|
31
|
+
export interface UserReaction {
|
|
32
|
+
/** The emoji of the reaction. */
|
|
33
|
+
emoji: ReactionEmoji;
|
|
34
|
+
/** Who reacted. */
|
|
35
|
+
user: User;
|
|
36
|
+
/** Who reacted, as a member of the server: `null` in a private message, or when the bot does not remember them. */
|
|
37
|
+
member: GuildMember | null;
|
|
38
|
+
/** Whether it is a super reaction. */
|
|
39
|
+
burst: boolean;
|
|
40
|
+
/** The id of the message. */
|
|
41
|
+
messageId: Snowflake;
|
|
42
|
+
/** The message, when the bot remembers it. */
|
|
43
|
+
message: Message | null;
|
|
44
|
+
/** The id of the channel of the message. */
|
|
45
|
+
channelId: Snowflake;
|
|
46
|
+
/** The channel of the message, when the bot knows it. */
|
|
47
|
+
channel: TextBasedChannel | null;
|
|
48
|
+
/** The id of the server; `null` in a private message. */
|
|
49
|
+
guildId: Snowflake | null;
|
|
50
|
+
}
|
|
51
|
+
/** A reaction added to a message: what Discord tells of its message too. */
|
|
52
|
+
export interface AddedReaction extends UserReaction {
|
|
53
|
+
/** The id of who wrote the message, when Discord says it. */
|
|
54
|
+
messageAuthorId: Snowflake | null;
|
|
55
|
+
}
|
|
56
|
+
/** Reactions removed from a message at once: all of them, or every reaction of one emoji. */
|
|
57
|
+
export interface ClearedReactions {
|
|
58
|
+
/** The emoji whose reactions were removed; `null` when all were. */
|
|
59
|
+
emoji: ReactionEmoji | null;
|
|
60
|
+
/** The id of the message. */
|
|
61
|
+
messageId: Snowflake;
|
|
62
|
+
/** The message, when the bot remembers it. */
|
|
63
|
+
message: Message | null;
|
|
64
|
+
/** The id of the channel of the message. */
|
|
65
|
+
channelId: Snowflake;
|
|
66
|
+
/** The channel of the message, when the bot knows it. */
|
|
67
|
+
channel: TextBasedChannel | null;
|
|
68
|
+
/** The id of the server; `null` in a private message. */
|
|
69
|
+
guildId: Snowflake | null;
|
|
70
|
+
}
|
|
71
|
+
/** A vote in a poll, given or taken back. */
|
|
72
|
+
export interface PollVote {
|
|
73
|
+
/** The id Discord gave to the answer: today, its position in the poll, `1` for the first answer. */
|
|
74
|
+
answerId: number;
|
|
75
|
+
/** Who voted. */
|
|
76
|
+
user: User;
|
|
77
|
+
/** Who voted, as a member of the server, when the bot remembers it. */
|
|
78
|
+
member: GuildMember | null;
|
|
79
|
+
/** The id of the message of the poll. */
|
|
80
|
+
messageId: Snowflake;
|
|
81
|
+
/** The message of the poll, when the bot remembers it. */
|
|
82
|
+
message: Message | null;
|
|
83
|
+
/** The id of the channel of the poll. */
|
|
84
|
+
channelId: Snowflake;
|
|
85
|
+
/** The channel of the poll, when the bot knows it. */
|
|
86
|
+
channel: TextBasedChannel | null;
|
|
87
|
+
/** The id of the server; `null` in a private message. */
|
|
88
|
+
guildId: Snowflake | null;
|
|
89
|
+
}
|
|
90
|
+
/** Someone typing in a channel. */
|
|
91
|
+
export interface Typing {
|
|
92
|
+
/** Who is typing. */
|
|
93
|
+
user: User;
|
|
94
|
+
/** Who is typing, as a member of the server; `null` in a private message. */
|
|
95
|
+
member: GuildMember | null;
|
|
96
|
+
/** When they started. */
|
|
97
|
+
startedAt: Date;
|
|
98
|
+
/** The id of the channel. */
|
|
99
|
+
channelId: Snowflake;
|
|
100
|
+
/** The channel, when the bot knows it. */
|
|
101
|
+
channel: TextBasedChannel | null;
|
|
102
|
+
/** The id of the server; `null` in a private message. */
|
|
103
|
+
guildId: Snowflake | null;
|
|
104
|
+
}
|
|
105
|
+
/** An invite that was deleted, or expired: what is left of it. */
|
|
106
|
+
export interface DeletedInvite {
|
|
107
|
+
/** The code of the invite (`discord.gg/code`). */
|
|
108
|
+
code: string;
|
|
109
|
+
/** The channel the invite led to. */
|
|
110
|
+
channel: GuildChannel;
|
|
111
|
+
}
|
|
112
|
+
/** Someone in a voice channel: who, where, and their voice state. */
|
|
113
|
+
export interface VoiceActivity {
|
|
114
|
+
/** Who it is. */
|
|
115
|
+
member: GuildMember;
|
|
116
|
+
/** The voice channel. */
|
|
117
|
+
channel: VoiceChannel;
|
|
118
|
+
/** Their voice state: muted, deafened, streaming... */
|
|
119
|
+
state: VoiceState;
|
|
120
|
+
}
|
|
121
|
+
/** Someone who went from one voice channel to another. */
|
|
122
|
+
export interface VoiceMove {
|
|
123
|
+
/** Who moved. */
|
|
124
|
+
member: GuildMember;
|
|
125
|
+
/** The channel they left. */
|
|
126
|
+
from: VoiceChannel;
|
|
127
|
+
/** The channel they are in now. */
|
|
128
|
+
to: VoiceChannel;
|
|
129
|
+
/** Their voice state, as it is now. */
|
|
130
|
+
state: VoiceState;
|
|
131
|
+
}
|
|
132
|
+
/** Someone in a voice channel whose voice state changed. */
|
|
133
|
+
export interface VoiceChange extends VoiceActivity {
|
|
134
|
+
/** Their voice state as it was. */
|
|
135
|
+
before: VoiceState;
|
|
136
|
+
}
|
|
137
|
+
/** Someone's status or activity, as it is now, and whose it is. */
|
|
138
|
+
export interface PresenceChange extends UserPresence {
|
|
139
|
+
/** The id of whose presence changed. */
|
|
140
|
+
userId: Snowflake;
|
|
141
|
+
/** The account of whose presence changed, when the bot knows it. */
|
|
142
|
+
user: User | null;
|
|
143
|
+
/** Whose presence changed, as a member of the server, when the bot remembers it. */
|
|
144
|
+
member: GuildMember | null;
|
|
145
|
+
}
|
|
146
|
+
/** Someone interested in a scheduled event, or no longer. */
|
|
147
|
+
export interface ScheduledEventInterest {
|
|
148
|
+
/** The id of the scheduled event. */
|
|
149
|
+
scheduledEventId: Snowflake;
|
|
150
|
+
/** Who it is. */
|
|
151
|
+
user: User;
|
|
152
|
+
/** Who it is, as a member of the server, when the bot remembers it. */
|
|
153
|
+
member: GuildMember | null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* What your function receives, for each event: what the event is about,
|
|
157
|
+
* the server it happened in, and `t`. The widest form: the options of a
|
|
158
|
+
* file narrow it (`ContextOf`).
|
|
159
|
+
*/
|
|
15
160
|
export interface EventContexts {
|
|
16
161
|
/** The bot is connected and knows every server it is in. */
|
|
17
162
|
ready: {
|
|
@@ -24,26 +169,22 @@ export interface EventContexts {
|
|
|
24
169
|
messageCreate: {
|
|
25
170
|
/** The message that was sent. */
|
|
26
171
|
message: Message;
|
|
172
|
+
/** The server; `null` for a private message. */
|
|
173
|
+
guild: Guild | null;
|
|
27
174
|
};
|
|
28
175
|
/** A message was edited. */
|
|
29
176
|
messageUpdate: {
|
|
30
177
|
/** The message, as it is now. */
|
|
31
178
|
message: Message;
|
|
179
|
+
/** The server; `null` for a private message. */
|
|
180
|
+
guild: Guild | null;
|
|
32
181
|
};
|
|
33
182
|
/** A message was deleted. */
|
|
34
183
|
messageDelete: {
|
|
35
|
-
/** The
|
|
36
|
-
|
|
37
|
-
/** The id of the channel the message was in. */
|
|
38
|
-
channelId: Snowflake;
|
|
39
|
-
/** The id of the server; `null` for a private message. */
|
|
40
|
-
guildId: Snowflake | null;
|
|
184
|
+
/** The message that was deleted. */
|
|
185
|
+
message: DeletedMessage;
|
|
41
186
|
/** The server; `null` for a private message. */
|
|
42
187
|
guild: Guild | null;
|
|
43
|
-
/** The channel, when the bot knows it. */
|
|
44
|
-
channel: TextBasedChannel | null;
|
|
45
|
-
/** The message as it was, when the bot remembered it. */
|
|
46
|
-
message: Message | null;
|
|
47
188
|
};
|
|
48
189
|
/** Someone joined a server. */
|
|
49
190
|
memberJoin: {
|
|
@@ -58,8 +199,6 @@ export interface EventContexts {
|
|
|
58
199
|
user: User;
|
|
59
200
|
/** The server they left. */
|
|
60
201
|
guild: Guild;
|
|
61
|
-
/** The member as it was, when the bot knew it. */
|
|
62
|
-
member: GuildMember | null;
|
|
63
202
|
};
|
|
64
203
|
/** A member changed: nickname, roles, timeout, avatar... */
|
|
65
204
|
memberUpdate: {
|
|
@@ -82,16 +221,22 @@ export interface EventContexts {
|
|
|
82
221
|
channelCreate: {
|
|
83
222
|
/** The new channel or thread. */
|
|
84
223
|
channel: GuildChannel | ThreadChannel | Channel;
|
|
224
|
+
/** The server of the channel; `null` for a private conversation. */
|
|
225
|
+
guild: Guild | null;
|
|
85
226
|
};
|
|
86
227
|
/** A channel changed: name, topic, permissions... */
|
|
87
228
|
channelUpdate: {
|
|
88
229
|
/** The channel or thread, as it is now. */
|
|
89
230
|
channel: GuildChannel | ThreadChannel | Channel;
|
|
231
|
+
/** The server of the channel; `null` for a private conversation. */
|
|
232
|
+
guild: Guild | null;
|
|
90
233
|
};
|
|
91
234
|
/** A channel was deleted. */
|
|
92
235
|
channelDelete: {
|
|
93
236
|
/** The channel or thread as it was. */
|
|
94
237
|
channel: GuildChannel | ThreadChannel | Channel;
|
|
238
|
+
/** The server of the channel; `null` for a private conversation. */
|
|
239
|
+
guild: Guild | null;
|
|
95
240
|
};
|
|
96
241
|
/** A role was created. */
|
|
97
242
|
roleCreate: {
|
|
@@ -109,12 +254,10 @@ export interface EventContexts {
|
|
|
109
254
|
};
|
|
110
255
|
/** A role was deleted. */
|
|
111
256
|
roleDelete: {
|
|
112
|
-
/** The id of the deleted role. */
|
|
113
|
-
roleId: Snowflake;
|
|
114
|
-
/** The server the role was in. */
|
|
115
|
-
guild: Guild;
|
|
116
257
|
/** The role as it was. */
|
|
117
258
|
role: Role;
|
|
259
|
+
/** The server the role was in. */
|
|
260
|
+
guild: Guild;
|
|
118
261
|
};
|
|
119
262
|
/** The server changed: name, icon, settings... */
|
|
120
263
|
guildUpdate: {
|
|
@@ -162,17 +305,13 @@ export interface EventContexts {
|
|
|
162
305
|
invite: Invite;
|
|
163
306
|
/** The server the invite leads to. */
|
|
164
307
|
guild: Guild;
|
|
165
|
-
/** The channel the invite leads to. */
|
|
166
|
-
channel: GuildChannel;
|
|
167
308
|
};
|
|
168
309
|
/** An invite was deleted, or expired. */
|
|
169
310
|
inviteDelete: {
|
|
170
|
-
/** The
|
|
171
|
-
|
|
311
|
+
/** The invite that was deleted. */
|
|
312
|
+
invite: DeletedInvite;
|
|
172
313
|
/** The server the invite led to. */
|
|
173
314
|
guild: Guild;
|
|
174
|
-
/** The channel the invite led to. */
|
|
175
|
-
channel: GuildChannel;
|
|
176
315
|
};
|
|
177
316
|
/** Something was added to the audit log of a server. */
|
|
178
317
|
auditLogEntryCreate: {
|
|
@@ -183,125 +322,43 @@ export interface EventContexts {
|
|
|
183
322
|
};
|
|
184
323
|
/** Someone added a reaction to a message. */
|
|
185
324
|
reactionAdd: {
|
|
186
|
-
/** The
|
|
187
|
-
|
|
188
|
-
/** Who reacted. */
|
|
189
|
-
user: User;
|
|
190
|
-
/** Who reacted, as a member of the server; `null` in a private message. */
|
|
191
|
-
member: GuildMember | null;
|
|
192
|
-
/** Whether it is a super reaction. */
|
|
193
|
-
burst: boolean;
|
|
194
|
-
/** The id of the message. */
|
|
195
|
-
messageId: Snowflake;
|
|
196
|
-
/** The message, when the bot remembers it. */
|
|
197
|
-
message: Message | null;
|
|
198
|
-
/** The id of who wrote the message, when Discord says it. */
|
|
199
|
-
messageAuthorId: Snowflake | null;
|
|
200
|
-
/** The id of the channel of the message. */
|
|
201
|
-
channelId: Snowflake;
|
|
202
|
-
/** The channel of the message, when the bot knows it. */
|
|
203
|
-
channel: TextBasedChannel | null;
|
|
204
|
-
/** The id of the server; `null` in a private message. */
|
|
205
|
-
guildId: Snowflake | null;
|
|
325
|
+
/** The reaction that was added. */
|
|
326
|
+
reaction: AddedReaction;
|
|
206
327
|
/** The server; `null` in a private message. */
|
|
207
328
|
guild: Guild | null;
|
|
208
329
|
};
|
|
209
330
|
/** Someone removed their reaction from a message. */
|
|
210
331
|
reactionRemove: {
|
|
211
|
-
/** The
|
|
212
|
-
|
|
213
|
-
/** Who had reacted. */
|
|
214
|
-
user: User;
|
|
215
|
-
/** Who had reacted, as a member of the server, when the bot remembers it. */
|
|
216
|
-
member: GuildMember | null;
|
|
217
|
-
/** Whether it was a super reaction. */
|
|
218
|
-
burst: boolean;
|
|
219
|
-
/** The id of the message. */
|
|
220
|
-
messageId: Snowflake;
|
|
221
|
-
/** The message, when the bot remembers it. */
|
|
222
|
-
message: Message | null;
|
|
223
|
-
/** The id of the channel of the message. */
|
|
224
|
-
channelId: Snowflake;
|
|
225
|
-
/** The channel of the message, when the bot knows it. */
|
|
226
|
-
channel: TextBasedChannel | null;
|
|
227
|
-
/** The id of the server; `null` in a private message. */
|
|
228
|
-
guildId: Snowflake | null;
|
|
332
|
+
/** The reaction that was removed. */
|
|
333
|
+
reaction: UserReaction;
|
|
229
334
|
/** The server; `null` in a private message. */
|
|
230
335
|
guild: Guild | null;
|
|
231
336
|
};
|
|
232
337
|
/** The reactions of a message were removed: all of them, or every reaction of one emoji. */
|
|
233
338
|
reactionClear: {
|
|
234
|
-
/** The
|
|
235
|
-
|
|
236
|
-
/** The id of the message. */
|
|
237
|
-
messageId: Snowflake;
|
|
238
|
-
/** The message, when the bot remembers it. */
|
|
239
|
-
message: Message | null;
|
|
240
|
-
/** The id of the channel of the message. */
|
|
241
|
-
channelId: Snowflake;
|
|
242
|
-
/** The channel of the message, when the bot knows it. */
|
|
243
|
-
channel: TextBasedChannel | null;
|
|
244
|
-
/** The id of the server; `null` in a private message. */
|
|
245
|
-
guildId: Snowflake | null;
|
|
339
|
+
/** The reactions that were removed. */
|
|
340
|
+
reactions: ClearedReactions;
|
|
246
341
|
/** The server; `null` in a private message. */
|
|
247
342
|
guild: Guild | null;
|
|
248
343
|
};
|
|
249
344
|
/** Someone voted in a poll. */
|
|
250
345
|
pollVoteAdd: {
|
|
251
|
-
/** The
|
|
252
|
-
|
|
253
|
-
/** Who voted. */
|
|
254
|
-
user: User;
|
|
255
|
-
/** Who voted, as a member of the server, when the bot remembers it. */
|
|
256
|
-
member: GuildMember | null;
|
|
257
|
-
/** The id of the message of the poll. */
|
|
258
|
-
messageId: Snowflake;
|
|
259
|
-
/** The message of the poll, when the bot remembers it. */
|
|
260
|
-
message: Message | null;
|
|
261
|
-
/** The id of the channel of the poll. */
|
|
262
|
-
channelId: Snowflake;
|
|
263
|
-
/** The channel of the poll, when the bot knows it. */
|
|
264
|
-
channel: TextBasedChannel | null;
|
|
265
|
-
/** The id of the server; `null` in a private message. */
|
|
266
|
-
guildId: Snowflake | null;
|
|
346
|
+
/** The vote. */
|
|
347
|
+
vote: PollVote;
|
|
267
348
|
/** The server; `null` in a private message. */
|
|
268
349
|
guild: Guild | null;
|
|
269
350
|
};
|
|
270
351
|
/** Someone took back their vote in a poll. */
|
|
271
352
|
pollVoteRemove: {
|
|
272
|
-
/** The
|
|
273
|
-
|
|
274
|
-
/** Who had voted. */
|
|
275
|
-
user: User;
|
|
276
|
-
/** Who had voted, as a member of the server, when the bot remembers it. */
|
|
277
|
-
member: GuildMember | null;
|
|
278
|
-
/** The id of the message of the poll. */
|
|
279
|
-
messageId: Snowflake;
|
|
280
|
-
/** The message of the poll, when the bot remembers it. */
|
|
281
|
-
message: Message | null;
|
|
282
|
-
/** The id of the channel of the poll. */
|
|
283
|
-
channelId: Snowflake;
|
|
284
|
-
/** The channel of the poll, when the bot knows it. */
|
|
285
|
-
channel: TextBasedChannel | null;
|
|
286
|
-
/** The id of the server; `null` in a private message. */
|
|
287
|
-
guildId: Snowflake | null;
|
|
353
|
+
/** The vote taken back. */
|
|
354
|
+
vote: PollVote;
|
|
288
355
|
/** The server; `null` in a private message. */
|
|
289
356
|
guild: Guild | null;
|
|
290
357
|
};
|
|
291
358
|
/** Someone started typing in a channel. */
|
|
292
359
|
typingStart: {
|
|
293
|
-
/** Who is typing. */
|
|
294
|
-
|
|
295
|
-
/** Who is typing, as a member of the server; `null` in a private message. */
|
|
296
|
-
member: GuildMember | null;
|
|
297
|
-
/** When they started. */
|
|
298
|
-
startedAt: Date;
|
|
299
|
-
/** The id of the channel. */
|
|
300
|
-
channelId: Snowflake;
|
|
301
|
-
/** The channel, when the bot knows it. */
|
|
302
|
-
channel: TextBasedChannel | null;
|
|
303
|
-
/** The id of the server; `null` in a private message. */
|
|
304
|
-
guildId: Snowflake | null;
|
|
360
|
+
/** Who is typing, and where. */
|
|
361
|
+
typing: Typing;
|
|
305
362
|
/** The server; `null` in a private message. */
|
|
306
363
|
guild: Guild | null;
|
|
307
364
|
};
|
|
@@ -311,8 +368,6 @@ export interface EventContexts {
|
|
|
311
368
|
thread: ThreadChannel;
|
|
312
369
|
/** Who was added, as a member of the server. */
|
|
313
370
|
member: GuildMember;
|
|
314
|
-
/** The account of who was added. */
|
|
315
|
-
user: User;
|
|
316
371
|
/** The server of the thread. */
|
|
317
372
|
guild: Guild;
|
|
318
373
|
};
|
|
@@ -322,8 +377,6 @@ export interface EventContexts {
|
|
|
322
377
|
thread: ThreadChannel;
|
|
323
378
|
/** The id of who was removed. */
|
|
324
379
|
userId: Snowflake;
|
|
325
|
-
/** The account of who was removed, when the bot knows it. */
|
|
326
|
-
user: User | null;
|
|
327
380
|
/** Who was removed, as a member of the server, when the bot remembers it. */
|
|
328
381
|
member: GuildMember | null;
|
|
329
382
|
/** The server of the thread. */
|
|
@@ -331,62 +384,36 @@ export interface EventContexts {
|
|
|
331
384
|
};
|
|
332
385
|
/** Someone joined a voice channel. */
|
|
333
386
|
voiceJoin: {
|
|
334
|
-
/** Who joined. */
|
|
335
|
-
|
|
336
|
-
/** The channel they joined. */
|
|
337
|
-
channel: VoiceChannel;
|
|
338
|
-
/** Their voice state: muted, deafened, streaming... */
|
|
339
|
-
voice: VoiceState;
|
|
387
|
+
/** Who joined, the channel, and their voice state. */
|
|
388
|
+
voice: VoiceActivity;
|
|
340
389
|
/** The server of the channel. */
|
|
341
390
|
guild: Guild;
|
|
342
391
|
};
|
|
343
392
|
/** Someone left a voice channel, or was disconnected. */
|
|
344
393
|
voiceLeave: {
|
|
345
|
-
/** Who left. */
|
|
346
|
-
|
|
347
|
-
/** The channel they left. */
|
|
348
|
-
channel: VoiceChannel;
|
|
349
|
-
/** Their voice state as it was, in that channel. */
|
|
350
|
-
voice: VoiceState;
|
|
394
|
+
/** Who left, the channel they left, and their voice state as it was. */
|
|
395
|
+
voice: VoiceActivity;
|
|
351
396
|
/** The server of the channel. */
|
|
352
397
|
guild: Guild;
|
|
353
398
|
};
|
|
354
399
|
/** Someone went from one voice channel to another, or was moved. */
|
|
355
400
|
voiceMove: {
|
|
356
|
-
/** Who moved. */
|
|
357
|
-
|
|
358
|
-
/** The channel they left. */
|
|
359
|
-
from: VoiceChannel;
|
|
360
|
-
/** The channel they are in now. */
|
|
361
|
-
to: VoiceChannel;
|
|
362
|
-
/** Their voice state, as it is now. */
|
|
363
|
-
voice: VoiceState;
|
|
401
|
+
/** Who moved, from where, to where. */
|
|
402
|
+
voice: VoiceMove;
|
|
364
403
|
/** The server of the channels. */
|
|
365
404
|
guild: Guild;
|
|
366
405
|
};
|
|
367
406
|
/** Someone in a voice channel changed: muted, deafened, started a stream or a camera... */
|
|
368
407
|
voiceUpdate: {
|
|
369
|
-
/** Who changed. */
|
|
370
|
-
|
|
371
|
-
/** The channel they are in. */
|
|
372
|
-
channel: VoiceChannel;
|
|
373
|
-
/** Their voice state, as it is now. */
|
|
374
|
-
voice: VoiceState;
|
|
375
|
-
/** Their voice state as it was. */
|
|
376
|
-
before: VoiceState;
|
|
408
|
+
/** Who changed, their voice state now and before. */
|
|
409
|
+
voice: VoiceChange;
|
|
377
410
|
/** The server of the channel. */
|
|
378
411
|
guild: Guild;
|
|
379
412
|
};
|
|
380
413
|
/** Someone's status or activity changed: online, idle, playing a game... */
|
|
381
414
|
presenceUpdate: {
|
|
382
|
-
/** The
|
|
383
|
-
|
|
384
|
-
/** The account of whose presence changed, when the bot knows it. */
|
|
385
|
-
user: User | null;
|
|
386
|
-
/** Whose presence changed, as a member of the server, when the bot remembers it. */
|
|
387
|
-
member: GuildMember | null;
|
|
388
|
-
/** Their status, activities and devices, as they are now. */
|
|
389
|
-
presence: UserPresence;
|
|
415
|
+
/** The presence as it is now, and whose it is. */
|
|
416
|
+
presence: PresenceChange;
|
|
390
417
|
/** The server the change is seen from. */
|
|
391
418
|
guild: Guild;
|
|
392
419
|
};
|
|
@@ -413,23 +440,15 @@ export interface EventContexts {
|
|
|
413
440
|
};
|
|
414
441
|
/** Someone said they are interested in a scheduled event. */
|
|
415
442
|
scheduledEventUserAdd: {
|
|
416
|
-
/**
|
|
417
|
-
|
|
418
|
-
/** Who is interested. */
|
|
419
|
-
user: User;
|
|
420
|
-
/** Who is interested, as a member of the server, when the bot remembers it. */
|
|
421
|
-
member: GuildMember | null;
|
|
443
|
+
/** Who is interested, in which scheduled event. */
|
|
444
|
+
interest: ScheduledEventInterest;
|
|
422
445
|
/** The server of the scheduled event. */
|
|
423
446
|
guild: Guild;
|
|
424
447
|
};
|
|
425
448
|
/** Someone is no longer interested in a scheduled event. */
|
|
426
449
|
scheduledEventUserRemove: {
|
|
427
|
-
/**
|
|
428
|
-
|
|
429
|
-
/** Who is no longer interested. */
|
|
430
|
-
user: User;
|
|
431
|
-
/** Who is no longer interested, as a member of the server, when the bot remembers it. */
|
|
432
|
-
member: GuildMember | null;
|
|
450
|
+
/** Who is no longer interested, in which scheduled event. */
|
|
451
|
+
interest: ScheduledEventInterest;
|
|
433
452
|
/** The server of the scheduled event. */
|
|
434
453
|
guild: Guild;
|
|
435
454
|
};
|
|
@@ -493,88 +512,67 @@ type IsOn<Options, Key extends string> = Key extends keyof Options ? Exclude<Opt
|
|
|
493
512
|
* it says nothing, every place it may be when it is only known to be one.
|
|
494
513
|
*/
|
|
495
514
|
type WhereOf<Options> = 'where' extends keyof Options ? [Exclude<Options['where'], undefined>] extends [never] ? 'guild' : Exclude<Options['where'], undefined> : 'guild';
|
|
496
|
-
/**
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
interface DeletedInGuild extends Deleted {
|
|
503
|
-
/** The id of the server. */
|
|
504
|
-
guildId: Snowflake;
|
|
505
|
-
/** The server the message was in. */
|
|
506
|
-
guild: Guild;
|
|
507
|
-
/** The channel the message was in. */
|
|
508
|
-
channel: GuildTextBasedChannel;
|
|
509
|
-
/** The message as it was, when the bot remembered it. */
|
|
510
|
-
message: GuildMessage | null;
|
|
511
|
-
}
|
|
512
|
-
/** A private message deleted, for a file that receives both kinds. */
|
|
513
|
-
interface DeletedInPrivate extends Deleted {
|
|
514
|
-
/** No server: the message was private. */
|
|
515
|
-
guildId: null;
|
|
516
|
-
/** No server: the message was private. */
|
|
517
|
-
guild: null;
|
|
518
|
-
/** The private conversation, when the bot knows it. */
|
|
519
|
-
channel: DMChannel | null;
|
|
520
|
-
/** The message as it was, when the bot remembered it. */
|
|
521
|
-
message: PrivateMessage | null;
|
|
522
|
-
}
|
|
523
|
-
/** A private message deleted, for a file that only receives those. */
|
|
524
|
-
interface DeletedInDm extends Deleted {
|
|
525
|
-
/** The private conversation, when the bot knows it. */
|
|
526
|
-
channel: DMChannel | null;
|
|
527
|
-
/** The message as it was, when the bot remembered it. */
|
|
528
|
-
message: DmMessage | null;
|
|
529
|
-
}
|
|
530
|
-
type DeletedFor<Where> = Where extends 'guild' ? DeletedInGuild : Where extends 'dm' ? DeletedInDm : DeletedInGuild | DeletedInPrivate;
|
|
531
|
-
/** Where something happened in a server: the server and the channel are there. */
|
|
532
|
-
interface ServerPlace {
|
|
515
|
+
/**
|
|
516
|
+
* Something about a message, told apart by where it happened: in a server
|
|
517
|
+
* the server is there and the channel is one of the server; in private,
|
|
518
|
+
* the conversation, when the bot knows it.
|
|
519
|
+
*/
|
|
520
|
+
interface InServer {
|
|
533
521
|
/** The id of the server. */
|
|
534
522
|
guildId: Snowflake;
|
|
535
|
-
/** The server. */
|
|
536
|
-
guild: Guild;
|
|
537
523
|
/** The channel. */
|
|
538
524
|
channel: GuildTextBasedChannel;
|
|
539
525
|
}
|
|
540
|
-
/**
|
|
541
|
-
interface
|
|
526
|
+
/** In private, for a file that receives both kinds. */
|
|
527
|
+
interface InPrivate {
|
|
542
528
|
/** No server: it happened in private. */
|
|
543
529
|
guildId: null;
|
|
544
|
-
/** No server: it happened in private. */
|
|
545
|
-
guild: null;
|
|
546
530
|
/** The private conversation, when the bot knows it. */
|
|
547
531
|
channel: DMChannel | null;
|
|
548
532
|
}
|
|
549
|
-
/**
|
|
550
|
-
interface
|
|
533
|
+
/** In private, for a file that only receives that. */
|
|
534
|
+
interface InDm {
|
|
551
535
|
/** The private conversation, when the bot knows it. */
|
|
552
536
|
channel: DMChannel | null;
|
|
553
537
|
}
|
|
554
|
-
/** The
|
|
538
|
+
/** The fields of an object that its place narrows. */
|
|
539
|
+
type PlaceKeys = 'guildId' | 'channel' | 'message' | 'member' | 'before';
|
|
540
|
+
/** `T` without what its place narrows: the rest is the same everywhere. */
|
|
541
|
+
type Unplaced<T> = Omit<T, PlaceKeys>;
|
|
542
|
+
/**
|
|
543
|
+
* What a file receives for an event of servers and private messages,
|
|
544
|
+
* following where it listens: the object of the event under `Key`, and
|
|
545
|
+
* the server when there is one. With `'both'`, a union told apart by
|
|
546
|
+
* `guild`.
|
|
547
|
+
*/
|
|
548
|
+
type Placed<Where, Key extends string, InGuild, Private, Dm> = Where extends 'guild' ? {
|
|
549
|
+
[K in Key]: InGuild;
|
|
550
|
+
} & {
|
|
551
|
+
guild: Guild;
|
|
552
|
+
} : Where extends 'dm' ? {
|
|
553
|
+
[K in Key]: Dm;
|
|
554
|
+
} : ({
|
|
555
|
+
[K in Key]: InGuild;
|
|
556
|
+
} & {
|
|
557
|
+
guild: Guild;
|
|
558
|
+
}) | ({
|
|
559
|
+
[K in Key]: Private;
|
|
560
|
+
} & {
|
|
561
|
+
guild: null;
|
|
562
|
+
});
|
|
563
|
+
/** A message the bot remembers, in each place. */
|
|
555
564
|
interface ServerMessagePart {
|
|
556
565
|
/** The message, when the bot remembers it. */
|
|
557
566
|
message: GuildMessage | null;
|
|
558
567
|
}
|
|
559
|
-
/** The message of something that happened in private, for both kinds. */
|
|
560
568
|
interface PrivateMessagePart {
|
|
561
569
|
/** The message, when the bot remembers it. */
|
|
562
570
|
message: PrivateMessage | null;
|
|
563
571
|
}
|
|
564
|
-
/** The message of something that happened in private, for that only. */
|
|
565
572
|
interface DmMessagePart {
|
|
566
573
|
/** The message, when the bot remembers it. */
|
|
567
574
|
message: DmMessage | null;
|
|
568
575
|
}
|
|
569
|
-
/** The fields an event of servers and private messages narrows. */
|
|
570
|
-
type PlaceKeys = 'guildId' | 'guild' | 'channel' | 'message' | 'member';
|
|
571
|
-
/**
|
|
572
|
-
* What a file receives for an event of servers and private messages,
|
|
573
|
-
* following where it listens: the same fields, plus what each place has.
|
|
574
|
-
*/
|
|
575
|
-
type Placed<Where, Common, InServer, InPrivate, InDm> = Where extends 'guild' ? Common & InServer : Where extends 'dm' ? Common & InDm : (Common & InServer) | (Common & InPrivate);
|
|
576
|
-
/** An event about a message, with or without the member who did it. */
|
|
577
|
-
type OnMessage<Name extends EventName, Options, Member> = Placed<WhereOf<Options>, Omit<EventContexts[Name], PlaceKeys>, ServerPlace & ServerMessagePart & Member, PrivatePlace & PrivateMessagePart & ([keyof Member] extends [never] ? object : NoMember), DmPlace & DmMessagePart>;
|
|
578
576
|
/** No member in private: who did it is `user`. */
|
|
579
577
|
interface NoMember {
|
|
580
578
|
/** No member: it happened in private. */
|
|
@@ -590,24 +588,39 @@ interface KnownMember {
|
|
|
590
588
|
/** Who did it, as a member of the server, when the bot remembers it. */
|
|
591
589
|
member: GuildMember | null;
|
|
592
590
|
}
|
|
591
|
+
/** An object about a message (a reaction, a vote), narrowed by where. */
|
|
592
|
+
type AboutMessage<Where, Key extends string, T, Member> = Placed<Where, Key, Unplaced<T> & InServer & ServerMessagePart & Member, Unplaced<T> & InPrivate & PrivateMessagePart & ([keyof Member] extends [never] ? object : NoMember), Unplaced<T> & InDm & DmMessagePart>;
|
|
593
|
+
/** A message of a server: its author is a member unless bots are let in. */
|
|
594
|
+
type ServerMessage<Options> = IsOn<Options, 'bots'> extends true ? GuildMessage : MemberMessage;
|
|
595
|
+
/** A message deleted in a server. */
|
|
596
|
+
interface DeletedInGuild extends Unplaced<DeletedMessage>, InServer {
|
|
597
|
+
/** The message as it was, when the bot remembered it. */
|
|
598
|
+
before: GuildMessage | null;
|
|
599
|
+
}
|
|
600
|
+
/** A private message deleted, for a file that receives both kinds. */
|
|
601
|
+
interface DeletedInPrivate extends Unplaced<DeletedMessage>, InPrivate {
|
|
602
|
+
/** The message as it was, when the bot remembered it. */
|
|
603
|
+
before: PrivateMessage | null;
|
|
604
|
+
}
|
|
605
|
+
/** A private message deleted, for a file that only receives those. */
|
|
606
|
+
interface DeletedInDm extends Unplaced<DeletedMessage>, InDm {
|
|
607
|
+
/** The message as it was, when the bot remembered it. */
|
|
608
|
+
before: DmMessage | null;
|
|
609
|
+
}
|
|
593
610
|
/**
|
|
594
611
|
* The events whose handler receives something more precise than
|
|
595
612
|
* `EventContexts`, following where its file listens.
|
|
596
613
|
*/
|
|
597
614
|
interface NarrowedContexts<Options> {
|
|
598
|
-
messageCreate:
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
reactionClear: OnMessage<'reactionClear', Options, object>;
|
|
608
|
-
pollVoteAdd: OnMessage<'pollVoteAdd', Options, KnownMember>;
|
|
609
|
-
pollVoteRemove: OnMessage<'pollVoteRemove', Options, KnownMember>;
|
|
610
|
-
typingStart: Placed<WhereOf<Options>, Omit<EventContexts['typingStart'], PlaceKeys>, ServerPlace & SentMember, PrivatePlace & NoMember, DmPlace>;
|
|
615
|
+
messageCreate: Placed<WhereOf<Options>, 'message', ServerMessage<Options>, PrivateMessage, DmMessage>;
|
|
616
|
+
messageUpdate: Placed<WhereOf<Options>, 'message', ServerMessage<Options>, PrivateMessage, DmMessage>;
|
|
617
|
+
messageDelete: Placed<WhereOf<Options>, 'message', DeletedInGuild, DeletedInPrivate, DeletedInDm>;
|
|
618
|
+
reactionAdd: AboutMessage<WhereOf<Options>, 'reaction', AddedReaction, SentMember>;
|
|
619
|
+
reactionRemove: AboutMessage<WhereOf<Options>, 'reaction', UserReaction, KnownMember>;
|
|
620
|
+
reactionClear: AboutMessage<WhereOf<Options>, 'reactions', ClearedReactions, object>;
|
|
621
|
+
pollVoteAdd: AboutMessage<WhereOf<Options>, 'vote', PollVote, KnownMember>;
|
|
622
|
+
pollVoteRemove: AboutMessage<WhereOf<Options>, 'vote', PollVote, KnownMember>;
|
|
623
|
+
typingStart: Placed<WhereOf<Options>, 'typing', Unplaced<Typing> & InServer & SentMember, Unplaced<Typing> & InPrivate & NoMember, Unplaced<Typing> & InDm>;
|
|
611
624
|
}
|
|
612
625
|
/**
|
|
613
626
|
* What your function receives for an event, given the options its file passed
|