@sodiumlabs/gamecord 0.1.1
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/LICENSE +21 -0
- package/README.md +58 -0
- package/dist/index.d.mts +2145 -0
- package/dist/index.d.ts +2145 -0
- package/dist/index.js +2614 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2561 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2145 @@
|
|
|
1
|
+
import * as discord_js from 'discord.js';
|
|
2
|
+
import { APIEmbed, User, RepliableInteraction, Message, Awaitable as Awaitable$1, MessageCreateOptions, InteractionEditReplyOptions, MessageEditOptions, ActionRowBuilder, ButtonBuilder, MessageCollector } from 'discord.js';
|
|
3
|
+
import z from 'zod/v4';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import z$1 from 'zod';
|
|
6
|
+
|
|
7
|
+
type Awaitable<T> = T | Promise<T>;
|
|
8
|
+
type GamecordAPIEmbed = APIEmbed & {
|
|
9
|
+
color?: string | number;
|
|
10
|
+
};
|
|
11
|
+
type Embed1<G> = GamecordAPIEmbed | ((game: G) => Awaitable<GamecordAPIEmbed>);
|
|
12
|
+
type Embed2<G, R> = GamecordAPIEmbed | ((game: G, result: R) => Awaitable<GamecordAPIEmbed>);
|
|
13
|
+
type GameMessage<G> = string | ((game: G) => string);
|
|
14
|
+
|
|
15
|
+
type GameContext = RepliableInteraction | Message;
|
|
16
|
+
interface GameResult {
|
|
17
|
+
/**
|
|
18
|
+
* The player who started the game.
|
|
19
|
+
*/
|
|
20
|
+
player: User;
|
|
21
|
+
/**
|
|
22
|
+
* The timestamp at which the game started.
|
|
23
|
+
*/
|
|
24
|
+
gameStartedAt: number;
|
|
25
|
+
/**
|
|
26
|
+
* The duration of the game in milliseconds.
|
|
27
|
+
*/
|
|
28
|
+
gameDuration: number;
|
|
29
|
+
}
|
|
30
|
+
declare interface Game<Res, Ctx extends GameContext = GameContext> {
|
|
31
|
+
/**
|
|
32
|
+
* Emitted when an error occurred.
|
|
33
|
+
*/
|
|
34
|
+
on(event: "error", listener: (err: unknown) => Awaitable$1<void>): this;
|
|
35
|
+
/**
|
|
36
|
+
* Emitted when a fatal error occurred. The "end" event will be emitted at the same time.
|
|
37
|
+
* For example, this let you tell the players that the game stopped.
|
|
38
|
+
*
|
|
39
|
+
* This can only happens in some games, see their docs to know more.
|
|
40
|
+
*/
|
|
41
|
+
on(event: "fatalError", listener: (err: unknown) => Awaitable$1<void>): this;
|
|
42
|
+
/**
|
|
43
|
+
* Only emitted on instances of {@link VersusGame}.
|
|
44
|
+
*
|
|
45
|
+
* Emitted if the versus is rejected, either manually by the opponent or because
|
|
46
|
+
* he took too long to respond. In that case, the `gameOver` event
|
|
47
|
+
* is not emitted.
|
|
48
|
+
*/
|
|
49
|
+
on(event: "versusReject", listener: (reason: "user" | "time") => Awaitable$1<void>): this;
|
|
50
|
+
/**
|
|
51
|
+
* Emitted with the result when the game finishes.
|
|
52
|
+
*/
|
|
53
|
+
on(event: "gameOver", listener: (result: Res) => Awaitable$1<void>): this;
|
|
54
|
+
/**
|
|
55
|
+
* Emitted when the game ends. Not necessarily emitted last (e.g. can be emitted just before `gameOver`).
|
|
56
|
+
*
|
|
57
|
+
* This event is guaranteed to be emitted after {@link Game#start} was successfully called, even after errors (fatal or not).
|
|
58
|
+
*/
|
|
59
|
+
on(event: "end", listener: () => Awaitable$1<void>): this;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The base class of a game.
|
|
63
|
+
*/
|
|
64
|
+
declare abstract class Game<Res extends GameResult, Ctx extends GameContext = GameContext> extends EventEmitter {
|
|
65
|
+
/**
|
|
66
|
+
* The initial context that started this game, either an interaction or a message.
|
|
67
|
+
*/
|
|
68
|
+
readonly context: Ctx;
|
|
69
|
+
/**
|
|
70
|
+
* If the {@link Game#context} is a `Message` or not.
|
|
71
|
+
*/
|
|
72
|
+
readonly isMessage: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The player that started the game.
|
|
75
|
+
*/
|
|
76
|
+
readonly player: User;
|
|
77
|
+
/**
|
|
78
|
+
* The timestamp at which the class was instantiated. Not when {@link Game#start} was called.
|
|
79
|
+
*/
|
|
80
|
+
readonly gameStartedAt: number;
|
|
81
|
+
constructor(context: Ctx);
|
|
82
|
+
/**
|
|
83
|
+
* Returns the current duration of the game.
|
|
84
|
+
*/
|
|
85
|
+
getGameDuration(): number;
|
|
86
|
+
/**
|
|
87
|
+
* Start the game.
|
|
88
|
+
*/
|
|
89
|
+
abstract start(): Promise<void>;
|
|
90
|
+
protected sendMessage(options: MessageCreateOptions | InteractionEditReplyOptions): Promise<Message>;
|
|
91
|
+
/**
|
|
92
|
+
* Edit the context message if it was an interaction,
|
|
93
|
+
* or edit the given message.
|
|
94
|
+
*
|
|
95
|
+
* Since the original context is only valid 15 minutes,
|
|
96
|
+
* we need the message reference if the interaction died.
|
|
97
|
+
*/
|
|
98
|
+
protected editContextOrMessage(message: Message, options: MessageEditOptions): Promise<Message>;
|
|
99
|
+
/**
|
|
100
|
+
* Utility to build an embed from the options.
|
|
101
|
+
*/
|
|
102
|
+
protected buildEmbed(embed: APIEmbed | ((game: this) => Awaitable$1<APIEmbed>), props?: APIEmbed): Promise<APIEmbed>;
|
|
103
|
+
/**
|
|
104
|
+
* Utility to build an end embed from the options.
|
|
105
|
+
*/
|
|
106
|
+
protected buildEndEmbed(embed: APIEmbed | ((game: this) => Awaitable$1<APIEmbed>), endEmbed: APIEmbed | ((game: this, result: Res) => Awaitable$1<APIEmbed>) | undefined, result: Res, props?: APIEmbed): Promise<APIEmbed>;
|
|
107
|
+
/**
|
|
108
|
+
* Utility to build the result of a game.
|
|
109
|
+
*/
|
|
110
|
+
protected result(data: Omit<Res, keyof GameResult>): Res;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The 2048 game result.
|
|
115
|
+
*/
|
|
116
|
+
interface Game2048Result extends GameResult {
|
|
117
|
+
outcome: "over" | "timeout";
|
|
118
|
+
score: number;
|
|
119
|
+
/**
|
|
120
|
+
* If the player reached 2048 or more.
|
|
121
|
+
*/
|
|
122
|
+
hasWon: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface Game2048Options extends z.input<typeof game2048Options> {
|
|
125
|
+
embed?: Embed1<Game2048>;
|
|
126
|
+
endEmbed?: Embed2<Game2048, Game2048Result>;
|
|
127
|
+
/**
|
|
128
|
+
* The max amount of time the player can be idle.
|
|
129
|
+
*/
|
|
130
|
+
timeout?: number;
|
|
131
|
+
}
|
|
132
|
+
declare const game2048Options: z.ZodObject<{
|
|
133
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
134
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
135
|
+
name: z.ZodString;
|
|
136
|
+
url: z.ZodOptional<z.ZodString>;
|
|
137
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
140
|
+
url: z.ZodString;
|
|
141
|
+
}, z.core.$strip>>;
|
|
142
|
+
title: z.ZodOptional<z.ZodString>;
|
|
143
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
144
|
+
description: z.ZodOptional<z.ZodString>;
|
|
145
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
146
|
+
url: z.ZodString;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
text: z.ZodString;
|
|
150
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
151
|
+
}, z.core.$strip>>;
|
|
152
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Game2048) => Awaitable<{
|
|
153
|
+
author?: {
|
|
154
|
+
name: string;
|
|
155
|
+
url?: string | undefined;
|
|
156
|
+
icon_url?: string | undefined;
|
|
157
|
+
} | undefined;
|
|
158
|
+
thumbnail?: {
|
|
159
|
+
url: string;
|
|
160
|
+
} | undefined;
|
|
161
|
+
title?: string | undefined;
|
|
162
|
+
color?: number | undefined;
|
|
163
|
+
description?: string | undefined;
|
|
164
|
+
image?: {
|
|
165
|
+
url: string;
|
|
166
|
+
} | undefined;
|
|
167
|
+
footer?: {
|
|
168
|
+
text: string;
|
|
169
|
+
icon_url?: string | undefined;
|
|
170
|
+
} | undefined;
|
|
171
|
+
}>, (args_0: Game2048) => Awaitable<{
|
|
172
|
+
author?: {
|
|
173
|
+
name: string;
|
|
174
|
+
url?: string | undefined;
|
|
175
|
+
icon_url?: string | undefined;
|
|
176
|
+
} | undefined;
|
|
177
|
+
thumbnail?: {
|
|
178
|
+
url: string;
|
|
179
|
+
} | undefined;
|
|
180
|
+
title?: string | undefined;
|
|
181
|
+
color?: number | undefined;
|
|
182
|
+
description?: string | undefined;
|
|
183
|
+
image?: {
|
|
184
|
+
url: string;
|
|
185
|
+
} | undefined;
|
|
186
|
+
footer?: {
|
|
187
|
+
text: string;
|
|
188
|
+
icon_url?: string | undefined;
|
|
189
|
+
} | undefined;
|
|
190
|
+
}>>]>>>;
|
|
191
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
192
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
193
|
+
name: z.ZodString;
|
|
194
|
+
url: z.ZodOptional<z.ZodString>;
|
|
195
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
196
|
+
}, z.core.$strip>>;
|
|
197
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
198
|
+
url: z.ZodString;
|
|
199
|
+
}, z.core.$strip>>;
|
|
200
|
+
title: z.ZodOptional<z.ZodString>;
|
|
201
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
202
|
+
description: z.ZodOptional<z.ZodString>;
|
|
203
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
204
|
+
url: z.ZodString;
|
|
205
|
+
}, z.core.$strip>>;
|
|
206
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
207
|
+
text: z.ZodString;
|
|
208
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
209
|
+
}, z.core.$strip>>;
|
|
210
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Game2048, args_1: Game2048Result) => Awaitable<{
|
|
211
|
+
author?: {
|
|
212
|
+
name: string;
|
|
213
|
+
url?: string | undefined;
|
|
214
|
+
icon_url?: string | undefined;
|
|
215
|
+
} | undefined;
|
|
216
|
+
thumbnail?: {
|
|
217
|
+
url: string;
|
|
218
|
+
} | undefined;
|
|
219
|
+
title?: string | undefined;
|
|
220
|
+
color?: number | undefined;
|
|
221
|
+
description?: string | undefined;
|
|
222
|
+
image?: {
|
|
223
|
+
url: string;
|
|
224
|
+
} | undefined;
|
|
225
|
+
footer?: {
|
|
226
|
+
text: string;
|
|
227
|
+
icon_url?: string | undefined;
|
|
228
|
+
} | undefined;
|
|
229
|
+
}>, (args_0: Game2048, args_1: Game2048Result) => Awaitable<{
|
|
230
|
+
author?: {
|
|
231
|
+
name: string;
|
|
232
|
+
url?: string | undefined;
|
|
233
|
+
icon_url?: string | undefined;
|
|
234
|
+
} | undefined;
|
|
235
|
+
thumbnail?: {
|
|
236
|
+
url: string;
|
|
237
|
+
} | undefined;
|
|
238
|
+
title?: string | undefined;
|
|
239
|
+
color?: number | undefined;
|
|
240
|
+
description?: string | undefined;
|
|
241
|
+
image?: {
|
|
242
|
+
url: string;
|
|
243
|
+
} | undefined;
|
|
244
|
+
footer?: {
|
|
245
|
+
text: string;
|
|
246
|
+
icon_url?: string | undefined;
|
|
247
|
+
} | undefined;
|
|
248
|
+
}>>]>>;
|
|
249
|
+
notPlayerMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(game: Game2048) => string, (game: Game2048) => string>]>>>;
|
|
250
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
251
|
+
buttonStyle: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
252
|
+
emojis: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
253
|
+
up: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
254
|
+
down: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
255
|
+
right: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
256
|
+
left: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
257
|
+
}, z.core.$strip>>>;
|
|
258
|
+
}, z.core.$strip>;
|
|
259
|
+
/**
|
|
260
|
+
* A game where the player needs to merge numbers until reaching 2048.
|
|
261
|
+
*
|
|
262
|
+
* # Custom Display
|
|
263
|
+
*
|
|
264
|
+
* If you are using functions to create the embeds, use `attachment://board.png`
|
|
265
|
+
* in the embed image URL to display the board.
|
|
266
|
+
*
|
|
267
|
+
* # Example
|
|
268
|
+
*
|
|
269
|
+
* ```js
|
|
270
|
+
* const game = new Game2048(interaction, {
|
|
271
|
+
* timeout: 120_000
|
|
272
|
+
* });
|
|
273
|
+
*
|
|
274
|
+
* game.on("error", err => console.error(err));
|
|
275
|
+
* game.on("gameOver", result => console.log(result));
|
|
276
|
+
*
|
|
277
|
+
* await game.start();
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
declare class Game2048 extends Game<Game2048Result> {
|
|
281
|
+
readonly options: z.output<typeof game2048Options>;
|
|
282
|
+
/**
|
|
283
|
+
* The numbers are stored as exponents (1 => 2, 2 => 4, etc.).
|
|
284
|
+
*/
|
|
285
|
+
readonly gameboard: number[];
|
|
286
|
+
readonly length = 4;
|
|
287
|
+
score: number;
|
|
288
|
+
message: Message | null;
|
|
289
|
+
private mergedPos;
|
|
290
|
+
constructor(context: GameContext, options?: Game2048Options);
|
|
291
|
+
start(): Promise<void>;
|
|
292
|
+
private handleButtons;
|
|
293
|
+
private gameOver;
|
|
294
|
+
private isGameOver;
|
|
295
|
+
private placeRandomTile;
|
|
296
|
+
/**
|
|
297
|
+
* @returns Has moved
|
|
298
|
+
*/
|
|
299
|
+
private shiftVertical;
|
|
300
|
+
/**
|
|
301
|
+
* @returns Has moved
|
|
302
|
+
*/
|
|
303
|
+
private shiftHorizontal;
|
|
304
|
+
private isInsideBlock;
|
|
305
|
+
/**
|
|
306
|
+
* @returns Has moved
|
|
307
|
+
*/
|
|
308
|
+
private shift;
|
|
309
|
+
private getComponents;
|
|
310
|
+
private getBoardAttachment;
|
|
311
|
+
private getBoardImage;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
interface VersusPlayers {
|
|
315
|
+
player: User;
|
|
316
|
+
opponent: User;
|
|
317
|
+
}
|
|
318
|
+
interface VersusOptions extends z$1.input<ReturnType<typeof versusOptions>> {
|
|
319
|
+
/**
|
|
320
|
+
* The opponent.
|
|
321
|
+
*/
|
|
322
|
+
opponent: User;
|
|
323
|
+
/**
|
|
324
|
+
* The amount of time the opponent has to accept or deny the versus request.
|
|
325
|
+
*/
|
|
326
|
+
timeout?: number;
|
|
327
|
+
}
|
|
328
|
+
type VersusOptionsOutput = z$1.output<ReturnType<typeof versusOptions>>;
|
|
329
|
+
declare const versusOptions: (name: string) => z$1.ZodObject<{
|
|
330
|
+
opponent: z$1.ZodCustom<User, User>;
|
|
331
|
+
timeout: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
|
|
332
|
+
requestEmbed: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodCustom<(ctx: VersusPlayers) => APIEmbed, (ctx: VersusPlayers) => APIEmbed>>>;
|
|
333
|
+
rejectEmbed: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodCustom<(ctx: VersusPlayers) => APIEmbed, (ctx: VersusPlayers) => APIEmbed>>>;
|
|
334
|
+
timeoutEmbed: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodCustom<(ctx: VersusPlayers) => APIEmbed, (ctx: VersusPlayers) => APIEmbed>>>;
|
|
335
|
+
buttons: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
|
|
336
|
+
accept: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
|
|
337
|
+
reject: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
|
|
338
|
+
}, z$1.core.$strip>>>;
|
|
339
|
+
}, z$1.core.$strip>;
|
|
340
|
+
interface VersusGameResult extends GameResult {
|
|
341
|
+
opponent: User;
|
|
342
|
+
}
|
|
343
|
+
declare abstract class VersusGame<Res extends VersusGameResult, Ctx extends GameContext = GameContext> extends Game<Res, Ctx> {
|
|
344
|
+
readonly versusOptions: VersusOptionsOutput;
|
|
345
|
+
/**
|
|
346
|
+
* The opponent user.
|
|
347
|
+
*/
|
|
348
|
+
readonly opponent: User;
|
|
349
|
+
constructor(context: Ctx, options: VersusOptionsOutput);
|
|
350
|
+
protected requestVersus(): Promise<Message | null>;
|
|
351
|
+
/**
|
|
352
|
+
* Utility to build an embed from the options.
|
|
353
|
+
*/
|
|
354
|
+
protected buildEmbed(embed: APIEmbed | ((game: this) => Awaitable$1<APIEmbed>), props?: APIEmbed): Promise<APIEmbed>;
|
|
355
|
+
/**
|
|
356
|
+
* Utility to build an end embed from the options.
|
|
357
|
+
*/
|
|
358
|
+
protected buildEndEmbed(embed: APIEmbed | ((game: this) => Awaitable$1<APIEmbed>), endEmbed: APIEmbed | ((game: this, result: Res) => Awaitable$1<APIEmbed>) | undefined, result: Res, props?: APIEmbed): Promise<APIEmbed>;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The Connect 4 game result.
|
|
363
|
+
*/
|
|
364
|
+
interface Connect4Result extends VersusGameResult {
|
|
365
|
+
outcome: "win" | "tie" | "timeout";
|
|
366
|
+
/**
|
|
367
|
+
* Only if `outcome` is `win`.
|
|
368
|
+
*/
|
|
369
|
+
winner: User | null;
|
|
370
|
+
winnerEmoji: string | null;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The data of a Connect 4 turn.
|
|
374
|
+
*/
|
|
375
|
+
interface Connect4Turn {
|
|
376
|
+
player: User;
|
|
377
|
+
emoji: string;
|
|
378
|
+
}
|
|
379
|
+
interface Connect4Options extends z.input<typeof connect4Options> {
|
|
380
|
+
versus: VersusOptions;
|
|
381
|
+
embed?: Embed1<Connect4>;
|
|
382
|
+
endEmbed?: Embed2<Connect4, Connect4Result>;
|
|
383
|
+
/**
|
|
384
|
+
* The max amount of time the player can be idle.
|
|
385
|
+
*/
|
|
386
|
+
timeout?: number;
|
|
387
|
+
}
|
|
388
|
+
declare const connect4Options: z.ZodObject<{
|
|
389
|
+
versus: z.ZodObject<{
|
|
390
|
+
opponent: z.ZodCustom<User, User>;
|
|
391
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
392
|
+
requestEmbed: z.ZodDefault<z.ZodOptional<z.ZodCustom<(ctx: VersusPlayers) => discord_js.APIEmbed, (ctx: VersusPlayers) => discord_js.APIEmbed>>>;
|
|
393
|
+
rejectEmbed: z.ZodDefault<z.ZodOptional<z.ZodCustom<(ctx: VersusPlayers) => discord_js.APIEmbed, (ctx: VersusPlayers) => discord_js.APIEmbed>>>;
|
|
394
|
+
timeoutEmbed: z.ZodDefault<z.ZodOptional<z.ZodCustom<(ctx: VersusPlayers) => discord_js.APIEmbed, (ctx: VersusPlayers) => discord_js.APIEmbed>>>;
|
|
395
|
+
buttons: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
396
|
+
accept: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
397
|
+
reject: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
398
|
+
}, z.core.$strip>>>;
|
|
399
|
+
}, z.core.$strip>;
|
|
400
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
401
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
402
|
+
name: z.ZodString;
|
|
403
|
+
url: z.ZodOptional<z.ZodString>;
|
|
404
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
405
|
+
}, z.core.$strip>>;
|
|
406
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
407
|
+
url: z.ZodString;
|
|
408
|
+
}, z.core.$strip>>;
|
|
409
|
+
title: z.ZodOptional<z.ZodString>;
|
|
410
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
411
|
+
description: z.ZodOptional<z.ZodString>;
|
|
412
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
413
|
+
url: z.ZodString;
|
|
414
|
+
}, z.core.$strip>>;
|
|
415
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
416
|
+
text: z.ZodString;
|
|
417
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
418
|
+
}, z.core.$strip>>;
|
|
419
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Connect4) => Awaitable<{
|
|
420
|
+
author?: {
|
|
421
|
+
name: string;
|
|
422
|
+
url?: string | undefined;
|
|
423
|
+
icon_url?: string | undefined;
|
|
424
|
+
} | undefined;
|
|
425
|
+
thumbnail?: {
|
|
426
|
+
url: string;
|
|
427
|
+
} | undefined;
|
|
428
|
+
title?: string | undefined;
|
|
429
|
+
color?: number | undefined;
|
|
430
|
+
description?: string | undefined;
|
|
431
|
+
image?: {
|
|
432
|
+
url: string;
|
|
433
|
+
} | undefined;
|
|
434
|
+
footer?: {
|
|
435
|
+
text: string;
|
|
436
|
+
icon_url?: string | undefined;
|
|
437
|
+
} | undefined;
|
|
438
|
+
}>, (args_0: Connect4) => Awaitable<{
|
|
439
|
+
author?: {
|
|
440
|
+
name: string;
|
|
441
|
+
url?: string | undefined;
|
|
442
|
+
icon_url?: string | undefined;
|
|
443
|
+
} | undefined;
|
|
444
|
+
thumbnail?: {
|
|
445
|
+
url: string;
|
|
446
|
+
} | undefined;
|
|
447
|
+
title?: string | undefined;
|
|
448
|
+
color?: number | undefined;
|
|
449
|
+
description?: string | undefined;
|
|
450
|
+
image?: {
|
|
451
|
+
url: string;
|
|
452
|
+
} | undefined;
|
|
453
|
+
footer?: {
|
|
454
|
+
text: string;
|
|
455
|
+
icon_url?: string | undefined;
|
|
456
|
+
} | undefined;
|
|
457
|
+
}>>]>>>;
|
|
458
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
459
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
460
|
+
name: z.ZodString;
|
|
461
|
+
url: z.ZodOptional<z.ZodString>;
|
|
462
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
463
|
+
}, z.core.$strip>>;
|
|
464
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
465
|
+
url: z.ZodString;
|
|
466
|
+
}, z.core.$strip>>;
|
|
467
|
+
title: z.ZodOptional<z.ZodString>;
|
|
468
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
469
|
+
description: z.ZodOptional<z.ZodString>;
|
|
470
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
471
|
+
url: z.ZodString;
|
|
472
|
+
}, z.core.$strip>>;
|
|
473
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
474
|
+
text: z.ZodString;
|
|
475
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
476
|
+
}, z.core.$strip>>;
|
|
477
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Connect4, args_1: Connect4Result) => Awaitable<{
|
|
478
|
+
author?: {
|
|
479
|
+
name: string;
|
|
480
|
+
url?: string | undefined;
|
|
481
|
+
icon_url?: string | undefined;
|
|
482
|
+
} | undefined;
|
|
483
|
+
thumbnail?: {
|
|
484
|
+
url: string;
|
|
485
|
+
} | undefined;
|
|
486
|
+
title?: string | undefined;
|
|
487
|
+
color?: number | undefined;
|
|
488
|
+
description?: string | undefined;
|
|
489
|
+
image?: {
|
|
490
|
+
url: string;
|
|
491
|
+
} | undefined;
|
|
492
|
+
footer?: {
|
|
493
|
+
text: string;
|
|
494
|
+
icon_url?: string | undefined;
|
|
495
|
+
} | undefined;
|
|
496
|
+
}>, (args_0: Connect4, args_1: Connect4Result) => Awaitable<{
|
|
497
|
+
author?: {
|
|
498
|
+
name: string;
|
|
499
|
+
url?: string | undefined;
|
|
500
|
+
icon_url?: string | undefined;
|
|
501
|
+
} | undefined;
|
|
502
|
+
thumbnail?: {
|
|
503
|
+
url: string;
|
|
504
|
+
} | undefined;
|
|
505
|
+
title?: string | undefined;
|
|
506
|
+
color?: number | undefined;
|
|
507
|
+
description?: string | undefined;
|
|
508
|
+
image?: {
|
|
509
|
+
url: string;
|
|
510
|
+
} | undefined;
|
|
511
|
+
footer?: {
|
|
512
|
+
text: string;
|
|
513
|
+
icon_url?: string | undefined;
|
|
514
|
+
} | undefined;
|
|
515
|
+
}>>]>>;
|
|
516
|
+
winMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: Connect4Result, game: Connect4) => string, (result: Connect4Result, game: Connect4) => string>]>>>;
|
|
517
|
+
tieMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: Connect4Result, game: Connect4) => string, (result: Connect4Result, game: Connect4) => string>]>>>;
|
|
518
|
+
timeoutMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: Connect4Result, game: Connect4) => string, (result: Connect4Result, game: Connect4) => string>]>>>;
|
|
519
|
+
turnMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(data: Connect4Turn, game: Connect4) => string, (data: Connect4Turn, game: Connect4) => string>]>>>;
|
|
520
|
+
notPlayerMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(game: Connect4) => string, (game: Connect4) => string>]>>>;
|
|
521
|
+
statusText: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
522
|
+
emojis: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
523
|
+
board: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
524
|
+
player1: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
525
|
+
player2: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
526
|
+
}, z.core.$strip>>>;
|
|
527
|
+
buttonStyle: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
528
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
529
|
+
}, z.core.$strip>;
|
|
530
|
+
/**
|
|
531
|
+
* The Connect 4 game.
|
|
532
|
+
*
|
|
533
|
+
* # Errors
|
|
534
|
+
*
|
|
535
|
+
* Can emit `fatalError` if it fails to edit from the invitation embed to the game message.
|
|
536
|
+
*
|
|
537
|
+
* # Example
|
|
538
|
+
*
|
|
539
|
+
* ```js
|
|
540
|
+
* const opponent = // The opponent (must be a discord.js User)
|
|
541
|
+
*
|
|
542
|
+
* const game = new Connect4(interaction, {
|
|
543
|
+
* versus: {
|
|
544
|
+
* opponent
|
|
545
|
+
* }
|
|
546
|
+
* });
|
|
547
|
+
*
|
|
548
|
+
* game.on("error", err => console.error(err));
|
|
549
|
+
* game.on("versusReject", () => console.log("Opponent rejected the invitation to play"));
|
|
550
|
+
* game.on("gameOver", result => console.log(result));
|
|
551
|
+
*
|
|
552
|
+
* await game.start();
|
|
553
|
+
* ```
|
|
554
|
+
*/
|
|
555
|
+
declare class Connect4 extends VersusGame<Connect4Result> {
|
|
556
|
+
readonly options: z.output<typeof connect4Options>;
|
|
557
|
+
/**
|
|
558
|
+
* A 6*7 elements array.
|
|
559
|
+
*
|
|
560
|
+
* - `0` : empty
|
|
561
|
+
* - `1` : player 1
|
|
562
|
+
* - `2` : player 2
|
|
563
|
+
*/
|
|
564
|
+
readonly gameboard: number[];
|
|
565
|
+
isPlayer1Turn: boolean;
|
|
566
|
+
message: Message | null;
|
|
567
|
+
private locked;
|
|
568
|
+
constructor(context: GameContext, options?: Connect4Options);
|
|
569
|
+
start(): Promise<void>;
|
|
570
|
+
private runGame;
|
|
571
|
+
private handleButtons;
|
|
572
|
+
private gameOver;
|
|
573
|
+
private getPlayerTurnData;
|
|
574
|
+
getBoardContent(): string;
|
|
575
|
+
/**
|
|
576
|
+
* Get the current player number (`1` or `2`).
|
|
577
|
+
*/
|
|
578
|
+
getPlayerNumber(): 1 | 2;
|
|
579
|
+
isBoardFull(): boolean;
|
|
580
|
+
/**
|
|
581
|
+
* Get the emoji of a number of the game board (`0`, `1` or `2`).
|
|
582
|
+
*/
|
|
583
|
+
getEmoji(number: number): string;
|
|
584
|
+
isWinAt(x: number, y: number): boolean;
|
|
585
|
+
isColumnFilled(x: number): boolean;
|
|
586
|
+
getComponents(disabled?: boolean): ActionRowBuilder<ButtonBuilder>[];
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* The fast type game result.
|
|
591
|
+
*/
|
|
592
|
+
interface FastTypeResult extends GameResult {
|
|
593
|
+
outcome: "win" | "lose" | "timeout";
|
|
594
|
+
timeTaken: number;
|
|
595
|
+
secondsTaken: number;
|
|
596
|
+
/**
|
|
597
|
+
* Words per minute. Will be `0` if the player has lost.
|
|
598
|
+
*/
|
|
599
|
+
wpm: number;
|
|
600
|
+
}
|
|
601
|
+
interface FastTypeOptions extends z.input<typeof fastTypeOptions> {
|
|
602
|
+
embed?: Embed1<FastType>;
|
|
603
|
+
endEmbed?: Embed2<FastType, FastTypeResult>;
|
|
604
|
+
/**
|
|
605
|
+
* The sentence the player has to type.
|
|
606
|
+
*/
|
|
607
|
+
sentence?: string;
|
|
608
|
+
/**
|
|
609
|
+
* The max amount of time the player can be idle.
|
|
610
|
+
*/
|
|
611
|
+
timeout?: number;
|
|
612
|
+
}
|
|
613
|
+
declare const fastTypeOptions: z.ZodObject<{
|
|
614
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
615
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
616
|
+
name: z.ZodString;
|
|
617
|
+
url: z.ZodOptional<z.ZodString>;
|
|
618
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
619
|
+
}, z.core.$strip>>;
|
|
620
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
621
|
+
url: z.ZodString;
|
|
622
|
+
}, z.core.$strip>>;
|
|
623
|
+
title: z.ZodOptional<z.ZodString>;
|
|
624
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
625
|
+
description: z.ZodOptional<z.ZodString>;
|
|
626
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
627
|
+
url: z.ZodString;
|
|
628
|
+
}, z.core.$strip>>;
|
|
629
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
630
|
+
text: z.ZodString;
|
|
631
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
632
|
+
}, z.core.$strip>>;
|
|
633
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: FastType) => Awaitable<{
|
|
634
|
+
author?: {
|
|
635
|
+
name: string;
|
|
636
|
+
url?: string | undefined;
|
|
637
|
+
icon_url?: string | undefined;
|
|
638
|
+
} | undefined;
|
|
639
|
+
thumbnail?: {
|
|
640
|
+
url: string;
|
|
641
|
+
} | undefined;
|
|
642
|
+
title?: string | undefined;
|
|
643
|
+
color?: number | undefined;
|
|
644
|
+
description?: string | undefined;
|
|
645
|
+
image?: {
|
|
646
|
+
url: string;
|
|
647
|
+
} | undefined;
|
|
648
|
+
footer?: {
|
|
649
|
+
text: string;
|
|
650
|
+
icon_url?: string | undefined;
|
|
651
|
+
} | undefined;
|
|
652
|
+
}>, (args_0: FastType) => Awaitable<{
|
|
653
|
+
author?: {
|
|
654
|
+
name: string;
|
|
655
|
+
url?: string | undefined;
|
|
656
|
+
icon_url?: string | undefined;
|
|
657
|
+
} | undefined;
|
|
658
|
+
thumbnail?: {
|
|
659
|
+
url: string;
|
|
660
|
+
} | undefined;
|
|
661
|
+
title?: string | undefined;
|
|
662
|
+
color?: number | undefined;
|
|
663
|
+
description?: string | undefined;
|
|
664
|
+
image?: {
|
|
665
|
+
url: string;
|
|
666
|
+
} | undefined;
|
|
667
|
+
footer?: {
|
|
668
|
+
text: string;
|
|
669
|
+
icon_url?: string | undefined;
|
|
670
|
+
} | undefined;
|
|
671
|
+
}>>]>>>;
|
|
672
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
673
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
674
|
+
name: z.ZodString;
|
|
675
|
+
url: z.ZodOptional<z.ZodString>;
|
|
676
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
677
|
+
}, z.core.$strip>>;
|
|
678
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
679
|
+
url: z.ZodString;
|
|
680
|
+
}, z.core.$strip>>;
|
|
681
|
+
title: z.ZodOptional<z.ZodString>;
|
|
682
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
683
|
+
description: z.ZodOptional<z.ZodString>;
|
|
684
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
685
|
+
url: z.ZodString;
|
|
686
|
+
}, z.core.$strip>>;
|
|
687
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
688
|
+
text: z.ZodString;
|
|
689
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
690
|
+
}, z.core.$strip>>;
|
|
691
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: FastType, args_1: FastTypeResult) => Awaitable<{
|
|
692
|
+
author?: {
|
|
693
|
+
name: string;
|
|
694
|
+
url?: string | undefined;
|
|
695
|
+
icon_url?: string | undefined;
|
|
696
|
+
} | undefined;
|
|
697
|
+
thumbnail?: {
|
|
698
|
+
url: string;
|
|
699
|
+
} | undefined;
|
|
700
|
+
title?: string | undefined;
|
|
701
|
+
color?: number | undefined;
|
|
702
|
+
description?: string | undefined;
|
|
703
|
+
image?: {
|
|
704
|
+
url: string;
|
|
705
|
+
} | undefined;
|
|
706
|
+
footer?: {
|
|
707
|
+
text: string;
|
|
708
|
+
icon_url?: string | undefined;
|
|
709
|
+
} | undefined;
|
|
710
|
+
}>, (args_0: FastType, args_1: FastTypeResult) => Awaitable<{
|
|
711
|
+
author?: {
|
|
712
|
+
name: string;
|
|
713
|
+
url?: string | undefined;
|
|
714
|
+
icon_url?: string | undefined;
|
|
715
|
+
} | undefined;
|
|
716
|
+
thumbnail?: {
|
|
717
|
+
url: string;
|
|
718
|
+
} | undefined;
|
|
719
|
+
title?: string | undefined;
|
|
720
|
+
color?: number | undefined;
|
|
721
|
+
description?: string | undefined;
|
|
722
|
+
image?: {
|
|
723
|
+
url: string;
|
|
724
|
+
} | undefined;
|
|
725
|
+
footer?: {
|
|
726
|
+
text: string;
|
|
727
|
+
icon_url?: string | undefined;
|
|
728
|
+
} | undefined;
|
|
729
|
+
}>>]>>;
|
|
730
|
+
winMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: FastTypeResult, game: FastType) => string, (result: FastTypeResult, game: FastType) => string>]>>>;
|
|
731
|
+
loseMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: FastTypeResult, game: FastType) => string, (result: FastTypeResult, game: FastType) => string>]>>>;
|
|
732
|
+
sentence: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
733
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
734
|
+
}, z.core.$strip>;
|
|
735
|
+
/**
|
|
736
|
+
* A game where the player needs to write a sentence as fast as possible.
|
|
737
|
+
*
|
|
738
|
+
* # Permissions
|
|
739
|
+
*
|
|
740
|
+
* The bot needs to be able to read the messages of the current channel.
|
|
741
|
+
*
|
|
742
|
+
* # Example
|
|
743
|
+
* ```js
|
|
744
|
+
* const game = new FastType(interaction, {
|
|
745
|
+
* // See the full list of options in the docs
|
|
746
|
+
* sentence: "Some really cool sentence to fast type.",
|
|
747
|
+
* winMessage: res => `You won! You finished the type race in ${res.secondsTaken} seconds with word per minute of ${res.wpm}.`
|
|
748
|
+
* timeout: 20_000
|
|
749
|
+
* });
|
|
750
|
+
*
|
|
751
|
+
* game.on("error", err => console.error(err));
|
|
752
|
+
* game.on("gameOver", result => console.log(result));
|
|
753
|
+
*
|
|
754
|
+
* await game.start();
|
|
755
|
+
* ```
|
|
756
|
+
*/
|
|
757
|
+
declare class FastType extends Game<FastTypeResult> {
|
|
758
|
+
readonly options: z.output<typeof fastTypeOptions>;
|
|
759
|
+
timeTaken: number;
|
|
760
|
+
wpm: number;
|
|
761
|
+
constructor(context: GameContext, options: FastTypeOptions);
|
|
762
|
+
start(): Promise<void>;
|
|
763
|
+
private gameOver;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* The flood game result.
|
|
768
|
+
*/
|
|
769
|
+
interface FloodResult extends GameResult {
|
|
770
|
+
outcome: "win" | "lose" | "timeout";
|
|
771
|
+
turns: number;
|
|
772
|
+
maxTurns: number;
|
|
773
|
+
/**
|
|
774
|
+
* The index (in `options.emojis`) of the last emoji that was chosen by the player.
|
|
775
|
+
*/
|
|
776
|
+
boardEmojiIndex: number;
|
|
777
|
+
}
|
|
778
|
+
interface FloodOptions extends z.input<typeof floodOptions> {
|
|
779
|
+
embed?: Embed1<Flood>;
|
|
780
|
+
endEmbed?: Embed2<Flood, FloodResult>;
|
|
781
|
+
/**
|
|
782
|
+
* The size (width) of the game board.
|
|
783
|
+
*/
|
|
784
|
+
size?: number;
|
|
785
|
+
/**
|
|
786
|
+
* The max amount of time the player can be idle.
|
|
787
|
+
*/
|
|
788
|
+
timeout?: number;
|
|
789
|
+
}
|
|
790
|
+
declare const floodOptions: z.ZodObject<{
|
|
791
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
792
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
793
|
+
name: z.ZodString;
|
|
794
|
+
url: z.ZodOptional<z.ZodString>;
|
|
795
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
796
|
+
}, z.core.$strip>>;
|
|
797
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
798
|
+
url: z.ZodString;
|
|
799
|
+
}, z.core.$strip>>;
|
|
800
|
+
title: z.ZodOptional<z.ZodString>;
|
|
801
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
802
|
+
description: z.ZodOptional<z.ZodString>;
|
|
803
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
804
|
+
url: z.ZodString;
|
|
805
|
+
}, z.core.$strip>>;
|
|
806
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
807
|
+
text: z.ZodString;
|
|
808
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
809
|
+
}, z.core.$strip>>;
|
|
810
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Flood) => Awaitable<{
|
|
811
|
+
author?: {
|
|
812
|
+
name: string;
|
|
813
|
+
url?: string | undefined;
|
|
814
|
+
icon_url?: string | undefined;
|
|
815
|
+
} | undefined;
|
|
816
|
+
thumbnail?: {
|
|
817
|
+
url: string;
|
|
818
|
+
} | undefined;
|
|
819
|
+
title?: string | undefined;
|
|
820
|
+
color?: number | undefined;
|
|
821
|
+
description?: string | undefined;
|
|
822
|
+
image?: {
|
|
823
|
+
url: string;
|
|
824
|
+
} | undefined;
|
|
825
|
+
footer?: {
|
|
826
|
+
text: string;
|
|
827
|
+
icon_url?: string | undefined;
|
|
828
|
+
} | undefined;
|
|
829
|
+
}>, (args_0: Flood) => Awaitable<{
|
|
830
|
+
author?: {
|
|
831
|
+
name: string;
|
|
832
|
+
url?: string | undefined;
|
|
833
|
+
icon_url?: string | undefined;
|
|
834
|
+
} | undefined;
|
|
835
|
+
thumbnail?: {
|
|
836
|
+
url: string;
|
|
837
|
+
} | undefined;
|
|
838
|
+
title?: string | undefined;
|
|
839
|
+
color?: number | undefined;
|
|
840
|
+
description?: string | undefined;
|
|
841
|
+
image?: {
|
|
842
|
+
url: string;
|
|
843
|
+
} | undefined;
|
|
844
|
+
footer?: {
|
|
845
|
+
text: string;
|
|
846
|
+
icon_url?: string | undefined;
|
|
847
|
+
} | undefined;
|
|
848
|
+
}>>]>>>;
|
|
849
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
850
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
851
|
+
name: z.ZodString;
|
|
852
|
+
url: z.ZodOptional<z.ZodString>;
|
|
853
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
854
|
+
}, z.core.$strip>>;
|
|
855
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
856
|
+
url: z.ZodString;
|
|
857
|
+
}, z.core.$strip>>;
|
|
858
|
+
title: z.ZodOptional<z.ZodString>;
|
|
859
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
860
|
+
description: z.ZodOptional<z.ZodString>;
|
|
861
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
862
|
+
url: z.ZodString;
|
|
863
|
+
}, z.core.$strip>>;
|
|
864
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
865
|
+
text: z.ZodString;
|
|
866
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
867
|
+
}, z.core.$strip>>;
|
|
868
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Flood, args_1: FloodResult) => Awaitable<{
|
|
869
|
+
author?: {
|
|
870
|
+
name: string;
|
|
871
|
+
url?: string | undefined;
|
|
872
|
+
icon_url?: string | undefined;
|
|
873
|
+
} | undefined;
|
|
874
|
+
thumbnail?: {
|
|
875
|
+
url: string;
|
|
876
|
+
} | undefined;
|
|
877
|
+
title?: string | undefined;
|
|
878
|
+
color?: number | undefined;
|
|
879
|
+
description?: string | undefined;
|
|
880
|
+
image?: {
|
|
881
|
+
url: string;
|
|
882
|
+
} | undefined;
|
|
883
|
+
footer?: {
|
|
884
|
+
text: string;
|
|
885
|
+
icon_url?: string | undefined;
|
|
886
|
+
} | undefined;
|
|
887
|
+
}>, (args_0: Flood, args_1: FloodResult) => Awaitable<{
|
|
888
|
+
author?: {
|
|
889
|
+
name: string;
|
|
890
|
+
url?: string | undefined;
|
|
891
|
+
icon_url?: string | undefined;
|
|
892
|
+
} | undefined;
|
|
893
|
+
thumbnail?: {
|
|
894
|
+
url: string;
|
|
895
|
+
} | undefined;
|
|
896
|
+
title?: string | undefined;
|
|
897
|
+
color?: number | undefined;
|
|
898
|
+
description?: string | undefined;
|
|
899
|
+
image?: {
|
|
900
|
+
url: string;
|
|
901
|
+
} | undefined;
|
|
902
|
+
footer?: {
|
|
903
|
+
text: string;
|
|
904
|
+
icon_url?: string | undefined;
|
|
905
|
+
} | undefined;
|
|
906
|
+
}>>]>>;
|
|
907
|
+
winMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: FloodResult, game: Flood) => string, (result: FloodResult, game: Flood) => string>]>>>;
|
|
908
|
+
loseMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: FloodResult, game: Flood) => string, (result: FloodResult, game: Flood) => string>]>>>;
|
|
909
|
+
notPlayerMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(game: Flood) => string, (game: Flood) => string>]>>>;
|
|
910
|
+
size: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
911
|
+
maxTurns: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
912
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
913
|
+
buttonStyle: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
914
|
+
emojis: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
915
|
+
}, z.core.$strip>;
|
|
916
|
+
/**
|
|
917
|
+
* A game where the player needs to make the whole board a single emoji.
|
|
918
|
+
*
|
|
919
|
+
* # Custom display
|
|
920
|
+
*
|
|
921
|
+
* If you are using functions to create the embeds, use {@link Flood#getBoardContent} to get the game board.
|
|
922
|
+
*
|
|
923
|
+
* # Example
|
|
924
|
+
*
|
|
925
|
+
* ```js
|
|
926
|
+
* const game = new Flood(interaction, {
|
|
927
|
+
* winMessage: "You won the Game! You successfully avoided all the mines."
|
|
928
|
+
* timeout: 120_000
|
|
929
|
+
* });
|
|
930
|
+
*
|
|
931
|
+
* game.on("error", err => console.error(err));
|
|
932
|
+
* game.on("gameOver", result => console.log(result));
|
|
933
|
+
*
|
|
934
|
+
* await game.start();
|
|
935
|
+
* ```
|
|
936
|
+
*/
|
|
937
|
+
declare class Flood extends Game<FloodResult> {
|
|
938
|
+
readonly options: z.output<typeof floodOptions>;
|
|
939
|
+
readonly board: number[];
|
|
940
|
+
turns: number;
|
|
941
|
+
message: Message | null;
|
|
942
|
+
constructor(context: GameContext, options: FloodOptions);
|
|
943
|
+
start(): Promise<void>;
|
|
944
|
+
private handleButtons;
|
|
945
|
+
getBoardContent(): string;
|
|
946
|
+
getActionRow(disabled?: boolean): ActionRowBuilder<ButtonBuilder>;
|
|
947
|
+
private getEmbed;
|
|
948
|
+
private gameOver;
|
|
949
|
+
private updateGame;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
declare const jokerEmoji = "\uD83C\uDCCF";
|
|
953
|
+
interface MemoryEmojiPosition {
|
|
954
|
+
x: number;
|
|
955
|
+
y: number;
|
|
956
|
+
index: number;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* The memory game result.
|
|
960
|
+
*/
|
|
961
|
+
interface MemoryResult extends GameResult {
|
|
962
|
+
outcome: "win" | "timeout";
|
|
963
|
+
tilesTurned: number;
|
|
964
|
+
remainingPairs: number;
|
|
965
|
+
}
|
|
966
|
+
interface MemoryOptions extends z.input<typeof memoryOptions> {
|
|
967
|
+
embed?: Embed1<Memory>;
|
|
968
|
+
endEmbed?: Embed2<Memory, MemoryResult>;
|
|
969
|
+
/**
|
|
970
|
+
* The max amount of time the player can be idle.
|
|
971
|
+
*/
|
|
972
|
+
timeout?: number;
|
|
973
|
+
}
|
|
974
|
+
declare const memoryOptions: z.ZodObject<{
|
|
975
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
976
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
977
|
+
name: z.ZodString;
|
|
978
|
+
url: z.ZodOptional<z.ZodString>;
|
|
979
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
980
|
+
}, z.core.$strip>>;
|
|
981
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
982
|
+
url: z.ZodString;
|
|
983
|
+
}, z.core.$strip>>;
|
|
984
|
+
title: z.ZodOptional<z.ZodString>;
|
|
985
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
986
|
+
description: z.ZodOptional<z.ZodString>;
|
|
987
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
988
|
+
url: z.ZodString;
|
|
989
|
+
}, z.core.$strip>>;
|
|
990
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
991
|
+
text: z.ZodString;
|
|
992
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
993
|
+
}, z.core.$strip>>;
|
|
994
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Memory) => Awaitable<{
|
|
995
|
+
author?: {
|
|
996
|
+
name: string;
|
|
997
|
+
url?: string | undefined;
|
|
998
|
+
icon_url?: string | undefined;
|
|
999
|
+
} | undefined;
|
|
1000
|
+
thumbnail?: {
|
|
1001
|
+
url: string;
|
|
1002
|
+
} | undefined;
|
|
1003
|
+
title?: string | undefined;
|
|
1004
|
+
color?: number | undefined;
|
|
1005
|
+
description?: string | undefined;
|
|
1006
|
+
image?: {
|
|
1007
|
+
url: string;
|
|
1008
|
+
} | undefined;
|
|
1009
|
+
footer?: {
|
|
1010
|
+
text: string;
|
|
1011
|
+
icon_url?: string | undefined;
|
|
1012
|
+
} | undefined;
|
|
1013
|
+
}>, (args_0: Memory) => Awaitable<{
|
|
1014
|
+
author?: {
|
|
1015
|
+
name: string;
|
|
1016
|
+
url?: string | undefined;
|
|
1017
|
+
icon_url?: string | undefined;
|
|
1018
|
+
} | undefined;
|
|
1019
|
+
thumbnail?: {
|
|
1020
|
+
url: string;
|
|
1021
|
+
} | undefined;
|
|
1022
|
+
title?: string | undefined;
|
|
1023
|
+
color?: number | undefined;
|
|
1024
|
+
description?: string | undefined;
|
|
1025
|
+
image?: {
|
|
1026
|
+
url: string;
|
|
1027
|
+
} | undefined;
|
|
1028
|
+
footer?: {
|
|
1029
|
+
text: string;
|
|
1030
|
+
icon_url?: string | undefined;
|
|
1031
|
+
} | undefined;
|
|
1032
|
+
}>>]>>>;
|
|
1033
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1034
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1035
|
+
name: z.ZodString;
|
|
1036
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1037
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1038
|
+
}, z.core.$strip>>;
|
|
1039
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1040
|
+
url: z.ZodString;
|
|
1041
|
+
}, z.core.$strip>>;
|
|
1042
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1043
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1044
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1045
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1046
|
+
url: z.ZodString;
|
|
1047
|
+
}, z.core.$strip>>;
|
|
1048
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1049
|
+
text: z.ZodString;
|
|
1050
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1051
|
+
}, z.core.$strip>>;
|
|
1052
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Memory, args_1: MemoryResult) => Awaitable<{
|
|
1053
|
+
author?: {
|
|
1054
|
+
name: string;
|
|
1055
|
+
url?: string | undefined;
|
|
1056
|
+
icon_url?: string | undefined;
|
|
1057
|
+
} | undefined;
|
|
1058
|
+
thumbnail?: {
|
|
1059
|
+
url: string;
|
|
1060
|
+
} | undefined;
|
|
1061
|
+
title?: string | undefined;
|
|
1062
|
+
color?: number | undefined;
|
|
1063
|
+
description?: string | undefined;
|
|
1064
|
+
image?: {
|
|
1065
|
+
url: string;
|
|
1066
|
+
} | undefined;
|
|
1067
|
+
footer?: {
|
|
1068
|
+
text: string;
|
|
1069
|
+
icon_url?: string | undefined;
|
|
1070
|
+
} | undefined;
|
|
1071
|
+
}>, (args_0: Memory, args_1: MemoryResult) => Awaitable<{
|
|
1072
|
+
author?: {
|
|
1073
|
+
name: string;
|
|
1074
|
+
url?: string | undefined;
|
|
1075
|
+
icon_url?: string | undefined;
|
|
1076
|
+
} | undefined;
|
|
1077
|
+
thumbnail?: {
|
|
1078
|
+
url: string;
|
|
1079
|
+
} | undefined;
|
|
1080
|
+
title?: string | undefined;
|
|
1081
|
+
color?: number | undefined;
|
|
1082
|
+
description?: string | undefined;
|
|
1083
|
+
image?: {
|
|
1084
|
+
url: string;
|
|
1085
|
+
} | undefined;
|
|
1086
|
+
footer?: {
|
|
1087
|
+
text: string;
|
|
1088
|
+
icon_url?: string | undefined;
|
|
1089
|
+
} | undefined;
|
|
1090
|
+
}>>]>>;
|
|
1091
|
+
winMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: MemoryResult, game: Memory) => string, (result: MemoryResult, game: Memory) => string>]>>>;
|
|
1092
|
+
loseMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: MemoryResult, game: Memory) => string, (result: MemoryResult, game: Memory) => string>]>>>;
|
|
1093
|
+
notPlayerMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(game: Memory) => string, (game: Memory) => string>]>>>;
|
|
1094
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1095
|
+
emojis: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
1096
|
+
}, z.core.$strip>;
|
|
1097
|
+
/**
|
|
1098
|
+
* A game where the player to find all the pairs.
|
|
1099
|
+
*
|
|
1100
|
+
* # Example
|
|
1101
|
+
*
|
|
1102
|
+
* ```js
|
|
1103
|
+
* const game = new Memory(interaction, {
|
|
1104
|
+
* winMessage: res => `**You won the Game! You turned a total of \`${res.tilesTurned}\` tiles.**`
|
|
1105
|
+
* timeout: 120_000
|
|
1106
|
+
* });
|
|
1107
|
+
*
|
|
1108
|
+
* game.on("error", err => console.error(err));
|
|
1109
|
+
* game.on("gameOver", result => console.log(result));
|
|
1110
|
+
*
|
|
1111
|
+
* await game.start();
|
|
1112
|
+
* ```
|
|
1113
|
+
*/
|
|
1114
|
+
declare class Memory extends Game<MemoryResult> {
|
|
1115
|
+
readonly options: z.output<typeof memoryOptions>;
|
|
1116
|
+
readonly emojis: string[];
|
|
1117
|
+
components: ActionRowBuilder<ButtonBuilder>[];
|
|
1118
|
+
selected: MemoryEmojiPosition | null;
|
|
1119
|
+
remainingPairs: number;
|
|
1120
|
+
tilesTurned: number;
|
|
1121
|
+
readonly size = 5;
|
|
1122
|
+
message: Message | null;
|
|
1123
|
+
constructor(context: GameContext, options: MemoryOptions);
|
|
1124
|
+
start(): Promise<void>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Get the positions of this emoji.
|
|
1127
|
+
*/
|
|
1128
|
+
getPairEmojiPositions(emoji: string): MemoryEmojiPosition[];
|
|
1129
|
+
getComponents(): ActionRowBuilder<ButtonBuilder>[];
|
|
1130
|
+
private gameOver;
|
|
1131
|
+
private handleButtons;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* The minesweeper game result.
|
|
1136
|
+
*/
|
|
1137
|
+
interface MinesweeperResult extends GameResult {
|
|
1138
|
+
outcome: "win" | "lose" | "timeout";
|
|
1139
|
+
tilesTurned: number;
|
|
1140
|
+
}
|
|
1141
|
+
interface MinesweeperOptions extends z.input<typeof minesweeperOptions> {
|
|
1142
|
+
embed?: Embed1<Minesweeper>;
|
|
1143
|
+
endEmbed?: Embed2<Minesweeper, MinesweeperResult>;
|
|
1144
|
+
/**
|
|
1145
|
+
* The max amount of time the player can be idle.
|
|
1146
|
+
*/
|
|
1147
|
+
timeout?: number;
|
|
1148
|
+
}
|
|
1149
|
+
declare const minesweeperOptions: z.ZodObject<{
|
|
1150
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1151
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1152
|
+
name: z.ZodString;
|
|
1153
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1154
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1155
|
+
}, z.core.$strip>>;
|
|
1156
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1157
|
+
url: z.ZodString;
|
|
1158
|
+
}, z.core.$strip>>;
|
|
1159
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1160
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1161
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1162
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1163
|
+
url: z.ZodString;
|
|
1164
|
+
}, z.core.$strip>>;
|
|
1165
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1166
|
+
text: z.ZodString;
|
|
1167
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1168
|
+
}, z.core.$strip>>;
|
|
1169
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Minesweeper) => Awaitable<{
|
|
1170
|
+
author?: {
|
|
1171
|
+
name: string;
|
|
1172
|
+
url?: string | undefined;
|
|
1173
|
+
icon_url?: string | undefined;
|
|
1174
|
+
} | undefined;
|
|
1175
|
+
thumbnail?: {
|
|
1176
|
+
url: string;
|
|
1177
|
+
} | undefined;
|
|
1178
|
+
title?: string | undefined;
|
|
1179
|
+
color?: number | undefined;
|
|
1180
|
+
description?: string | undefined;
|
|
1181
|
+
image?: {
|
|
1182
|
+
url: string;
|
|
1183
|
+
} | undefined;
|
|
1184
|
+
footer?: {
|
|
1185
|
+
text: string;
|
|
1186
|
+
icon_url?: string | undefined;
|
|
1187
|
+
} | undefined;
|
|
1188
|
+
}>, (args_0: Minesweeper) => Awaitable<{
|
|
1189
|
+
author?: {
|
|
1190
|
+
name: string;
|
|
1191
|
+
url?: string | undefined;
|
|
1192
|
+
icon_url?: string | undefined;
|
|
1193
|
+
} | undefined;
|
|
1194
|
+
thumbnail?: {
|
|
1195
|
+
url: string;
|
|
1196
|
+
} | undefined;
|
|
1197
|
+
title?: string | undefined;
|
|
1198
|
+
color?: number | undefined;
|
|
1199
|
+
description?: string | undefined;
|
|
1200
|
+
image?: {
|
|
1201
|
+
url: string;
|
|
1202
|
+
} | undefined;
|
|
1203
|
+
footer?: {
|
|
1204
|
+
text: string;
|
|
1205
|
+
icon_url?: string | undefined;
|
|
1206
|
+
} | undefined;
|
|
1207
|
+
}>>]>>>;
|
|
1208
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1209
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1210
|
+
name: z.ZodString;
|
|
1211
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1212
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1213
|
+
}, z.core.$strip>>;
|
|
1214
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1215
|
+
url: z.ZodString;
|
|
1216
|
+
}, z.core.$strip>>;
|
|
1217
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1218
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1219
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1220
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1221
|
+
url: z.ZodString;
|
|
1222
|
+
}, z.core.$strip>>;
|
|
1223
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1224
|
+
text: z.ZodString;
|
|
1225
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1226
|
+
}, z.core.$strip>>;
|
|
1227
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Minesweeper, args_1: MinesweeperResult) => Awaitable<{
|
|
1228
|
+
author?: {
|
|
1229
|
+
name: string;
|
|
1230
|
+
url?: string | undefined;
|
|
1231
|
+
icon_url?: string | undefined;
|
|
1232
|
+
} | undefined;
|
|
1233
|
+
thumbnail?: {
|
|
1234
|
+
url: string;
|
|
1235
|
+
} | undefined;
|
|
1236
|
+
title?: string | undefined;
|
|
1237
|
+
color?: number | undefined;
|
|
1238
|
+
description?: string | undefined;
|
|
1239
|
+
image?: {
|
|
1240
|
+
url: string;
|
|
1241
|
+
} | undefined;
|
|
1242
|
+
footer?: {
|
|
1243
|
+
text: string;
|
|
1244
|
+
icon_url?: string | undefined;
|
|
1245
|
+
} | undefined;
|
|
1246
|
+
}>, (args_0: Minesweeper, args_1: MinesweeperResult) => Awaitable<{
|
|
1247
|
+
author?: {
|
|
1248
|
+
name: string;
|
|
1249
|
+
url?: string | undefined;
|
|
1250
|
+
icon_url?: string | undefined;
|
|
1251
|
+
} | undefined;
|
|
1252
|
+
thumbnail?: {
|
|
1253
|
+
url: string;
|
|
1254
|
+
} | undefined;
|
|
1255
|
+
title?: string | undefined;
|
|
1256
|
+
color?: number | undefined;
|
|
1257
|
+
description?: string | undefined;
|
|
1258
|
+
image?: {
|
|
1259
|
+
url: string;
|
|
1260
|
+
} | undefined;
|
|
1261
|
+
footer?: {
|
|
1262
|
+
text: string;
|
|
1263
|
+
icon_url?: string | undefined;
|
|
1264
|
+
} | undefined;
|
|
1265
|
+
}>>]>>;
|
|
1266
|
+
winMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: MinesweeperResult, game: Minesweeper) => string, (result: MinesweeperResult, game: Minesweeper) => string>]>>>;
|
|
1267
|
+
loseMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: MinesweeperResult, game: Minesweeper) => string, (result: MinesweeperResult, game: Minesweeper) => string>]>>>;
|
|
1268
|
+
notPlayerMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(game: Minesweeper) => string, (game: Minesweeper) => string>]>>>;
|
|
1269
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1270
|
+
mines: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1271
|
+
emojis: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
1272
|
+
flag: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1273
|
+
mine: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1274
|
+
}, z.core.$strip>>>;
|
|
1275
|
+
}, z.core.$strip>;
|
|
1276
|
+
/**
|
|
1277
|
+
* A game where the player needs to click on all tiles except the mines.
|
|
1278
|
+
*
|
|
1279
|
+
* # Example
|
|
1280
|
+
*
|
|
1281
|
+
* ```js
|
|
1282
|
+
* const game = new Minesweeper(interaction, {
|
|
1283
|
+
* winMessage: "You won the Game! You successfully avoided all the mines."
|
|
1284
|
+
* timeout: 120_000
|
|
1285
|
+
* });
|
|
1286
|
+
*
|
|
1287
|
+
* game.on("error", err => console.error(err));
|
|
1288
|
+
* game.on("gameOver", result => console.log(result));
|
|
1289
|
+
*
|
|
1290
|
+
* await game.start();
|
|
1291
|
+
* ```
|
|
1292
|
+
*/
|
|
1293
|
+
declare class Minesweeper extends Game<MinesweeperResult> {
|
|
1294
|
+
readonly options: z.output<typeof minesweeperOptions>;
|
|
1295
|
+
/**
|
|
1296
|
+
* The board of the game.
|
|
1297
|
+
*
|
|
1298
|
+
* - `true` : empty
|
|
1299
|
+
* - `false` : mine
|
|
1300
|
+
* - `number` : empty, with `n` mines around it
|
|
1301
|
+
*/
|
|
1302
|
+
readonly board: (number | boolean)[];
|
|
1303
|
+
/**
|
|
1304
|
+
* The width/height of the board
|
|
1305
|
+
*/
|
|
1306
|
+
readonly size = 5;
|
|
1307
|
+
message: Message | null;
|
|
1308
|
+
constructor(context: GameContext, options?: MinesweeperOptions);
|
|
1309
|
+
start(): Promise<void>;
|
|
1310
|
+
private handleButtons;
|
|
1311
|
+
private gameOver;
|
|
1312
|
+
private plantMines;
|
|
1313
|
+
private getMinesAround;
|
|
1314
|
+
private showFirstBlock;
|
|
1315
|
+
private hasFoundAllMines;
|
|
1316
|
+
/**
|
|
1317
|
+
* Build the minesweeper grid using buttons.
|
|
1318
|
+
*/
|
|
1319
|
+
getComponents(showMines?: boolean, found?: boolean, disabled?: boolean): ActionRowBuilder<ButtonBuilder>[];
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* The RPS game result.
|
|
1324
|
+
*/
|
|
1325
|
+
interface RockPaperScissorsResult extends VersusGameResult {
|
|
1326
|
+
outcome: "win" | "tie" | "timeout";
|
|
1327
|
+
/**
|
|
1328
|
+
* Only if `outcome` is `win`.
|
|
1329
|
+
*/
|
|
1330
|
+
winner: User | null;
|
|
1331
|
+
playerChoice: string | null;
|
|
1332
|
+
opponentChoice: string | null;
|
|
1333
|
+
}
|
|
1334
|
+
interface RockPaperScissorsOptions extends z.input<typeof rockPaperScissorsOptions> {
|
|
1335
|
+
versus: VersusOptions;
|
|
1336
|
+
embed?: Embed1<RockPaperScissors>;
|
|
1337
|
+
endEmbed?: Embed2<RockPaperScissors, RockPaperScissorsResult>;
|
|
1338
|
+
/**
|
|
1339
|
+
* The max amount of time the player can be idle.
|
|
1340
|
+
*/
|
|
1341
|
+
timeout?: number;
|
|
1342
|
+
}
|
|
1343
|
+
declare const rockPaperScissorsOptions: z.ZodObject<{
|
|
1344
|
+
versus: z.ZodObject<{
|
|
1345
|
+
opponent: z.ZodCustom<User, User>;
|
|
1346
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1347
|
+
requestEmbed: z.ZodDefault<z.ZodOptional<z.ZodCustom<(ctx: VersusPlayers) => discord_js.APIEmbed, (ctx: VersusPlayers) => discord_js.APIEmbed>>>;
|
|
1348
|
+
rejectEmbed: z.ZodDefault<z.ZodOptional<z.ZodCustom<(ctx: VersusPlayers) => discord_js.APIEmbed, (ctx: VersusPlayers) => discord_js.APIEmbed>>>;
|
|
1349
|
+
timeoutEmbed: z.ZodDefault<z.ZodOptional<z.ZodCustom<(ctx: VersusPlayers) => discord_js.APIEmbed, (ctx: VersusPlayers) => discord_js.APIEmbed>>>;
|
|
1350
|
+
buttons: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
1351
|
+
accept: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1352
|
+
reject: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1353
|
+
}, z.core.$strip>>>;
|
|
1354
|
+
}, z.core.$strip>;
|
|
1355
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1356
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1357
|
+
name: z.ZodString;
|
|
1358
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1359
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1360
|
+
}, z.core.$strip>>;
|
|
1361
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1362
|
+
url: z.ZodString;
|
|
1363
|
+
}, z.core.$strip>>;
|
|
1364
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1365
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1366
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1367
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1368
|
+
url: z.ZodString;
|
|
1369
|
+
}, z.core.$strip>>;
|
|
1370
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1371
|
+
text: z.ZodString;
|
|
1372
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1373
|
+
}, z.core.$strip>>;
|
|
1374
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: RockPaperScissors) => Awaitable<{
|
|
1375
|
+
author?: {
|
|
1376
|
+
name: string;
|
|
1377
|
+
url?: string | undefined;
|
|
1378
|
+
icon_url?: string | undefined;
|
|
1379
|
+
} | undefined;
|
|
1380
|
+
thumbnail?: {
|
|
1381
|
+
url: string;
|
|
1382
|
+
} | undefined;
|
|
1383
|
+
title?: string | undefined;
|
|
1384
|
+
color?: number | undefined;
|
|
1385
|
+
description?: string | undefined;
|
|
1386
|
+
image?: {
|
|
1387
|
+
url: string;
|
|
1388
|
+
} | undefined;
|
|
1389
|
+
footer?: {
|
|
1390
|
+
text: string;
|
|
1391
|
+
icon_url?: string | undefined;
|
|
1392
|
+
} | undefined;
|
|
1393
|
+
}>, (args_0: RockPaperScissors) => Awaitable<{
|
|
1394
|
+
author?: {
|
|
1395
|
+
name: string;
|
|
1396
|
+
url?: string | undefined;
|
|
1397
|
+
icon_url?: string | undefined;
|
|
1398
|
+
} | undefined;
|
|
1399
|
+
thumbnail?: {
|
|
1400
|
+
url: string;
|
|
1401
|
+
} | undefined;
|
|
1402
|
+
title?: string | undefined;
|
|
1403
|
+
color?: number | undefined;
|
|
1404
|
+
description?: string | undefined;
|
|
1405
|
+
image?: {
|
|
1406
|
+
url: string;
|
|
1407
|
+
} | undefined;
|
|
1408
|
+
footer?: {
|
|
1409
|
+
text: string;
|
|
1410
|
+
icon_url?: string | undefined;
|
|
1411
|
+
} | undefined;
|
|
1412
|
+
}>>]>>>;
|
|
1413
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1414
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1415
|
+
name: z.ZodString;
|
|
1416
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1417
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1418
|
+
}, z.core.$strip>>;
|
|
1419
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1420
|
+
url: z.ZodString;
|
|
1421
|
+
}, z.core.$strip>>;
|
|
1422
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1423
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1424
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1425
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1426
|
+
url: z.ZodString;
|
|
1427
|
+
}, z.core.$strip>>;
|
|
1428
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1429
|
+
text: z.ZodString;
|
|
1430
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1431
|
+
}, z.core.$strip>>;
|
|
1432
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: RockPaperScissors, args_1: RockPaperScissorsResult) => Awaitable<{
|
|
1433
|
+
author?: {
|
|
1434
|
+
name: string;
|
|
1435
|
+
url?: string | undefined;
|
|
1436
|
+
icon_url?: string | undefined;
|
|
1437
|
+
} | undefined;
|
|
1438
|
+
thumbnail?: {
|
|
1439
|
+
url: string;
|
|
1440
|
+
} | undefined;
|
|
1441
|
+
title?: string | undefined;
|
|
1442
|
+
color?: number | undefined;
|
|
1443
|
+
description?: string | undefined;
|
|
1444
|
+
image?: {
|
|
1445
|
+
url: string;
|
|
1446
|
+
} | undefined;
|
|
1447
|
+
footer?: {
|
|
1448
|
+
text: string;
|
|
1449
|
+
icon_url?: string | undefined;
|
|
1450
|
+
} | undefined;
|
|
1451
|
+
}>, (args_0: RockPaperScissors, args_1: RockPaperScissorsResult) => Awaitable<{
|
|
1452
|
+
author?: {
|
|
1453
|
+
name: string;
|
|
1454
|
+
url?: string | undefined;
|
|
1455
|
+
icon_url?: string | undefined;
|
|
1456
|
+
} | undefined;
|
|
1457
|
+
thumbnail?: {
|
|
1458
|
+
url: string;
|
|
1459
|
+
} | undefined;
|
|
1460
|
+
title?: string | undefined;
|
|
1461
|
+
color?: number | undefined;
|
|
1462
|
+
description?: string | undefined;
|
|
1463
|
+
image?: {
|
|
1464
|
+
url: string;
|
|
1465
|
+
} | undefined;
|
|
1466
|
+
footer?: {
|
|
1467
|
+
text: string;
|
|
1468
|
+
icon_url?: string | undefined;
|
|
1469
|
+
} | undefined;
|
|
1470
|
+
}>>]>>;
|
|
1471
|
+
winMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: RockPaperScissorsResult, game: RockPaperScissors) => string, (result: RockPaperScissorsResult, game: RockPaperScissors) => string>]>>>;
|
|
1472
|
+
tieMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: RockPaperScissorsResult, game: RockPaperScissors) => string, (result: RockPaperScissorsResult, game: RockPaperScissors) => string>]>>>;
|
|
1473
|
+
timeoutMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: RockPaperScissorsResult, game: RockPaperScissors) => string, (result: RockPaperScissorsResult, game: RockPaperScissors) => string>]>>>;
|
|
1474
|
+
choiceMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(data: string, game: RockPaperScissors) => string, (data: string, game: RockPaperScissors) => string>]>>>;
|
|
1475
|
+
notPlayerMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(game: RockPaperScissors) => string, (game: RockPaperScissors) => string>]>>>;
|
|
1476
|
+
buttonStyle: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1477
|
+
buttons: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
1478
|
+
rock: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1479
|
+
paper: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1480
|
+
scissors: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1481
|
+
}, z.core.$strip>>>;
|
|
1482
|
+
emojis: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
1483
|
+
rock: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1484
|
+
paper: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1485
|
+
scissors: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1486
|
+
}, z.core.$strip>>>;
|
|
1487
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1488
|
+
}, z.core.$strip>;
|
|
1489
|
+
/**
|
|
1490
|
+
* The Rock Paper Scissors game.
|
|
1491
|
+
*
|
|
1492
|
+
* # Errors
|
|
1493
|
+
*
|
|
1494
|
+
* Can emit `fatalError` if it fails to edit from the invitation embed to the game message.
|
|
1495
|
+
*
|
|
1496
|
+
* # Example
|
|
1497
|
+
*
|
|
1498
|
+
* ```js
|
|
1499
|
+
* const opponent = // The opponent (must be a discord.js User)
|
|
1500
|
+
*
|
|
1501
|
+
* const game = new RockPaperScissors(interaction, {
|
|
1502
|
+
* versus: {
|
|
1503
|
+
* opponent
|
|
1504
|
+
* }
|
|
1505
|
+
* });
|
|
1506
|
+
*
|
|
1507
|
+
* game.on("error", err => console.error(err));
|
|
1508
|
+
* game.on("versusReject", () => console.log("Opponent rejected the invitation to play"));
|
|
1509
|
+
* game.on("gameOver", result => console.log(result));
|
|
1510
|
+
*
|
|
1511
|
+
* await game.start();
|
|
1512
|
+
* ```
|
|
1513
|
+
*/
|
|
1514
|
+
declare class RockPaperScissors extends VersusGame<RockPaperScissorsResult> {
|
|
1515
|
+
readonly options: z.output<typeof rockPaperScissorsOptions>;
|
|
1516
|
+
playerChoice: string | null;
|
|
1517
|
+
opponentChoice: string | null;
|
|
1518
|
+
message: Message | null;
|
|
1519
|
+
constructor(context: GameContext, options?: RockPaperScissorsOptions);
|
|
1520
|
+
start(): Promise<void>;
|
|
1521
|
+
private runGame;
|
|
1522
|
+
private handleButtons;
|
|
1523
|
+
private getResult;
|
|
1524
|
+
private hasPlayer1Won;
|
|
1525
|
+
private getActionRow;
|
|
1526
|
+
private gameOver;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* The Tic Tac Toe game result.
|
|
1531
|
+
*/
|
|
1532
|
+
interface TicTacToeResult extends VersusGameResult {
|
|
1533
|
+
outcome: "win" | "tie" | "timeout";
|
|
1534
|
+
/**
|
|
1535
|
+
* Only if `outcome` is `win`.
|
|
1536
|
+
*/
|
|
1537
|
+
winner: User | null;
|
|
1538
|
+
winnerEmoji: string | null;
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* The data of a Tic Tac Toe turn.
|
|
1542
|
+
*/
|
|
1543
|
+
interface TicTacToeTurn {
|
|
1544
|
+
player: User;
|
|
1545
|
+
emoji: string;
|
|
1546
|
+
}
|
|
1547
|
+
interface TicTacToeOptions extends z.input<typeof ticTacToeOptions> {
|
|
1548
|
+
versus: VersusOptions;
|
|
1549
|
+
embed?: Embed1<TicTacToe>;
|
|
1550
|
+
endEmbed?: Embed2<TicTacToe, TicTacToeResult>;
|
|
1551
|
+
/**
|
|
1552
|
+
* The max amount of time the player can be idle.
|
|
1553
|
+
*/
|
|
1554
|
+
timeout?: number;
|
|
1555
|
+
}
|
|
1556
|
+
declare const ticTacToeOptions: z.ZodObject<{
|
|
1557
|
+
versus: z.ZodObject<{
|
|
1558
|
+
opponent: z.ZodCustom<User, User>;
|
|
1559
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1560
|
+
requestEmbed: z.ZodDefault<z.ZodOptional<z.ZodCustom<(ctx: VersusPlayers) => discord_js.APIEmbed, (ctx: VersusPlayers) => discord_js.APIEmbed>>>;
|
|
1561
|
+
rejectEmbed: z.ZodDefault<z.ZodOptional<z.ZodCustom<(ctx: VersusPlayers) => discord_js.APIEmbed, (ctx: VersusPlayers) => discord_js.APIEmbed>>>;
|
|
1562
|
+
timeoutEmbed: z.ZodDefault<z.ZodOptional<z.ZodCustom<(ctx: VersusPlayers) => discord_js.APIEmbed, (ctx: VersusPlayers) => discord_js.APIEmbed>>>;
|
|
1563
|
+
buttons: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
1564
|
+
accept: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1565
|
+
reject: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1566
|
+
}, z.core.$strip>>>;
|
|
1567
|
+
}, z.core.$strip>;
|
|
1568
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1569
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1570
|
+
name: z.ZodString;
|
|
1571
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1572
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1573
|
+
}, z.core.$strip>>;
|
|
1574
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1575
|
+
url: z.ZodString;
|
|
1576
|
+
}, z.core.$strip>>;
|
|
1577
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1578
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1579
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1580
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1581
|
+
url: z.ZodString;
|
|
1582
|
+
}, z.core.$strip>>;
|
|
1583
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1584
|
+
text: z.ZodString;
|
|
1585
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1586
|
+
}, z.core.$strip>>;
|
|
1587
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: TicTacToe) => Awaitable<{
|
|
1588
|
+
author?: {
|
|
1589
|
+
name: string;
|
|
1590
|
+
url?: string | undefined;
|
|
1591
|
+
icon_url?: string | undefined;
|
|
1592
|
+
} | undefined;
|
|
1593
|
+
thumbnail?: {
|
|
1594
|
+
url: string;
|
|
1595
|
+
} | undefined;
|
|
1596
|
+
title?: string | undefined;
|
|
1597
|
+
color?: number | undefined;
|
|
1598
|
+
description?: string | undefined;
|
|
1599
|
+
image?: {
|
|
1600
|
+
url: string;
|
|
1601
|
+
} | undefined;
|
|
1602
|
+
footer?: {
|
|
1603
|
+
text: string;
|
|
1604
|
+
icon_url?: string | undefined;
|
|
1605
|
+
} | undefined;
|
|
1606
|
+
}>, (args_0: TicTacToe) => Awaitable<{
|
|
1607
|
+
author?: {
|
|
1608
|
+
name: string;
|
|
1609
|
+
url?: string | undefined;
|
|
1610
|
+
icon_url?: string | undefined;
|
|
1611
|
+
} | undefined;
|
|
1612
|
+
thumbnail?: {
|
|
1613
|
+
url: string;
|
|
1614
|
+
} | undefined;
|
|
1615
|
+
title?: string | undefined;
|
|
1616
|
+
color?: number | undefined;
|
|
1617
|
+
description?: string | undefined;
|
|
1618
|
+
image?: {
|
|
1619
|
+
url: string;
|
|
1620
|
+
} | undefined;
|
|
1621
|
+
footer?: {
|
|
1622
|
+
text: string;
|
|
1623
|
+
icon_url?: string | undefined;
|
|
1624
|
+
} | undefined;
|
|
1625
|
+
}>>]>>>;
|
|
1626
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1627
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1628
|
+
name: z.ZodString;
|
|
1629
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1630
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1631
|
+
}, z.core.$strip>>;
|
|
1632
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1633
|
+
url: z.ZodString;
|
|
1634
|
+
}, z.core.$strip>>;
|
|
1635
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1636
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1637
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1638
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1639
|
+
url: z.ZodString;
|
|
1640
|
+
}, z.core.$strip>>;
|
|
1641
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1642
|
+
text: z.ZodString;
|
|
1643
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1644
|
+
}, z.core.$strip>>;
|
|
1645
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: TicTacToe, args_1: TicTacToeResult) => Awaitable<{
|
|
1646
|
+
author?: {
|
|
1647
|
+
name: string;
|
|
1648
|
+
url?: string | undefined;
|
|
1649
|
+
icon_url?: string | undefined;
|
|
1650
|
+
} | undefined;
|
|
1651
|
+
thumbnail?: {
|
|
1652
|
+
url: string;
|
|
1653
|
+
} | undefined;
|
|
1654
|
+
title?: string | undefined;
|
|
1655
|
+
color?: number | undefined;
|
|
1656
|
+
description?: string | undefined;
|
|
1657
|
+
image?: {
|
|
1658
|
+
url: string;
|
|
1659
|
+
} | undefined;
|
|
1660
|
+
footer?: {
|
|
1661
|
+
text: string;
|
|
1662
|
+
icon_url?: string | undefined;
|
|
1663
|
+
} | undefined;
|
|
1664
|
+
}>, (args_0: TicTacToe, args_1: TicTacToeResult) => Awaitable<{
|
|
1665
|
+
author?: {
|
|
1666
|
+
name: string;
|
|
1667
|
+
url?: string | undefined;
|
|
1668
|
+
icon_url?: string | undefined;
|
|
1669
|
+
} | undefined;
|
|
1670
|
+
thumbnail?: {
|
|
1671
|
+
url: string;
|
|
1672
|
+
} | undefined;
|
|
1673
|
+
title?: string | undefined;
|
|
1674
|
+
color?: number | undefined;
|
|
1675
|
+
description?: string | undefined;
|
|
1676
|
+
image?: {
|
|
1677
|
+
url: string;
|
|
1678
|
+
} | undefined;
|
|
1679
|
+
footer?: {
|
|
1680
|
+
text: string;
|
|
1681
|
+
icon_url?: string | undefined;
|
|
1682
|
+
} | undefined;
|
|
1683
|
+
}>>]>>;
|
|
1684
|
+
winMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: TicTacToeResult, game: TicTacToe) => string, (result: TicTacToeResult, game: TicTacToe) => string>]>>>;
|
|
1685
|
+
tieMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: TicTacToeResult, game: TicTacToe) => string, (result: TicTacToeResult, game: TicTacToe) => string>]>>>;
|
|
1686
|
+
timeoutMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: TicTacToeResult, game: TicTacToe) => string, (result: TicTacToeResult, game: TicTacToe) => string>]>>>;
|
|
1687
|
+
turnMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(data: TicTacToeTurn, game: TicTacToe) => string, (data: TicTacToeTurn, game: TicTacToe) => string>]>>>;
|
|
1688
|
+
notPlayerMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(game: TicTacToe) => string, (game: TicTacToe) => string>]>>>;
|
|
1689
|
+
emojis: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
1690
|
+
xButton: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1691
|
+
oButton: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1692
|
+
}, z.core.$strip>>>;
|
|
1693
|
+
styles: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
1694
|
+
xButton: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1695
|
+
oButton: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1696
|
+
}, z.core.$strip>>>;
|
|
1697
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1698
|
+
}, z.core.$strip>;
|
|
1699
|
+
/**
|
|
1700
|
+
* The Tic Tac Toe game.
|
|
1701
|
+
*
|
|
1702
|
+
* # Errors
|
|
1703
|
+
*
|
|
1704
|
+
* Can emit `fatalError` if it fails to edit from the invitation embed to the game message.
|
|
1705
|
+
*
|
|
1706
|
+
* # Example
|
|
1707
|
+
*
|
|
1708
|
+
* ```js
|
|
1709
|
+
* const opponent = // The opponent (must be a discord.js User)
|
|
1710
|
+
*
|
|
1711
|
+
* const game = new TicTacToe(interaction, {
|
|
1712
|
+
* versus: {
|
|
1713
|
+
* opponent
|
|
1714
|
+
* }
|
|
1715
|
+
* });
|
|
1716
|
+
*
|
|
1717
|
+
* game.on("error", err => console.error(err));
|
|
1718
|
+
* game.on("versusReject", () => console.log("Opponent rejected the invitation to play"));
|
|
1719
|
+
* game.on("gameOver", result => console.log(result));
|
|
1720
|
+
*
|
|
1721
|
+
* await game.start();
|
|
1722
|
+
* ```
|
|
1723
|
+
*/
|
|
1724
|
+
declare class TicTacToe extends VersusGame<TicTacToeResult> {
|
|
1725
|
+
readonly options: z.output<typeof ticTacToeOptions>;
|
|
1726
|
+
/**
|
|
1727
|
+
* A 9-elements array.
|
|
1728
|
+
*
|
|
1729
|
+
* - `0` : empty
|
|
1730
|
+
* - `1` : X (player 1)
|
|
1731
|
+
* - `2` : O (player 2)
|
|
1732
|
+
*/
|
|
1733
|
+
readonly gameboard: number[];
|
|
1734
|
+
isPlayer1Turn: boolean;
|
|
1735
|
+
message: Message | null;
|
|
1736
|
+
private locked;
|
|
1737
|
+
constructor(context: GameContext, options?: TicTacToeOptions);
|
|
1738
|
+
start(): Promise<void>;
|
|
1739
|
+
private runGame;
|
|
1740
|
+
private handleButtons;
|
|
1741
|
+
private gameOver;
|
|
1742
|
+
private hasWonGame;
|
|
1743
|
+
private getPlayerTurnData;
|
|
1744
|
+
private getButtonData;
|
|
1745
|
+
private getComponents;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
/**
|
|
1749
|
+
* The trivia game result.
|
|
1750
|
+
*/
|
|
1751
|
+
interface TriviaResult extends GameResult {
|
|
1752
|
+
outcome: "win" | "lose" | "timeout";
|
|
1753
|
+
trivia: TriviaData;
|
|
1754
|
+
/**
|
|
1755
|
+
* Index in `trivia.options`.
|
|
1756
|
+
*/
|
|
1757
|
+
selected: number;
|
|
1758
|
+
}
|
|
1759
|
+
/**
|
|
1760
|
+
* For `single` questions, the values must be the strings `"True"` and `"False"`.
|
|
1761
|
+
*/
|
|
1762
|
+
interface TriviaData {
|
|
1763
|
+
question: string;
|
|
1764
|
+
difficulty: string;
|
|
1765
|
+
category: string;
|
|
1766
|
+
answer: string;
|
|
1767
|
+
options: string[];
|
|
1768
|
+
}
|
|
1769
|
+
interface TriviaOptions extends z.input<typeof triviaOptions> {
|
|
1770
|
+
embed?: Embed1<Trivia>;
|
|
1771
|
+
endEmbed?: Embed2<Trivia, TriviaResult>;
|
|
1772
|
+
/**
|
|
1773
|
+
* Message displayed when the API call to fetch the trivia fails.
|
|
1774
|
+
*/
|
|
1775
|
+
errorMessage?: GameMessage<Trivia>;
|
|
1776
|
+
/**
|
|
1777
|
+
* Random if not specified.
|
|
1778
|
+
*/
|
|
1779
|
+
difficulty?: "easy" | "medium" | "hard";
|
|
1780
|
+
/**
|
|
1781
|
+
* The max amount of time the player can be idle.
|
|
1782
|
+
*/
|
|
1783
|
+
timeout?: number;
|
|
1784
|
+
}
|
|
1785
|
+
declare const triviaOptions: z.ZodObject<{
|
|
1786
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1787
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1788
|
+
name: z.ZodString;
|
|
1789
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1790
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1791
|
+
}, z.core.$strip>>;
|
|
1792
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1793
|
+
url: z.ZodString;
|
|
1794
|
+
}, z.core.$strip>>;
|
|
1795
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1796
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1797
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1798
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1799
|
+
url: z.ZodString;
|
|
1800
|
+
}, z.core.$strip>>;
|
|
1801
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1802
|
+
text: z.ZodString;
|
|
1803
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1804
|
+
}, z.core.$strip>>;
|
|
1805
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Trivia) => Awaitable<{
|
|
1806
|
+
author?: {
|
|
1807
|
+
name: string;
|
|
1808
|
+
url?: string | undefined;
|
|
1809
|
+
icon_url?: string | undefined;
|
|
1810
|
+
} | undefined;
|
|
1811
|
+
thumbnail?: {
|
|
1812
|
+
url: string;
|
|
1813
|
+
} | undefined;
|
|
1814
|
+
title?: string | undefined;
|
|
1815
|
+
color?: number | undefined;
|
|
1816
|
+
description?: string | undefined;
|
|
1817
|
+
image?: {
|
|
1818
|
+
url: string;
|
|
1819
|
+
} | undefined;
|
|
1820
|
+
footer?: {
|
|
1821
|
+
text: string;
|
|
1822
|
+
icon_url?: string | undefined;
|
|
1823
|
+
} | undefined;
|
|
1824
|
+
}>, (args_0: Trivia) => Awaitable<{
|
|
1825
|
+
author?: {
|
|
1826
|
+
name: string;
|
|
1827
|
+
url?: string | undefined;
|
|
1828
|
+
icon_url?: string | undefined;
|
|
1829
|
+
} | undefined;
|
|
1830
|
+
thumbnail?: {
|
|
1831
|
+
url: string;
|
|
1832
|
+
} | undefined;
|
|
1833
|
+
title?: string | undefined;
|
|
1834
|
+
color?: number | undefined;
|
|
1835
|
+
description?: string | undefined;
|
|
1836
|
+
image?: {
|
|
1837
|
+
url: string;
|
|
1838
|
+
} | undefined;
|
|
1839
|
+
footer?: {
|
|
1840
|
+
text: string;
|
|
1841
|
+
icon_url?: string | undefined;
|
|
1842
|
+
} | undefined;
|
|
1843
|
+
}>>]>>>;
|
|
1844
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1845
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1846
|
+
name: z.ZodString;
|
|
1847
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1848
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1849
|
+
}, z.core.$strip>>;
|
|
1850
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1851
|
+
url: z.ZodString;
|
|
1852
|
+
}, z.core.$strip>>;
|
|
1853
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1854
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1855
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1856
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1857
|
+
url: z.ZodString;
|
|
1858
|
+
}, z.core.$strip>>;
|
|
1859
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1860
|
+
text: z.ZodString;
|
|
1861
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1862
|
+
}, z.core.$strip>>;
|
|
1863
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Trivia, args_1: TriviaResult) => Awaitable<{
|
|
1864
|
+
author?: {
|
|
1865
|
+
name: string;
|
|
1866
|
+
url?: string | undefined;
|
|
1867
|
+
icon_url?: string | undefined;
|
|
1868
|
+
} | undefined;
|
|
1869
|
+
thumbnail?: {
|
|
1870
|
+
url: string;
|
|
1871
|
+
} | undefined;
|
|
1872
|
+
title?: string | undefined;
|
|
1873
|
+
color?: number | undefined;
|
|
1874
|
+
description?: string | undefined;
|
|
1875
|
+
image?: {
|
|
1876
|
+
url: string;
|
|
1877
|
+
} | undefined;
|
|
1878
|
+
footer?: {
|
|
1879
|
+
text: string;
|
|
1880
|
+
icon_url?: string | undefined;
|
|
1881
|
+
} | undefined;
|
|
1882
|
+
}>, (args_0: Trivia, args_1: TriviaResult) => Awaitable<{
|
|
1883
|
+
author?: {
|
|
1884
|
+
name: string;
|
|
1885
|
+
url?: string | undefined;
|
|
1886
|
+
icon_url?: string | undefined;
|
|
1887
|
+
} | undefined;
|
|
1888
|
+
thumbnail?: {
|
|
1889
|
+
url: string;
|
|
1890
|
+
} | undefined;
|
|
1891
|
+
title?: string | undefined;
|
|
1892
|
+
color?: number | undefined;
|
|
1893
|
+
description?: string | undefined;
|
|
1894
|
+
image?: {
|
|
1895
|
+
url: string;
|
|
1896
|
+
} | undefined;
|
|
1897
|
+
footer?: {
|
|
1898
|
+
text: string;
|
|
1899
|
+
icon_url?: string | undefined;
|
|
1900
|
+
} | undefined;
|
|
1901
|
+
}>>]>>;
|
|
1902
|
+
winMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: TriviaResult, game: Trivia) => string, (result: TriviaResult, game: Trivia) => string>]>>>;
|
|
1903
|
+
loseMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: TriviaResult, game: Trivia) => string, (result: TriviaResult, game: Trivia) => string>]>>>;
|
|
1904
|
+
errorMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(game: Trivia) => string, (game: Trivia) => string>]>>>;
|
|
1905
|
+
notPlayerMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(game: Trivia) => string, (game: Trivia) => string>]>>>;
|
|
1906
|
+
mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
1907
|
+
multiple: "multiple";
|
|
1908
|
+
single: "single";
|
|
1909
|
+
}>>>;
|
|
1910
|
+
difficulty: z.ZodOptional<z.ZodEnum<{
|
|
1911
|
+
[x: string]: string;
|
|
1912
|
+
}>>;
|
|
1913
|
+
trivia: z.ZodOptional<z.ZodCustom<(game: Trivia) => Awaitable<TriviaData>, (game: Trivia) => Awaitable<TriviaData>>>;
|
|
1914
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
1915
|
+
trueText: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1916
|
+
falseText: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
1917
|
+
}, z.core.$strip>;
|
|
1918
|
+
/**
|
|
1919
|
+
* A game where the player needs to find the answer of a random question.
|
|
1920
|
+
*
|
|
1921
|
+
* # API
|
|
1922
|
+
*
|
|
1923
|
+
* This game uses the `opentdb.com` API. If you want to use
|
|
1924
|
+
* your own questions, use the `trivia` option.
|
|
1925
|
+
*
|
|
1926
|
+
* # Example
|
|
1927
|
+
*
|
|
1928
|
+
* ```js
|
|
1929
|
+
* const game = new Trivia(interaction, {
|
|
1930
|
+
* timeout: 30_000
|
|
1931
|
+
* });
|
|
1932
|
+
*
|
|
1933
|
+
* game.on("error", err => console.error(err));
|
|
1934
|
+
* game.on("gameOver", result => console.log(result));
|
|
1935
|
+
*
|
|
1936
|
+
* await game.start();
|
|
1937
|
+
* ```
|
|
1938
|
+
*/
|
|
1939
|
+
declare class Trivia extends Game<TriviaResult> {
|
|
1940
|
+
readonly options: z.output<typeof triviaOptions>;
|
|
1941
|
+
readonly difficulty: string;
|
|
1942
|
+
selected: number | null;
|
|
1943
|
+
trivia: TriviaData | null;
|
|
1944
|
+
message: Message | null;
|
|
1945
|
+
constructor(context: GameContext, options?: TriviaOptions);
|
|
1946
|
+
start(): Promise<void>;
|
|
1947
|
+
private handleButtons;
|
|
1948
|
+
private gameOver;
|
|
1949
|
+
/**
|
|
1950
|
+
* Build the selection buttons.
|
|
1951
|
+
*/
|
|
1952
|
+
getComponents(ended?: boolean): ActionRowBuilder<ButtonBuilder>[];
|
|
1953
|
+
private getTriviaQuestion;
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
/**
|
|
1957
|
+
* The Wordle game result.
|
|
1958
|
+
*/
|
|
1959
|
+
interface WordleResult extends GameResult {
|
|
1960
|
+
outcome: "win" | "lose" | "timeout";
|
|
1961
|
+
/**
|
|
1962
|
+
* The word to guess, in lowercase. Either the one specified or a random one.
|
|
1963
|
+
*/
|
|
1964
|
+
word: string;
|
|
1965
|
+
guesses: string[];
|
|
1966
|
+
}
|
|
1967
|
+
interface WordleOptions extends z.input<typeof wordleOptions> {
|
|
1968
|
+
embed?: Embed1<Wordle>;
|
|
1969
|
+
endEmbed?: Embed2<Wordle, WordleResult>;
|
|
1970
|
+
/**
|
|
1971
|
+
* The max amount of time the player can be idle.
|
|
1972
|
+
*/
|
|
1973
|
+
timeout?: number;
|
|
1974
|
+
/**
|
|
1975
|
+
* The word to guess, in lowercase. Either the one specified or a random one.
|
|
1976
|
+
*/
|
|
1977
|
+
word?: string;
|
|
1978
|
+
}
|
|
1979
|
+
declare const wordleOptions: z.ZodObject<{
|
|
1980
|
+
embed: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1981
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
1982
|
+
name: z.ZodString;
|
|
1983
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1984
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1985
|
+
}, z.core.$strip>>;
|
|
1986
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
1987
|
+
url: z.ZodString;
|
|
1988
|
+
}, z.core.$strip>>;
|
|
1989
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1990
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
1991
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1992
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
1993
|
+
url: z.ZodString;
|
|
1994
|
+
}, z.core.$strip>>;
|
|
1995
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
1996
|
+
text: z.ZodString;
|
|
1997
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
1998
|
+
}, z.core.$strip>>;
|
|
1999
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Wordle) => Awaitable<{
|
|
2000
|
+
author?: {
|
|
2001
|
+
name: string;
|
|
2002
|
+
url?: string | undefined;
|
|
2003
|
+
icon_url?: string | undefined;
|
|
2004
|
+
} | undefined;
|
|
2005
|
+
thumbnail?: {
|
|
2006
|
+
url: string;
|
|
2007
|
+
} | undefined;
|
|
2008
|
+
title?: string | undefined;
|
|
2009
|
+
color?: number | undefined;
|
|
2010
|
+
description?: string | undefined;
|
|
2011
|
+
image?: {
|
|
2012
|
+
url: string;
|
|
2013
|
+
} | undefined;
|
|
2014
|
+
footer?: {
|
|
2015
|
+
text: string;
|
|
2016
|
+
icon_url?: string | undefined;
|
|
2017
|
+
} | undefined;
|
|
2018
|
+
}>, (args_0: Wordle) => Awaitable<{
|
|
2019
|
+
author?: {
|
|
2020
|
+
name: string;
|
|
2021
|
+
url?: string | undefined;
|
|
2022
|
+
icon_url?: string | undefined;
|
|
2023
|
+
} | undefined;
|
|
2024
|
+
thumbnail?: {
|
|
2025
|
+
url: string;
|
|
2026
|
+
} | undefined;
|
|
2027
|
+
title?: string | undefined;
|
|
2028
|
+
color?: number | undefined;
|
|
2029
|
+
description?: string | undefined;
|
|
2030
|
+
image?: {
|
|
2031
|
+
url: string;
|
|
2032
|
+
} | undefined;
|
|
2033
|
+
footer?: {
|
|
2034
|
+
text: string;
|
|
2035
|
+
icon_url?: string | undefined;
|
|
2036
|
+
} | undefined;
|
|
2037
|
+
}>>]>>>;
|
|
2038
|
+
endEmbed: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
2039
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
2040
|
+
name: z.ZodString;
|
|
2041
|
+
url: z.ZodOptional<z.ZodString>;
|
|
2042
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
2043
|
+
}, z.core.$strip>>;
|
|
2044
|
+
thumbnail: z.ZodOptional<z.ZodObject<{
|
|
2045
|
+
url: z.ZodString;
|
|
2046
|
+
}, z.core.$strip>>;
|
|
2047
|
+
title: z.ZodOptional<z.ZodString>;
|
|
2048
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber]>>;
|
|
2049
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2050
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
2051
|
+
url: z.ZodString;
|
|
2052
|
+
}, z.core.$strip>>;
|
|
2053
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
2054
|
+
text: z.ZodString;
|
|
2055
|
+
icon_url: z.ZodOptional<z.ZodString>;
|
|
2056
|
+
}, z.core.$strip>>;
|
|
2057
|
+
}, z.core.$strip>, z.ZodCustom<(args_0: Wordle, args_1: WordleResult) => Awaitable<{
|
|
2058
|
+
author?: {
|
|
2059
|
+
name: string;
|
|
2060
|
+
url?: string | undefined;
|
|
2061
|
+
icon_url?: string | undefined;
|
|
2062
|
+
} | undefined;
|
|
2063
|
+
thumbnail?: {
|
|
2064
|
+
url: string;
|
|
2065
|
+
} | undefined;
|
|
2066
|
+
title?: string | undefined;
|
|
2067
|
+
color?: number | undefined;
|
|
2068
|
+
description?: string | undefined;
|
|
2069
|
+
image?: {
|
|
2070
|
+
url: string;
|
|
2071
|
+
} | undefined;
|
|
2072
|
+
footer?: {
|
|
2073
|
+
text: string;
|
|
2074
|
+
icon_url?: string | undefined;
|
|
2075
|
+
} | undefined;
|
|
2076
|
+
}>, (args_0: Wordle, args_1: WordleResult) => Awaitable<{
|
|
2077
|
+
author?: {
|
|
2078
|
+
name: string;
|
|
2079
|
+
url?: string | undefined;
|
|
2080
|
+
icon_url?: string | undefined;
|
|
2081
|
+
} | undefined;
|
|
2082
|
+
thumbnail?: {
|
|
2083
|
+
url: string;
|
|
2084
|
+
} | undefined;
|
|
2085
|
+
title?: string | undefined;
|
|
2086
|
+
color?: number | undefined;
|
|
2087
|
+
description?: string | undefined;
|
|
2088
|
+
image?: {
|
|
2089
|
+
url: string;
|
|
2090
|
+
} | undefined;
|
|
2091
|
+
footer?: {
|
|
2092
|
+
text: string;
|
|
2093
|
+
icon_url?: string | undefined;
|
|
2094
|
+
} | undefined;
|
|
2095
|
+
}>>]>>;
|
|
2096
|
+
winMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: WordleResult, game: Wordle) => string, (result: WordleResult, game: Wordle) => string>]>>>;
|
|
2097
|
+
loseMessage: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<() => string, string>>, z.ZodCustom<(result: WordleResult, game: Wordle) => string, (result: WordleResult, game: Wordle) => string>]>>>;
|
|
2098
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
2099
|
+
word: z.ZodOptional<z.ZodString>;
|
|
2100
|
+
}, z.core.$strip>;
|
|
2101
|
+
/**
|
|
2102
|
+
* A game where the player needs to guess the word.
|
|
2103
|
+
*
|
|
2104
|
+
* # Permissions
|
|
2105
|
+
*
|
|
2106
|
+
* The bot needs to be able to read the messages of the current channel.
|
|
2107
|
+
*
|
|
2108
|
+
* # Custom Display
|
|
2109
|
+
*
|
|
2110
|
+
* If you are using functions to create the embeds, use `attachment://board.png`
|
|
2111
|
+
* in the embed image URL to display the board.
|
|
2112
|
+
*
|
|
2113
|
+
* # Example
|
|
2114
|
+
*
|
|
2115
|
+
* ```js
|
|
2116
|
+
* const game = new Wordle(interaction, {
|
|
2117
|
+
* timeout: 120_000
|
|
2118
|
+
* // If you want to use your own words (5 letters):
|
|
2119
|
+
* word: "house",
|
|
2120
|
+
* // Otherwise, it will be random.
|
|
2121
|
+
* });
|
|
2122
|
+
*
|
|
2123
|
+
* game.on("error", err => console.error(err));
|
|
2124
|
+
* game.on("gameOver", result => console.log(result));
|
|
2125
|
+
*
|
|
2126
|
+
* await game.start();
|
|
2127
|
+
* ```
|
|
2128
|
+
*/
|
|
2129
|
+
declare class Wordle extends Game<WordleResult> {
|
|
2130
|
+
readonly options: z.output<typeof wordleOptions>;
|
|
2131
|
+
/**
|
|
2132
|
+
* The word to guess, in lowercase. Either the one specified or a random one.
|
|
2133
|
+
*/
|
|
2134
|
+
readonly word: string;
|
|
2135
|
+
readonly guesses: string[];
|
|
2136
|
+
message: Message | null;
|
|
2137
|
+
collector: MessageCollector | null;
|
|
2138
|
+
constructor(context: GameContext, options?: WordleOptions);
|
|
2139
|
+
start(): Promise<void>;
|
|
2140
|
+
private gameOver;
|
|
2141
|
+
private getBoardAttachment;
|
|
2142
|
+
private getBoardImage;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
export { Connect4, type Connect4Options, type Connect4Result, type Connect4Turn, FastType, type FastTypeOptions, type FastTypeResult, Flood, type FloodOptions, type FloodResult, Game2048, type Game2048Options, type Game2048Result, Memory, type MemoryEmojiPosition, type MemoryOptions, type MemoryResult, Minesweeper, type MinesweeperOptions, type MinesweeperResult, RockPaperScissors, type RockPaperScissorsOptions, type RockPaperScissorsResult, TicTacToe, type TicTacToeOptions, type TicTacToeResult, type TicTacToeTurn, Trivia, type TriviaData, type TriviaOptions, type TriviaResult, Wordle, type WordleOptions, type WordleResult, connect4Options, fastTypeOptions, floodOptions, game2048Options, jokerEmoji, memoryOptions, minesweeperOptions, rockPaperScissorsOptions, ticTacToeOptions, triviaOptions, wordleOptions };
|