@spatulox/simplediscordbot 3.1.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/index.d.mts +193 -57
- package/dist/index.d.ts +193 -57
- package/dist/index.js +1026 -931
- package/dist/index.mjs +962 -858
- package/package.json +22 -8
- package/.env.example +0 -2
- package/prompt-message-for-wiki.txt +0 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { EmbedBuilder, ContainerBuilder, ActionRowBuilder, MessageActionRowComponentBuilder, Message, TextChannel, DMChannel, ThreadChannel, MessageCreateOptions, User, GuildMember, BaseInteraction, InteractionResponse, Client, ActivityType, InteractionDeferReplyOptions, InteractionReplyOptions,
|
|
2
|
-
import { BaseSelectMenuBuilder } from '@discordjs/builders';
|
|
1
|
+
import { EmbedBuilder, ContainerBuilder, BaseSelectMenuBuilder, ActionRowBuilder, MessageActionRowComponentBuilder, InteractionUpdateOptions, InteractionEditReplyOptions, MessageEditOptions, Message, TextChannel, DMChannel, ThreadChannel, MessageCreateOptions, User, GuildMember, BaseInteraction, InteractionResponse, Client, ActivityType, InteractionDeferReplyOptions, InteractionReplyOptions, Snowflake, WebhookMessageCreateOptions, EmojiResolvable, Guild, BanOptions, GuildBasedChannel, GuildChannelCreateOptions, ForumChannel, NewsChannel, StageChannel, StartThreadOptions, VoiceChannel, Invite, Channel, Collection, GuildBan, ModalBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, MentionableSelectMenuBuilder, ChannelSelectMenuBuilder, ChannelType, StringSelectMenuOptionBuilder, SeparatorSpacingSize, ButtonBuilder, TextDisplayBuilder, AttachmentBuilder, ButtonStyle, RepliableInteraction, InteractionCollector, ButtonInteraction } from 'discord.js';
|
|
3
2
|
export { CacheManager, FileManager, Log, SimpleMutex, Time } from '@spatulox/utils';
|
|
4
3
|
|
|
5
4
|
type SendableComponent = EmbedBuilder | ContainerBuilder | BaseSelectMenuBuilder<any> | ActionRowBuilder<MessageActionRowComponentBuilder>;
|
|
5
|
+
/**
|
|
6
|
+
* Options accepted by interaction.update(), interaction.editReply() and message.edit(),
|
|
7
|
+
* returned by every toXXXUpdate() helper (toInteractionUpdate(), toMessageUpdate())
|
|
8
|
+
*/
|
|
9
|
+
type UpdateOptions = InteractionUpdateOptions & InteractionEditReplyOptions & MessageEditOptions;
|
|
6
10
|
|
|
11
|
+
type LogContent = string | SendableComponent | SendableComponent[];
|
|
7
12
|
type PreciseLogConfig = {
|
|
8
13
|
channelId: string;
|
|
9
14
|
console: boolean;
|
|
@@ -20,7 +25,6 @@ declare class BotLog {
|
|
|
20
25
|
private static warnChannel;
|
|
21
26
|
private static debugChannel;
|
|
22
27
|
private static errorChannel;
|
|
23
|
-
constructor();
|
|
24
28
|
static config(): ConfigLog | undefined;
|
|
25
29
|
/**
|
|
26
30
|
* Initialize Discord logging channels and update Bot.log references
|
|
@@ -30,33 +34,38 @@ declare class BotLog {
|
|
|
30
34
|
* Send content to specific Discord channel
|
|
31
35
|
*/
|
|
32
36
|
private static _sendToChannel;
|
|
37
|
+
/**
|
|
38
|
+
* Text printed in the console : the string itself, or the description / title of an embed
|
|
39
|
+
*/
|
|
40
|
+
private static _consoleText;
|
|
33
41
|
/**
|
|
34
42
|
* Send INFO log - TEXT or EMBED ! Respecte config.log.info
|
|
35
43
|
*/
|
|
36
|
-
static info(content:
|
|
44
|
+
static info(content: LogContent): Promise<Message | void>;
|
|
37
45
|
/**
|
|
38
46
|
* Send ERROR log - TEXT or EMBED ! Respecte config.log.error
|
|
39
47
|
*/
|
|
40
|
-
static error(content:
|
|
48
|
+
static error(content: LogContent): Promise<Message | void>;
|
|
41
49
|
/**
|
|
42
50
|
* Send WARNING log - TEXT or EMBED ! Respecte config.log.warn
|
|
43
51
|
*/
|
|
44
|
-
static warn(content:
|
|
52
|
+
static warn(content: LogContent): Promise<Message | void>;
|
|
45
53
|
/**
|
|
46
54
|
* Send DEBUG log - TEXT or EMBED ! Respecte config.log.debug
|
|
47
55
|
*/
|
|
48
|
-
static debug(content:
|
|
56
|
+
static debug(content: LogContent): Promise<Message | void>;
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
declare class BotMessage {
|
|
52
60
|
/**
|
|
53
61
|
* Send message to any text-based channel
|
|
54
62
|
*/
|
|
55
|
-
static send(channel: TextChannel | DMChannel | ThreadChannel | string, content?: string | null, component?: SendableComponent): Promise<Message | null>;
|
|
56
|
-
static send(channel: TextChannel | DMChannel | ThreadChannel | string, content: SendableComponent): Promise<Message | null>;
|
|
63
|
+
static send(channel: TextChannel | DMChannel | ThreadChannel | string, content?: string | null, component?: SendableComponent | SendableComponent[]): Promise<Message | null>;
|
|
64
|
+
static send(channel: TextChannel | DMChannel | ThreadChannel | string, content: SendableComponent | SendableComponent[]): Promise<Message | null>;
|
|
57
65
|
static send(channel: TextChannel | DMChannel | ThreadChannel | string, content: MessageCreateOptions): Promise<Message | null>;
|
|
58
|
-
static
|
|
59
|
-
static sendDM(userOrId: User | GuildMember | string, content: string
|
|
66
|
+
private static buildPayload;
|
|
67
|
+
static sendDM(userOrId: User | GuildMember | string, content: string, component: SendableComponent | SendableComponent[]): Promise<Message | null>;
|
|
68
|
+
static sendDM(userOrId: User | GuildMember | string, content: string | SendableComponent | SendableComponent[] | MessageCreateOptions): Promise<Message | null>;
|
|
60
69
|
/**
|
|
61
70
|
* Quick success message
|
|
62
71
|
*/
|
|
@@ -67,6 +76,8 @@ declare class BotMessage {
|
|
|
67
76
|
static error(channel: TextChannel | DMChannel | ThreadChannel | User | GuildMember, message: string): Promise<Message | null>;
|
|
68
77
|
}
|
|
69
78
|
|
|
79
|
+
type InteractionComponent = SendableComponent | SendableComponent[];
|
|
80
|
+
type InteractionResult = Promise<InteractionResponse<boolean> | Message<boolean> | boolean>;
|
|
70
81
|
declare class BotInteraction {
|
|
71
82
|
/**
|
|
72
83
|
* InteractionReplyOptions && InteractionUpdateOptions
|
|
@@ -74,16 +85,30 @@ declare class BotInteraction {
|
|
|
74
85
|
*/
|
|
75
86
|
private static buildReplyOptions;
|
|
76
87
|
private static buildUpdateOptions;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
static
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
static
|
|
86
|
-
static
|
|
88
|
+
/**
|
|
89
|
+
* Normalize the (content, component, ephemeral) overloads :
|
|
90
|
+
* (string, ephemeral?) | (component, ephemeral?) | (string, component, ephemeral?)
|
|
91
|
+
*/
|
|
92
|
+
private static resolveArgs;
|
|
93
|
+
/**
|
|
94
|
+
* Reply, or followUp if the interaction is already acknowledged
|
|
95
|
+
*/
|
|
96
|
+
static send(interaction: BaseInteraction, content: string, ephemeral?: boolean): InteractionResult;
|
|
97
|
+
static send(interaction: BaseInteraction, content: InteractionComponent, ephemeral?: boolean): InteractionResult;
|
|
98
|
+
static send(interaction: BaseInteraction, content: string, component: InteractionComponent, ephemeral?: boolean): InteractionResult;
|
|
99
|
+
static reply(interaction: BaseInteraction, content: string, ephemeral?: boolean): InteractionResult;
|
|
100
|
+
static reply(interaction: BaseInteraction, content: InteractionComponent, ephemeral?: boolean): InteractionResult;
|
|
101
|
+
static reply(interaction: BaseInteraction, content: string, component: InteractionComponent, ephemeral?: boolean): InteractionResult;
|
|
102
|
+
static followUp(interaction: BaseInteraction, content: string, ephemeral?: boolean): InteractionResult;
|
|
103
|
+
static followUp(interaction: BaseInteraction, content: InteractionComponent, ephemeral?: boolean): InteractionResult;
|
|
104
|
+
static followUp(interaction: BaseInteraction, content: string, component: InteractionComponent, ephemeral?: boolean): InteractionResult;
|
|
105
|
+
/**
|
|
106
|
+
* @param ephemeral Only used by commands : components and modals defer the message they come from
|
|
107
|
+
*/
|
|
108
|
+
static defer(interaction: BaseInteraction, ephemeral?: boolean): Promise<InteractionResponse<boolean> | void>;
|
|
109
|
+
static update(interaction: BaseInteraction, content: string): InteractionResult;
|
|
110
|
+
static update(interaction: BaseInteraction, content: InteractionComponent): InteractionResult;
|
|
111
|
+
static update(interaction: BaseInteraction, content: string, component: InteractionComponent): InteractionResult;
|
|
87
112
|
}
|
|
88
113
|
|
|
89
114
|
declare enum SimpleColor {
|
|
@@ -131,7 +156,6 @@ type BotConfig = {
|
|
|
131
156
|
botName?: string;
|
|
132
157
|
log?: ConfigLog;
|
|
133
158
|
};
|
|
134
|
-
type InternalBotConfig = {} & BotConfig;
|
|
135
159
|
type RandomBotActivity = {
|
|
136
160
|
type: ActivityType;
|
|
137
161
|
message: string;
|
|
@@ -140,17 +164,26 @@ declare class Bot {
|
|
|
140
164
|
static readonly log: typeof BotLog;
|
|
141
165
|
static readonly message: typeof BotMessage;
|
|
142
166
|
static readonly interaction: typeof BotInteraction;
|
|
143
|
-
static _client
|
|
144
|
-
private static
|
|
167
|
+
private static _client;
|
|
168
|
+
private static token;
|
|
145
169
|
private static _config;
|
|
146
|
-
|
|
170
|
+
private static randomActivityInterval;
|
|
171
|
+
get config(): BotConfig;
|
|
147
172
|
get client(): Client;
|
|
148
173
|
static get client(): Client;
|
|
149
|
-
static get config():
|
|
174
|
+
static get config(): BotConfig;
|
|
175
|
+
/**
|
|
176
|
+
* Resolves once the login is done (true) or has definitively failed (false)
|
|
177
|
+
*/
|
|
178
|
+
readonly started: Promise<boolean>;
|
|
150
179
|
constructor(client: Client, config?: BotConfig);
|
|
151
180
|
login(maxTries?: number): Promise<boolean>;
|
|
152
181
|
static setActivity(message: string, type: ActivityType): void;
|
|
153
182
|
static setRandomActivity(randomActivity: RandomBotActivity, intervalMs?: number | null): void;
|
|
183
|
+
/**
|
|
184
|
+
* Stop the rotation started by setRandomActivity(), the current activity is kept
|
|
185
|
+
*/
|
|
186
|
+
static stopRandomActivity(): void;
|
|
154
187
|
}
|
|
155
188
|
|
|
156
189
|
declare const BotEnv: {
|
|
@@ -207,9 +240,13 @@ declare class EmbedManager {
|
|
|
207
240
|
*/
|
|
208
241
|
static toInteraction(embed: EmbedBuilder, ephemeral?: boolean): InteractionReplyOptions;
|
|
209
242
|
/**
|
|
210
|
-
*
|
|
243
|
+
* Options to edit an existing message : message.edit()
|
|
211
244
|
*/
|
|
212
|
-
static
|
|
245
|
+
static toMessageUpdate(embed: EmbedBuilder): UpdateOptions;
|
|
246
|
+
/**
|
|
247
|
+
* Options for interaction.update() and interaction.editReply() (buttons, select menus, modals, deferred replies)
|
|
248
|
+
*/
|
|
249
|
+
static toInteractionUpdate(embed: EmbedBuilder): UpdateOptions;
|
|
213
250
|
/**
|
|
214
251
|
* Transform embed into objet to send a message
|
|
215
252
|
*/
|
|
@@ -220,7 +257,8 @@ declare class WebhookManager {
|
|
|
220
257
|
private readonly client;
|
|
221
258
|
private readonly name;
|
|
222
259
|
private readonly avatarPathOrUrl?;
|
|
223
|
-
|
|
260
|
+
/** One webhook per channel id (the parent channel id for threads) */
|
|
261
|
+
private readonly webhooks;
|
|
224
262
|
constructor(client: Client, name: string, avatarPathOrUrl?: string | undefined);
|
|
225
263
|
private getAvatar;
|
|
226
264
|
/**
|
|
@@ -228,7 +266,11 @@ declare class WebhookManager {
|
|
|
228
266
|
*/
|
|
229
267
|
private getChannel;
|
|
230
268
|
/**
|
|
231
|
-
*
|
|
269
|
+
* Channel owning the webhook : the parent channel when targeting a thread
|
|
270
|
+
*/
|
|
271
|
+
private getWebhookChannel;
|
|
272
|
+
/**
|
|
273
|
+
* Get or create webhook (lazy initialization, cached per channel)
|
|
232
274
|
* Create the webhook in the parent channel if it's in a thread
|
|
233
275
|
*/
|
|
234
276
|
private getWebhook;
|
|
@@ -236,7 +278,7 @@ declare class WebhookManager {
|
|
|
236
278
|
* Send message/text/component !
|
|
237
279
|
*/
|
|
238
280
|
send(channelId: Snowflake, content: string): Promise<Message | null>;
|
|
239
|
-
send(channelId: Snowflake, content: SendableComponent): Promise<Message | null>;
|
|
281
|
+
send(channelId: Snowflake, content: SendableComponent | SendableComponent[]): Promise<Message | null>;
|
|
240
282
|
send(channelId: Snowflake, content: WebhookMessageCreateOptions): Promise<Message | null>;
|
|
241
283
|
/**
|
|
242
284
|
* Quick success embed
|
|
@@ -253,6 +295,10 @@ declare class WebhookManager {
|
|
|
253
295
|
}
|
|
254
296
|
|
|
255
297
|
declare class ReactionManager {
|
|
298
|
+
/**
|
|
299
|
+
* Any text based channel : guild channels, threads and DMs
|
|
300
|
+
*/
|
|
301
|
+
private static fetchMessage;
|
|
256
302
|
/**
|
|
257
303
|
* Add a reaction to a message
|
|
258
304
|
*/
|
|
@@ -315,7 +361,7 @@ declare class GuildUserManager extends BasicUserManager {
|
|
|
315
361
|
/**
|
|
316
362
|
* Check if a member is in voice
|
|
317
363
|
*/
|
|
318
|
-
static isInVoice(
|
|
364
|
+
static isInVoice(guildId: string, memberId: string): Promise<boolean>;
|
|
319
365
|
/**
|
|
320
366
|
* Mute a member
|
|
321
367
|
*/
|
|
@@ -369,15 +415,24 @@ declare class RoleManager {
|
|
|
369
415
|
* Check if member has role
|
|
370
416
|
*/
|
|
371
417
|
static hasRole(member: GuildMember, roleIdOrName: Snowflake | string): boolean;
|
|
418
|
+
/**
|
|
419
|
+
* Search by id first, then by name (case insensitive). Snowflakes are 17 to 20 digits long,
|
|
420
|
+
* so the length of the string can't tell an id from a name
|
|
421
|
+
*/
|
|
422
|
+
private static resolve;
|
|
372
423
|
}
|
|
373
424
|
|
|
374
425
|
declare class GuildMessageManager {
|
|
426
|
+
/**
|
|
427
|
+
* Any guild channel able to hold messages : text, announcement, thread, voice / stage text chat
|
|
428
|
+
*/
|
|
429
|
+
private static findTextBased;
|
|
375
430
|
/**
|
|
376
431
|
* Overloads for send
|
|
377
432
|
*/
|
|
378
|
-
static send(channelId: string, content: string): Promise<Message>;
|
|
379
|
-
static send(channelId: string, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
380
|
-
static send(channelId: string, options: MessageCreateOptions): Promise<Message>;
|
|
433
|
+
static send(channelId: string, content: string): Promise<Message | null>;
|
|
434
|
+
static send(channelId: string, component: SendableComponent | SendableComponent[]): Promise<Message | null>;
|
|
435
|
+
static send(channelId: string, options: MessageCreateOptions): Promise<Message | null>;
|
|
381
436
|
/**
|
|
382
437
|
* Delete message
|
|
383
438
|
*/
|
|
@@ -442,9 +497,9 @@ declare class ThreadChannelManager {
|
|
|
442
497
|
static findAll(guildId: string): ThreadChannel[];
|
|
443
498
|
static createFromChannel(parentId: string, options: StartThreadOptions): Promise<ThreadChannel>;
|
|
444
499
|
static createFromMessage(message: Message, options: StartThreadOptions): Promise<ThreadChannel>;
|
|
445
|
-
static send(channelId: string, content: string): Promise<Message>;
|
|
446
|
-
static send(channelId: string, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
447
|
-
static send(channelId: string, options: MessageCreateOptions): Promise<Message>;
|
|
500
|
+
static send(channelId: string, content: string): Promise<Message | null>;
|
|
501
|
+
static send(channelId: string, component: SendableComponent | SendableComponent[]): Promise<Message | null>;
|
|
502
|
+
static send(channelId: string, options: MessageCreateOptions): Promise<Message | null>;
|
|
448
503
|
}
|
|
449
504
|
|
|
450
505
|
declare class GuildVoiceChannelManager extends GuildChannelManager {
|
|
@@ -475,13 +530,27 @@ declare class InviteManager {
|
|
|
475
530
|
temporary?: boolean;
|
|
476
531
|
}): Promise<Invite>;
|
|
477
532
|
/**
|
|
478
|
-
*
|
|
533
|
+
* Find an invite by its code or its url (discord.gg/code, discord.com/invite/code)
|
|
534
|
+
*/
|
|
535
|
+
static find(codeOrUrl: string): Promise<Invite | null>;
|
|
536
|
+
/**
|
|
537
|
+
* Delete an invitation, from the invite itself or its code / url
|
|
479
538
|
*/
|
|
480
539
|
static delete(invite: Invite): Promise<boolean>;
|
|
540
|
+
static delete(codeOrUrl: string): Promise<boolean>;
|
|
481
541
|
/**
|
|
482
542
|
* List every invitation from a guild
|
|
483
543
|
*/
|
|
484
544
|
static list(guildId: string): Promise<Invite[]>;
|
|
545
|
+
/**
|
|
546
|
+
* Check if an invite is older than maxAgeMs (default 1 hour).
|
|
547
|
+
* Permanent invites (maxAge = 0) and excluded codes are never considered old
|
|
548
|
+
*/
|
|
549
|
+
static isOld(invite: Invite, excludedCodes?: string[], maxAgeMs?: number): boolean;
|
|
550
|
+
/**
|
|
551
|
+
* Delete every old invite of a guild, returns the number of deleted invites
|
|
552
|
+
*/
|
|
553
|
+
static cleanup(guildId: string, excludedCodes?: string[], maxAgeMs?: number): Promise<number>;
|
|
485
554
|
}
|
|
486
555
|
|
|
487
556
|
declare class GuildManager {
|
|
@@ -498,11 +567,11 @@ declare class GuildManager {
|
|
|
498
567
|
/**
|
|
499
568
|
* Search guild member by ID
|
|
500
569
|
*/
|
|
501
|
-
static searchMember(
|
|
570
|
+
static searchMember(guildId: string, memberId: string): Promise<GuildMember | null>;
|
|
502
571
|
/**
|
|
503
572
|
* Check if member is still in guild
|
|
504
573
|
*/
|
|
505
|
-
static isMemberInGuild(
|
|
574
|
+
static isMemberInGuild(guildId: string, memberId: string): Promise<boolean>;
|
|
506
575
|
/**
|
|
507
576
|
* Fetch all members with retry (heavy operation)
|
|
508
577
|
*/
|
|
@@ -524,6 +593,8 @@ declare enum ModalFieldType {
|
|
|
524
593
|
}
|
|
525
594
|
interface BaseModalField {
|
|
526
595
|
label: string;
|
|
596
|
+
/** Custom id of the input, default `${modalCustomId}_${label}` (add()) or `${modalCustomId}_input` (simple()) */
|
|
597
|
+
customId?: string;
|
|
527
598
|
value?: string;
|
|
528
599
|
required?: boolean;
|
|
529
600
|
}
|
|
@@ -554,16 +625,20 @@ declare class ModalManager {
|
|
|
554
625
|
static titleDescription(customId: string, modalTitle: string, title: Omit<TextModalField, "type">, description: Omit<TextModalField, "type">): ModalBuilder;
|
|
555
626
|
/**
|
|
556
627
|
* Date modal preset
|
|
628
|
+
* @param suffix true (default) : the modal customId is `${customId}_date` and the input `${customId}_date_input`,
|
|
629
|
+
* false : the modal keeps `customId` and the input is `${customId}_input`. Same for number() (_number) and phone() (_phone_number)
|
|
557
630
|
*/
|
|
558
|
-
static date(customId: string, modalTitle?: string, inputLabel?: string): ModalBuilder;
|
|
631
|
+
static date(customId: string, modalTitle?: string, inputLabel?: string, suffix?: boolean): ModalBuilder;
|
|
559
632
|
/**
|
|
560
633
|
* Number modal preset
|
|
634
|
+
* @param suffix See date() : `${customId}_number` by default, `customId` when false
|
|
561
635
|
*/
|
|
562
|
-
static number(customId: string, modalTitle?: string, inputLabel?: string): ModalBuilder;
|
|
636
|
+
static number(customId: string, modalTitle?: string, inputLabel?: string, suffix?: boolean): ModalBuilder;
|
|
563
637
|
/**
|
|
564
|
-
*
|
|
638
|
+
* Phone modal preset
|
|
639
|
+
* @param suffix See date() : `${customId}_phone_number` by default, `customId` when false
|
|
565
640
|
*/
|
|
566
|
-
static phone(customId: string, modalTitle?: string, inputLabel?: string): ModalBuilder;
|
|
641
|
+
static phone(customId: string, modalTitle?: string, inputLabel?: string, suffix?: boolean): ModalBuilder;
|
|
567
642
|
/**
|
|
568
643
|
* Add field to existing modal (Fluent API)
|
|
569
644
|
*/
|
|
@@ -576,6 +651,10 @@ declare class ModalManager {
|
|
|
576
651
|
* @param value
|
|
577
652
|
*/
|
|
578
653
|
static parseDate(value: string): Date | null;
|
|
654
|
+
/**
|
|
655
|
+
* new Date() silently rolls an impossible date over (31/02 becomes 02/03) : reject any date that doesn't round-trip
|
|
656
|
+
*/
|
|
657
|
+
private static buildDate;
|
|
579
658
|
}
|
|
580
659
|
|
|
581
660
|
type SelectMenuCreateOption = {
|
|
@@ -616,9 +695,11 @@ declare class SelectMenuManager {
|
|
|
616
695
|
*/
|
|
617
696
|
static channels(customId: string, placeholder?: string, channelTypes?: ChannelType[]): ChannelSelectMenuBuilder;
|
|
618
697
|
/**
|
|
619
|
-
* Quick option creator
|
|
698
|
+
* Quick option creator : one option, or several at once
|
|
699
|
+
* `menu.addOptions(SelectMenuManager.option([{label: "A", value: "a"}, {label: "B", value: "b"}]))`
|
|
620
700
|
*/
|
|
621
|
-
|
|
701
|
+
static option(option: SelectMenuCreateOption): StringSelectMenuOptionBuilder;
|
|
702
|
+
static option(options: SelectMenuCreateOption[]): StringSelectMenuOptionBuilder[];
|
|
622
703
|
private static _createOption;
|
|
623
704
|
/**
|
|
624
705
|
* Fluent API pour personnaliser
|
|
@@ -636,7 +717,14 @@ declare class SelectMenuManager {
|
|
|
636
717
|
static rows(...components: MessageActionRowComponentBuilder[]): ActionRowBuilder<MessageActionRowComponentBuilder>[];
|
|
637
718
|
static toMessage(menus: SelectMenuList | SelectMenuList[] | ActionRowBuilder<MessageActionRowComponentBuilder> | ActionRowBuilder<MessageActionRowComponentBuilder>[]): MessageCreateOptions;
|
|
638
719
|
static toInteraction(menus: SelectMenuList | SelectMenuList[] | ActionRowBuilder<MessageActionRowComponentBuilder> | ActionRowBuilder<MessageActionRowComponentBuilder>[], ephemeral?: boolean): InteractionReplyOptions;
|
|
639
|
-
|
|
720
|
+
/**
|
|
721
|
+
* Options to edit an existing message : message.edit()
|
|
722
|
+
*/
|
|
723
|
+
static toMessageUpdate(menus: SelectMenuList | SelectMenuList[] | ActionRowBuilder<MessageActionRowComponentBuilder> | ActionRowBuilder<MessageActionRowComponentBuilder>[]): UpdateOptions;
|
|
724
|
+
/**
|
|
725
|
+
* Options for interaction.update() and interaction.editReply() (buttons, select menus, modals, deferred replies)
|
|
726
|
+
*/
|
|
727
|
+
static toInteractionUpdate(menus: SelectMenuList | SelectMenuList[] | ActionRowBuilder<MessageActionRowComponentBuilder> | ActionRowBuilder<MessageActionRowComponentBuilder>[]): UpdateOptions;
|
|
640
728
|
private static _createRowsToReturn;
|
|
641
729
|
}
|
|
642
730
|
|
|
@@ -733,6 +821,10 @@ declare class ComponentManager {
|
|
|
733
821
|
container: ContainerBuilder;
|
|
734
822
|
files: AttachmentBuilder[];
|
|
735
823
|
};
|
|
824
|
+
/**
|
|
825
|
+
* Returns a copy with the footer, so calling toMessage() / toInteraction() twice on the same
|
|
826
|
+
* container doesn't stack footers
|
|
827
|
+
*/
|
|
736
828
|
private static footer;
|
|
737
829
|
/**
|
|
738
830
|
* Transform ComponentV2 into object for channel.send()
|
|
@@ -741,8 +833,15 @@ declare class ComponentManager {
|
|
|
741
833
|
* @param footer Sometimes you don't want to have the Bot name neither the timestamp...
|
|
742
834
|
*/
|
|
743
835
|
static toMessage(container: ContainerBuilder, file?: AttachmentBuilder | AttachmentBuilder[] | null, footer?: boolean): MessageCreateOptions;
|
|
744
|
-
static toInteraction(container: ContainerBuilder, file?: AttachmentBuilder | AttachmentBuilder[] | null, footer?: boolean): InteractionReplyOptions;
|
|
745
|
-
|
|
836
|
+
static toInteraction(container: ContainerBuilder, file?: AttachmentBuilder | AttachmentBuilder[] | null, footer?: boolean, ephemeral?: boolean): InteractionReplyOptions;
|
|
837
|
+
/**
|
|
838
|
+
* Options to edit an existing message : message.edit(). The Components V2 flag is set, so a legacy message can be turned into a V2 one
|
|
839
|
+
*/
|
|
840
|
+
static toMessageUpdate(container: ContainerBuilder, file?: AttachmentBuilder | AttachmentBuilder[] | null, footer?: boolean): UpdateOptions;
|
|
841
|
+
/**
|
|
842
|
+
* Options for interaction.update() and interaction.editReply() (buttons, select menus, modals, deferred replies), with the Components V2 flag
|
|
843
|
+
*/
|
|
844
|
+
static toInteractionUpdate(container: ContainerBuilder, file?: AttachmentBuilder | AttachmentBuilder[] | null, footer?: boolean): UpdateOptions;
|
|
746
845
|
}
|
|
747
846
|
|
|
748
847
|
interface ProgressBarOptions {
|
|
@@ -845,6 +944,8 @@ interface ButtonOptions {
|
|
|
845
944
|
customId: string;
|
|
846
945
|
disabled?: boolean;
|
|
847
946
|
}
|
|
947
|
+
/** One button, one row, or an array mixing buttons and rows (consecutive buttons are grouped by 5 per row) */
|
|
948
|
+
type ButtonInput = ButtonBuilder | ActionRowBuilder<ButtonBuilder> | (ButtonBuilder | ActionRowBuilder<ButtonBuilder>)[];
|
|
848
949
|
declare class ButtonManager {
|
|
849
950
|
static create(options: ButtonOptions & {
|
|
850
951
|
style: ButtonStyle;
|
|
@@ -861,19 +962,53 @@ declare class ButtonManager {
|
|
|
861
962
|
static cancel(customId: string): ButtonBuilder;
|
|
862
963
|
static row(but: ButtonBuilder): ActionRowBuilder<ButtonBuilder>;
|
|
863
964
|
static row(but: ButtonBuilder[]): ActionRowBuilder<ButtonBuilder>;
|
|
864
|
-
static toMessage(button:
|
|
865
|
-
static toInteraction(button:
|
|
866
|
-
|
|
965
|
+
static toMessage(button: ButtonInput): MessageCreateOptions;
|
|
966
|
+
static toInteraction(button: ButtonInput, ephemeral?: boolean): InteractionReplyOptions;
|
|
967
|
+
/**
|
|
968
|
+
* Options to edit an existing message : message.edit()
|
|
969
|
+
*/
|
|
970
|
+
static toMessageUpdate(button: ButtonInput): UpdateOptions;
|
|
971
|
+
/**
|
|
972
|
+
* Options for interaction.update() and interaction.editReply() (buttons, select menus, modals, deferred replies)
|
|
973
|
+
*/
|
|
974
|
+
static toInteractionUpdate(button: ButtonInput): UpdateOptions;
|
|
975
|
+
/**
|
|
976
|
+
* Consecutive buttons are grouped by 5 in the same row (like row() does), action rows are kept as is
|
|
977
|
+
*/
|
|
867
978
|
private static createRowsToReturn;
|
|
868
979
|
}
|
|
869
980
|
|
|
981
|
+
interface PaginationPage {
|
|
982
|
+
embed: EmbedBuilder;
|
|
983
|
+
content?: string;
|
|
984
|
+
}
|
|
985
|
+
interface PaginationOptions {
|
|
986
|
+
/** Total lifetime of the pagination in ms, default 60000 */
|
|
987
|
+
time?: number;
|
|
988
|
+
/** Stop after this many ms without any click, default 15000 */
|
|
989
|
+
idle?: number;
|
|
990
|
+
/** Only used when the interaction isn't acknowledged yet, default false */
|
|
991
|
+
ephemeral?: boolean;
|
|
992
|
+
}
|
|
993
|
+
declare class PaginationManager {
|
|
994
|
+
/**
|
|
995
|
+
* Reply to the interaction (or edit the deferred reply) with the first page and navigation buttons.
|
|
996
|
+
* Only the user who triggered the interaction can navigate, and the buttons are disabled when the
|
|
997
|
+
* collector ends.
|
|
998
|
+
*/
|
|
999
|
+
static send(interaction: RepliableInteraction, pages: PaginationPage[], options?: PaginationOptions): Promise<InteractionCollector<ButtonInteraction> | null>;
|
|
1000
|
+
private static row;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
870
1003
|
/**
|
|
871
1004
|
* Classe utilitaire pour valider tous les formats Discord avec regex
|
|
872
1005
|
*/
|
|
873
1006
|
declare class DiscordRegex {
|
|
874
1007
|
static readonly SPACE = "\u200B";
|
|
875
1008
|
static readonly URL_REGEX: RegExp;
|
|
1009
|
+
static readonly DISCORD_URL: RegExp;
|
|
876
1010
|
static readonly USER_REGEX: RegExp;
|
|
1011
|
+
/** @deprecated A bot mention can't be told apart from a user mention : same as USER_REGEX */
|
|
877
1012
|
static readonly BOT_REGEX: RegExp;
|
|
878
1013
|
static readonly CHANNEL_REGEX: RegExp;
|
|
879
1014
|
static readonly ROLE_REGEX: RegExp;
|
|
@@ -888,6 +1023,7 @@ declare class DiscordRegex {
|
|
|
888
1023
|
* Mention a Channel
|
|
889
1024
|
*/
|
|
890
1025
|
static readonly DISCORD_MENTION_REGEX: RegExp;
|
|
1026
|
+
static readonly SNOWFLAKE: RegExp;
|
|
891
1027
|
static readonly USER_ID: RegExp;
|
|
892
1028
|
static readonly CHANNEL_ID: RegExp;
|
|
893
1029
|
static readonly GUILD_ID: RegExp;
|
|
@@ -900,11 +1036,11 @@ declare class DiscordRegex {
|
|
|
900
1036
|
static readonly INVITE: RegExp;
|
|
901
1037
|
static readonly EMOJI: RegExp;
|
|
902
1038
|
/**
|
|
903
|
-
* Validate Discord ID
|
|
1039
|
+
* Validate a Discord ID (snowflake, 17 to 20 digits)
|
|
904
1040
|
*/
|
|
905
1041
|
static isDiscordId(id: string): boolean;
|
|
906
1042
|
/**
|
|
907
|
-
*
|
|
1043
|
+
* @deprecated A bot mention can't be told apart from a user mention : same as isUserMention()
|
|
908
1044
|
*/
|
|
909
1045
|
static isBotMention(mention: string): boolean;
|
|
910
1046
|
/**
|
|
@@ -916,7 +1052,7 @@ declare class DiscordRegex {
|
|
|
916
1052
|
*/
|
|
917
1053
|
static isUsername(username: string): boolean;
|
|
918
1054
|
/**
|
|
919
|
-
*
|
|
1055
|
+
* @deprecated Same as isDiscordId()
|
|
920
1056
|
*/
|
|
921
1057
|
static isDiscordIdType(id: string): id is string;
|
|
922
1058
|
/**
|
|
@@ -941,4 +1077,4 @@ declare const SimpleDiscordBotInfo: {
|
|
|
941
1077
|
license: string;
|
|
942
1078
|
};
|
|
943
1079
|
|
|
944
|
-
export { Bot, type BotConfig, BotEnv, ButtonManager, type ButtonOptions, ChartManager, ComponentManager, type ComponentManagerCreate, type ComponentManagerField, type ComponentManagerFileInput, DiscordRegex, EmbedManager, GuildManager, type ModalField, ModalFieldType, ModalManager, type ProgressBarOptions, type ProgressBarRow, type RandomBotActivity, ReactionManager, type SelectMenuCreateOption, type SelectMenuList, SelectMenuManager, SimpleColor, SimpleDiscordBotInfo, type SparklineOptions, type SparklineRow, type SparklinesOptions, UserManager, WebhookManager };
|
|
1080
|
+
export { Bot, type BotConfig, BotEnv, type ButtonInput, ButtonManager, type ButtonOptions, ChartManager, ComponentManager, type ComponentManagerCreate, type ComponentManagerField, type ComponentManagerFileInput, type ConfigLog, DiscordRegex, EmbedManager, GuildManager, type ModalField, ModalFieldType, ModalManager, PaginationManager, type PaginationOptions, type PaginationPage, type ProgressBarOptions, type ProgressBarRow, type RandomBotActivity, ReactionManager, type SelectMenuCreateOption, type SelectMenuList, SelectMenuManager, type SendableComponent, SimpleColor, SimpleDiscordBotInfo, type SparklineOptions, type SparklineRow, type SparklinesOptions, type UpdateOptions, UserManager, WebhookManager };
|